You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Logs] Workaround to avoid unwanted OTel log when OTEL_TRACES_SAMPLER = xray (#81)
*Issue #, if available:*
Short-term workaround to avoid Upsteam OTel emitting logs such as:
- `OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".`
OTel dependencies will always load a default Sampler configuration.
Although unused, that load process will read the `OTEL_TRACES_SAMPLER`
value and may emit the above log, which is unwanted for `xray` value.
`xray` does not yet exist in upstream OTel, but in ADOT, we define it as
valid. Thus we temporarily remove this env var to avoid the unwanted log
only if `xray` is set in that Env Var.
When `xray` sampler is available in upstream, this workaround should be
removed.
*Description of changes:*
- Unset `process.env.OTEL_TRACES_SAMPLER` if equal to `xray`, then use
boolean variable to enable `xray` sampler instead of Env Var. Restore
Env Var value later.
- Add log to state that `AWS XRay Sampler enabled`, if enabled
*Testing:*
- Tested that the log `OTEL_TRACES_SAMPLER value "xray invalid,
defaulting to always_on".` doesn't appear in this repo's sample app.
Before:
```
node --require '@aws/aws-distro-opentelemetry-node-autoinstrumentation/register' sample-app-express-server.js
'pollingInterval' is undefined or too small. Defaulting to 300 seconds
OTEL_TRACES_EXPORTER is empty. Using default otlp exporter.
AWS Application Signals enabled.
AWS Application Signals metrics export interval capped to 60000
OTEL_LOGS_EXPORTER is empty. Using default otlp exporter.
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
Setting TraceProvider for instrumentations at the end of initialization
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
...
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
AWS Distro of OpenTelemetry automatic instrumentation started successfully
Listening for requests on http://localhost:8080
...
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
OTEL_TRACES_SAMPLER value "xray invalid, defaulting to always_on".
```
After:
```
node --require '@aws/aws-distro-opentelemetry-node-autoinstrumentation/register' sample-app-express-server.js
AWS XRay Sampler enabled
'pollingInterval' is undefined or too small. Defaulting to 300 seconds
OTEL_TRACES_EXPORTER is empty. Using default otlp exporter.
AWS Application Signals enabled.
AWS Application Signals metrics export interval capped to 60000
OTEL_LOGS_EXPORTER is empty. Using default otlp exporter.
Setting TraceProvider for instrumentations at the end of initialization
AWS Distro of OpenTelemetry automatic instrumentation started successfully
Listening for requests on http://localhost:8080
```
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
0 commit comments