Honeycomb with OpenTelemetry
The spanslice package sets up OpenTelemetry for a Node service. It applies your rules to every span before the span is
exported. It replaces the SDK you start today, either @opentelemetry/sdk-node or Honeycomb’s
@honeycombio/opentelemetry-node. Your instrumentations, and any spans you create with @opentelemetry/api, stay as
they are. To keep your NodeSDK setup instead, see Keep your NodeSDK setup.
Before you start, connect Honeycomb. Then make sure the service exists in SpanSlice, with a dataset in each environment it runs in.
Set up the SDK
Section titled “Set up the SDK”npm install spansliceimport { spanSliceInit } from 'spanslice'import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node'
const telemetry = spanSliceInit({ service: 'api', // the service in SpanSlice; also service.name instrumentations: [getNodeAutoInstrumentations()],})await telemetry.readySPANSLICE_API_KEY=ss_… node --import ./src/instrument.ts server.jsSPANSLICE_API_KEY is the SpanSlice environment’s key, from Settings › API keys. Your Honeycomb ingest key doesn’t
go in your code or your environment variables. The SDK gets it with its config, along with the service’s dataset. See
Install the Node SDK for the other options.
Coming from @honeycombio/opentelemetry-node
Section titled “Coming from @honeycombio/opentelemetry-node”If your service starts Honeycomb’s SDK like this:
import { HoneycombSDK } from '@honeycombio/opentelemetry-node'import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node'
const sdk = new HoneycombSDK({ apiKey: process.env.HONEYCOMB_API_KEY, serviceName: 'api', instrumentations: [getNodeAutoInstrumentations()],})sdk.start()replace it with spanSliceInit, passing the same instrumentations, as in Set up the SDK above.
- Start only one SDK. A process has one OpenTelemetry tracer provider, so spans from the other SDK never reach SpanSlice’s rules.
- Replace any
sampleRateyou set in Honeycomb’s SDK with a Set Sample Rate rule. Then one place decides sampling, and theSampleRatethat Honeycomb receives is correct. HONEYCOMB_API_KEYandHONEYCOMB_DATASETare no longer read. The ingest key and dataset come from Project settings › Honeycomb.
Send with your own OTLP settings
Section titled “Send with your own OTLP settings”To keep Honeycomb’s key in your own deployment, or to send through an OpenTelemetry Collector, set the exporter to
otlp. The SDK then uses the standard OpenTelemetry variables and ignores the destination that SpanSlice resolves:
SPANSLICE_EXPORTER=otlpOTEL_EXPORTER_OTLP_ENDPOINT=https://api.honeycomb.io # https://api.eu1.honeycomb.io for an EU teamOTEL_EXPORTER_OTLP_HEADERS=x-honeycomb-team=<ingest key>- Traces go over OTLP/HTTP (protobuf). Honeycomb stores them in the dataset named after
service.name, which is theserviceyou pass tospanSliceInit. - Metrics need a dataset of their own. Add
OTEL_EXPORTER_OTLP_METRICS_HEADERS=x-honeycomb-team=<ingest key>,x-honeycomb-dataset=api_metrics, or passmetricExporter: 'none'to send no metrics. - For a collector, point
OTEL_EXPORTER_OTLP_ENDPOINTat it, and let the collector’s exporter add the Honeycomb headers. - SpanSlice still provides the rules, synchronous span handling and stuck-span checks. The Honeycomb exporter switches under Project settings › Exporters don’t apply to this process.
What Honeycomb receives
Section titled “What Honeycomb receives”- Only the spans your rules kept. When a span is dropped, its children move up to its nearest kept ancestor, so traces stay connected.
SampleRateon spans from a sampled trace: the trace rate, multiplied by the span rate when a Set Span Sample Rate applied. It’s left off when nothing was sampled.- Attributes as the rules left them, after any renaming, setting, redacting or removal.
- A
<span name> (incomplete)event for a span that’s still open past a stuck-span timeout. It carriesspanslice.stuck_by. See Stuck spans.