opentelemetry-js
opentelemetry-js copied to clipboard
Allow NodeSDK to specify sampler without spanProcessor/exporter
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
This means a sampler cannot be configured when using environment variables to set up the export pipeline.
@dyladan Is this a statement for or against supporting sampler without processor/exporter configuration?
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.
This actually is a bug the more I think about it. It means the sampler is not being applied correctly.
I think this is a duplicate of https://github.com/open-telemetry/opentelemetry-js/issues/4004