Keep your NodeSDK setup
If your service already starts OpenTelemetry with NodeSDK from @opentelemetry/sdk-node, you can keep that setup
and its exporters. spanslice/sdk-node wraps your NodeSDK class, so the options you pass today still work:
// beforeimport { NodeSDK } from '@opentelemetry/sdk-node'
const sdk = new NodeSDK({ ...options })sdk.start()// afterimport { NodeSDK } from '@opentelemetry/sdk-node'import { makeSpanSliceSDK } from 'spanslice/sdk-node'
const SpanSliceSDK = makeSpanSliceSDK(NodeSDK, { service: 'api' })
const sdk = new SpanSliceSDK({ ...options })sdk.start()Set SPANSLICE_API_KEY as described in Install the Node SDK. The second argument
takes the same options as spanSliceInit. The exceptions are exporter, spanProcessors,
batch, instrumentations and resourceAttributes, which come from your NodeSDK options.
What changes
Section titled “What changes”- Every span goes through your rules before it reaches the exporters you configured (
traceExporter,spanProcessors, or theOTEL_TRACES_EXPORTERvariables). Spans a rule drops never reach them. - SpanSlice can switch your instrumentations off, and change their options, from Traces › Instrumentation. No restart is needed.
- Until the first config arrives, spans are held. If it doesn’t arrive within
readyTimeoutMs(5 seconds by default), the SDK sends spans unfiltered instead of holding them.await sdk.readywaits for the config.
Everything else stays with NodeSDK: the sampler, propagators, metrics, logs and resource detection.
When SpanSlice stays out of the way
Section titled “When SpanSlice stays out of the way”Without SPANSLICE_API_KEY or a service name, or with OTEL_SDK_DISABLED=true, SpanSliceSDK behaves exactly like
NodeSDK. It does the same when the exporter is set only through environment variables that the SDK can’t rebuild:
otlp over grpc or http/json, or zipkin. For those, pass the exporter as traceExporter instead, and
SpanSlice sits in front of it.
SpanSlice takes the service name from the first of these that’s set: the service option, NodeSDK’s
serviceName, the service.name on your resource, or OTEL_SERVICE_NAME.