Skip to content

[pkg/instrumentation] Add feature gate for dotnet instrumentation #1629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

TylerHelmuth
Copy link
Member

This PR puts the dotnet instrumentation behind a feature gate named operator.autoinstrumentation.dotnet. This feature gate is enabled by default, but operator managers could disable it if they do not want Instrumentation to be able to inject dotnet instrumentation.

I'm using dotnet as the guinea pig, but if the pattern is good I'll submit PRs for the other languages as well.

@TylerHelmuth TylerHelmuth requested a review from a team April 4, 2023 20:32
Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one small wording change

@pavolloffay
Copy link
Member

@TylerHelmuth could you please paste here the output of operator's help command?

@TylerHelmuth
Copy link
Member Author

@pavolloffay

❯ go run ./main.go --help 
Usage of /var/folders/kv/z8h_0xts4h7dcr7fl3jsfr540000gp/T/go-build3376509927/b001/exe/main:
      --auto-instrumentation-dotnet-image string   The default OpenTelemetry DotNet instrumentation image. This image is used when no image is specified in the CustomResource. (default "ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-dotnet:0.0.0")
      --auto-instrumentation-java-image string     The default OpenTelemetry Java instrumentation image. This image is used when no image is specified in the CustomResource. (default "ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java:0.0.0")
      --auto-instrumentation-nodejs-image string   The default OpenTelemetry NodeJS instrumentation image. This image is used when no image is specified in the CustomResource. (default "ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-nodejs:0.0.0")
      --auto-instrumentation-python-image string   The default OpenTelemetry Python instrumentation image. This image is used when no image is specified in the CustomResource. (default "ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-python:0.0.0")
      --collector-image string                     The default OpenTelemetry collector image. This image is used when no image is specified in the CustomResource. (default "ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:0.0.0")
      --enable-leader-election                     Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.
      --feature-gates flag                         Comma-delimited list of feature gate identifiers. Prefix with '-' to disable the feature. '+' or no prefix will enable the feature. (default operator.autoinstrumentation.dotnet)
      --health-probe-addr string                   The address the probe endpoint binds to. (default ":8081")
      --kubeconfig string                          Paths to a kubeconfig. Only required if out-of-cluster.
      --labels stringArray                         Labels to filter away from propagating onto deploys
      --metrics-addr string                        The address the metric endpoint binds to. (default ":8080")
      --operator-opamp-bridge-image string         The default OpenTelemetry Operator OpAMP Bridge image. This image is used when no image is specified in the CustomResource. (default "ghcr.io/open-telemetry/opentelemetry-operator/operator-opamp-bridge:0.0.0")
      --target-allocator-image string              The default OpenTelemetry target allocator image. This image is used when no image is specified in the CustomResource. (default "ghcr.io/open-telemetry/opentelemetry-operator/target-allocator:0.0.0")
      --tls-cipher-suites strings                  Comma-separated list of cipher suites for the server. Values are from tls package constants (https://golang.org/pkg/crypto/tls/#pkg-constants). If omitted, the default Go cipher suites will be used
      --tls-min-version string                     Minimum TLS version supported. Value must match version names from https://golang.org/pkg/crypto/tls/#pkg-constants. (default "VersionTLS12")
      --webhook-port int                           The port the webhook endpoint binds to. (default 9443)
      --zap-devel                                  Development Mode defaults(encoder=consoleEncoder,logLevel=Debug,stackTraceLevel=Warn). Production Mode defaults(encoder=jsonEncoder,logLevel=Info,stackTraceLevel=Error)
      --zap-encoder encoder                        Zap log encoding (one of 'json' or 'console')
      --zap-log-level level                        Zap Level to configure the verbosity of logging. Can be one of 'debug', 'info', 'error', or any integer value > 0 which corresponds to custom debug levels of increasing verbosity
      --zap-stacktrace-level level                 Zap Level at and above which stacktraces are captured (one of 'info', 'error', 'panic').
      --zap-time-encoding time-encoding            Zap time encoding (one of 'epoch', 'millis', 'nano', 'iso8601', 'rfc3339' or 'rfc3339nano'). Defaults to 'epoch'.
pflag: help requested
exit status 2

@TylerHelmuth
Copy link
Member Author

@pavolloffay @jaronoff97 added a section to the README detailing the use of the feature gate.

@TylerHelmuth TylerHelmuth force-pushed the add-featuregate-for-dotnet branch from 4dc5811 to f43d5ea Compare April 13, 2023 17:51
@TylerHelmuth
Copy link
Member Author

@pavolloffay @jaronoff97 ready for another review. I'd like to get this one merge in before #1555

Copy link
Member

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just a minor comment.


| Language | Gate | Default Value |
|----------|---------------------------------------|-----------------|
| .NET | `operator.autoinstrumentation.dotnet` | enabled |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is it disabled? with disabled value?

Copy link
Contributor

@jaronoff97 jaronoff97 Apr 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc you can do --feature-gates=-operator.autoinstrumentation.dotnet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pavolloffay I added the disabling instructions above the table:

Prefix a gate with '-' to disable support for the corresponding language.

Let me know if I need to tweak the paragraph or table to make things more obvious.

if featuregate.EnableDotnetAutoInstrumentationSupport.IsEnabled() {
insts.DotNet = inst
} else {
pm.Recorder.Event(pod.DeepCopy(), "Warning", "InstrumentationRequestRejected", "support for .NET auto instrumentation is not enabled")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we keep the log as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll add back the error log.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pavolloffay added back.

@pavolloffay pavolloffay merged commit 5b1d32c into open-telemetry:main Apr 25, 2023
@TylerHelmuth TylerHelmuth deleted the add-featuregate-for-dotnet branch April 25, 2023 15:26
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
…en-telemetry#1629)

* Add feature gate for dotnet instrumentation

* changelog

* Apply feedback

* Move gate into featuregate pkg

* Add featuregates to info log

* Add README entry for the new gate

* Write event if feature gate is disabled

* Add back error log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants