@picked/telemetry
v0.0.96
Published
Minimal OTLP/HTTP-JSON span emitter shared by the Picked SDK surfaces
Maintainers
Keywords
Readme
@picked/telemetry
A minimal OTLP/HTTP-JSON span emitter shared by the Picked SDK surfaces.
Usage
import { createSpanId, createTelemetryEmitter, createTraceId, toUnixNano } from '@picked/telemetry'
const emitter = createTelemetryEmitter({
endpoint: 'https://production.otel.picked.app/v1/traces',
resource: { 'service.name': 'picked-sdk' },
headers: { 'Picked-Telemetry': 'cli' },
})
emitter.record({
name: 'picked.start',
traceId: createTraceId(),
spanId: createSpanId(),
startTimeUnixNano: toUnixNano(startedAt),
endTimeUnixNano: toUnixNano(finishedAt),
attributes: { 'picked.data.mode': 'api' },
status: 'ok',
})
await emitter.flush()Constraints
- No runtime dependencies, and none from
@opentelemetry/*. Enforced bysrc/package-safety.test.ts. - No Node built-ins. The same test pins it, so the package bundles into a browser page.
- Nothing it does can surface to the host. A blocked request, an offline machine, a
refused batch and a runtime without
fetchall resolve quietly. A failed batch is dropped rather than retried, which is what bounds the buffer on a long-lived page. fetchwithkeepalive, neversendBeacon.sendBeaconcannot set request headers, and the ingest-channel marker has to travel on the request.
