Skip to content
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

NodeSDK configuration with sampler and other settings not applied when using exporter from env #4004

Closed
anuraaga opened this issue Jul 19, 2023 · 1 comment · Fixed by #4394
Labels
bug Something isn't working priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect up-for-grabs Good for taking. Extra help will be provided by maintainers

Comments

@anuraaga
Copy link
Contributor

What happened?

Steps to Reproduce

Configure NodeSDK with sampler: new AlwaysOffSampler() but no traceExporter and run with OTEL_TRACES_EXPORTER=console.

Expected Result

No spans are logged

Actual Result

All spans are logged because the sampler setting is ignored

Additional Details

It seems to be related to only reading the configuration when exporter is defined

https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-sdk-node/src/sdk.ts#L132

But I guess intuitively, the configuration is supposed to work even when using environment variable selection for exporter.

Note, while the example above for simplicitly is using alwaysoffsampler, and thus could have been configured with env var, actually I want to use a custom sampler so need to set it programatically.

OpenTelemetry Setup Code

export const otelSdk = new NodeSDK({
  instrumentations: [
    new DnsInstrumentation(),
    new GrpcInstrumentation(),
    new HttpInstrumentation(),
    new NestInstrumentation(),
    new NetInstrumentation(),
    new PrismaInstrumentation(),
    new WinstonInstrumentation(),
  ],
  sampler: new AlwaysOffSampler(),
});

package.json

Leaving this out since the code in `main` seems obvious enough

Relevant log output

No response

@anuraaga anuraaga added bug Something isn't working triage labels Jul 19, 2023
@dyladan dyladan added priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect up-for-grabs Good for taking. Extra help will be provided by maintainers and removed triage labels Jul 19, 2023
@pichlermarc
Copy link
Member

this seems to be already fixed by #4394
See reproducer repo: https://github.com/pichlermarc/repro-4004/tree/main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect up-for-grabs Good for taking. Extra help will be provided by maintainers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants