Skip to content

Install the Node SDK

The spanslice package is an OpenTelemetry setup for Node. It fetches the rules your project defines in SpanSlice, applies them to every span in your process, and picks up changes without a restart.

Terminal window
npm install spanslice

Each runtime environment (production, staging, …) has its own API key, under your project’s Settings › API keys in the app. Set it as SPANSLICE_API_KEY wherever that environment runs. Without a key the SDK stays off.

Create a file that starts the SDK and load it with --import, so instrumentations can patch libraries before your code imports them:

src/instrument.ts
import { spanSliceInit } from 'spanslice'
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'
const telemetry = spanSliceInit({
service: 'api', // the service in SpanSlice; also service.name
instrumentations: [new HttpInstrumentation()],
})
await telemetry.ready
Terminal window
node --import ./src/instrument.ts server.js

service must be a service deployed to the API key’s environment, otherwise the SDK stays off.

ready resolves once the first config has applied, or after readyTimeoutMs (5 seconds by default) if the API can’t be reached. Until the first config arrives, the SDK holds spans rather than sending them unfiltered.

Option / env Default Meaning
apiKey / SPANSLICE_API_KEY — The environment’s ss_… key.
service OTEL_SERVICE_NAME The service’s slug or name in SpanSlice.
exporter / SPANSLICE_EXPORTER remote remote (where the project sends data), otlp (your own collector), console, or none.
configFile / SPANSLICE_CONFIG_FILE — A config written by spanslice prefetch, applied at boot without waiting on the API.
readyTimeoutMs 5000 How long ready waits for the first config.
apiUrl / SPANSLICE_API_URL https://api.spanslice.com Where the SDK fetches its config.

With the default remote exporter, SpanSlice tells the SDK where to send data (for example, your Honeycomb environment), so your code names no vendor. Spans go straight from your process to that backend; they don’t pass through SpanSlice.

Next: write your first rule.