opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

Allow NodeSDK to specify sampler without spanProcessor/exporter

Open dvoytenko opened this issue 2 years ago • 5 comments
trafficstars

What happened?

Steps to Reproduce

const sdk = new NodeSDK({
   sampler: new MySampler(),
});

Expected Result

The specified sampler is used.

Actual Result

Default sampler is initialized.

Additional Details

This is due to this code: the specified sampler is only accepted when the config also contains a spanProcessor or a traceExporter. However, these concepts are not necessarily require each other. It's should be ok to configure one without the other.

OpenTelemetry Setup Code

import { NodeSDK, type NodeSDKConfiguration } from '@opentelemetry/sdk-node';
const sdk = new NodeSDK({
  sampler: new MySampler(), // Never called.
});
sdk.start();


### package.json

```JSON
{
  "dependencies": {
    "@opentelemetry/sdk-node": "^0.44.0"
  }
}

Relevant log output

No response

dvoytenko avatar Oct 17 '23 18:10 dvoytenko

This means a sampler cannot be configured when using environment variables to set up the export pipeline.

dyladan avatar Oct 18 '23 16:10 dyladan

@dyladan Is this a statement for or against supporting sampler without processor/exporter configuration?

dvoytenko avatar Oct 19 '23 22:10 dvoytenko

It's just a statement of the current state sorry. I should have added more context. I think this is something we should fix, but I think it is a feature request and not a bug.

dyladan avatar Oct 25 '23 16:10 dyladan

This actually is a bug the more I think about it. It means the sampler is not being applied correctly.

dyladan avatar Oct 25 '23 16:10 dyladan

I think this is a duplicate of https://github.com/open-telemetry/opentelemetry-js/issues/4004

WesleyYue avatar Feb 27 '24 02:02 WesleyYue