npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@quicore/tracelet-otel

v0.5.0

Published

Explicit Tracelet adapter for application-owned OpenTelemetry providers

Readme

@quicore/tracelet-otel 0.5.0

Optional OpenTelemetry adapter: native spans, W3C propagation, bounded metrics and runtime cache export. Core and runtime remain dependency-free. The application supplies a tracer and optional meter; the adapter never registers global providers/context managers, starts samplers/exporters, installs signal handlers, or flushes/shuts down providers.

Installation and compatibility

npm install @quicore/tracelet-otel @opentelemetry/[email protected]

Requires API peer @opentelemetry/[email protected]; depends on @quicore/[email protected] (internal bridge coupling) and @opentelemetry/[email protected] (W3C propagator). SDKs, exporters, context managers and the runtime sampler are application dependencies. The pinned test/example SDK is 2.12.0. API 1.10 and SDK 3 are not supported by this release's dependency contract.

Engine range: Node ^18.19.0 or >=20.6.0. Windows tests passed on 18.20.8, 20.20.0, 22.22.0 and 24.13.0. Compatibility tests do not endorse EOL runtimes; Linux and other dependency combinations remain unverified. CJS and ESM named imports work. The npm package contains precompiled JavaScript; no build step is needed.

Basic use

For this runnable local example, install the application's SDK dependencies:

npm install @opentelemetry/[email protected] @opentelemetry/[email protected]

The console exporter below is for local inspection. Configure your application's exporter, resources, sampling and bounded batch processing before deployment.

import { createTraceletAdapter } from '@quicore/tracelet-otel';
import { TracerProvider, SimpleSpanProcessor, ConsoleSpanExporter } from '@opentelemetry/sdk-trace';
import { MeterProvider } from '@opentelemetry/sdk-metrics';

const tracerProvider = new TracerProvider({
  spanProcessors: [new SimpleSpanProcessor({ exporter: new ConsoleSpanExporter() })],
});
const meterProvider = new MeterProvider(); // Add a reader/exporter for metric delivery.
const adapter = createTraceletAdapter({
  tracer: tracerProvider.getTracer('my-service.tracelet', '0.5.0'),
  meter: meterProvider.getMeter('my-service.tracelet', '0.5.0'),
  operationNames: ['syncOrders'],
  resourceTypes: ['system'],
  businessMetrics: [{ name: 'orders', type: 'upDownCounter' }],
  tagKeys: ['region'],
});

const work = adapter.create({ operationName: 'syncOrders' });
try {
  work.start().tag('region', 'west');
  // Replace these example observations with measured application values.
  work.recordIO({ status: 200, durationMs: 12, bytesIn: 120 });
  work.increment('orders', 1).complete();
  console.log(adapter.otelContext(work));
} catch (error) {
  work.fail(error);
  throw error;
} finally {
  // In a service, do this once at shutdown after draining all work.
  adapter.dispose();
  await Promise.all([tracerProvider.shutdown(), meterProvider.shutdown()]);
}

CommonJS: const { createTraceletAdapter } = require('@quicore/tracelet-otel'). To export runtime data, install @quicore/tracelet-runtime and pass an application-started sampler as runtimeSampler; the application also owns its shutdown.

withContext requires an application-installed OTel context manager (for Node, AsyncLocalStorageContextManager). Without it the API's no-op manager cannot propagate active context through async work. Explicit parents and createChildSpan() do not need a global manager.

API

| API | Behavior | | --- | --- | | create(coreOptions, spanOptions?) | Returns a normal Tracelet; no late attach to existing contexts | | fromHeaders(headers, coreOptions, spanOptions?) | Explicit W3C extraction; plain objects or native Headers | | inject(tracelet, carrier?, {legacy?: boolean}) | Mutates/returns carrier; clears old W3C fields first; optional legacy trace/span IDs only | | otelContext(tracelet) | Detached native traceId/spanId/traceFlags; null for no-op provider, start failure or capacity shedding | | withContext(tracelet, callback, ...args) | Uses app context manager; returns callback value/promise and restores prior context | | toDiagnostics() | Detached fixed counters plus activeSpans and disposed | | dispose() | Idempotent; removes observable callbacks, ends active SDK spans as abandoned, rejects future creates/children |

spanOptions: explicit parentContext wins, otherwise useActiveContext: true requests the active context; default is a root. kind is a native SpanKind, default INTERNAL. fromHeaders uses an explicit parent or extracted remote parent, otherwise root; trustRemoteParent: false discards remote ancestry. Inbound extraction has no implicit active-context fallback.

| Factory option | Default / limits | | --- | --- | | tracer / meter | Required tracer / optional meter; injected app-owned objects | | operationNames / resourceTypes | Empty static registries, max 100 each; unmatched metric values become other | | businessMetrics | Up to 100 unique {name, type, unit?}; type counter, upDownCounter, or gauge | | tagKeys | Empty allowlist, max 32 | | includeIdentity | false; true includes tenant/integration as trace attributes only | | sanitizeError | Optional synchronous function returning approved name/message/stack strings; no exception text/type/stack by default | | maxActiveSpans | 10000; configurable 1..100000 | | maxDimensionSets | 1000 per synchronous instrument; configurable 1..10000 | | runtimeSampler | Optional schema-1 sampler; requires meter; never started/stopped by adapter |

Registration names match [a-zA-Z][a-zA-Z0-9_.-]{0,127} and must be unique/static. Register once at startup. Use one adapter per instrumentation scope/service lifetime: recreating adapters resets adapter budgets without clearing SDK aggregation, defeating a lifetime cardinality bound.

Lifecycle, identity and ownership

Native spans start at construction, including PENDING time. Start adds an event; complete/fail/skip end once. Fail marks ERROR without a message; complete/skip retain UNSET. Failed I/O does not automatically fail the execution. End timestamps use the core epoch anchor plus monotonic elapsed time.

Existing UUID/custom IDs and snapshot schema 3 remain unchanged. Legacy IDs become trace correlation attributes, never fabricated native IDs or metric dimensions. The SDK owns native identity/sampling. Children inherit native ancestry, can outlive parents, and can be created after parent completion. Parenting into an existing HTTP server span creates an INTERNAL business child by default.

Per-context state is weakly keyed. Completed contexts retain native SpanContext for late children/correlation, not SDK Span objects or ancestor context trees. The bounded active-span registry drops excess native spans while retaining core behavior/metrics. Shed contexts have no native propagation context; a later child can become a new root if capacity returns. Unfinished spans occupy capacity until terminal/disposal; there is no automatic timeout policy.

Disposal ends active SDK spans as abandoned without changing core lifecycle or fabricating terminal execution metrics. Existing contexts continue locally with telemetry disabled. Callback failures are diagnosed and contained. Disposal does not flush or guarantee delivery; exporter queues, retries, transport and shutdown order belong to the app/Collector.

Propagation and data policy

W3C syntax validation uses OTel's propagator. Invalid/duplicate/ambiguous traceparent becomes a root and increments invalidParents. Valid tracestate survives. Baggage is never imported or injected; unrelated fields already in an outgoing carrier are untouched.

Legacy-only incoming correlation starts a native root. Ambiguous custom headers still throw. Incoming tenant/integration headers are ignored: provide authenticated identity in coreOptions. Optional legacy dual-write sends correlation IDs only, unlike core's existing toTraceHeaders(), which can include identity.

Tags export only allowlisted scalars or homogeneous scalar arrays (max 32); strings are capped at 1024 characters. Nested objects are omitted. Registered per-context gauges become span attributes, not global gauges. Exception fields need an explicit sanitizer, with 1024 characters per field. Async sanitizers are unsupported/diagnosed; native promise rejections are consumed. No raw errors are logged on failure.

Operation names, resourceType and legacy IDs still reach trace attributes and may themselves contain sensitive values. Use static operation names and opaque identifiers. This is not automatic PHI/secret redaction or identity verification. SDK attribute limits may drop additional attributes.

Metrics

Names are Tracelet-owned, not a claim of full semantic-convention compliance. Configure service/instance identity on application SDK resources. No tenant, integration, trace/span ID, URL or error text dimensions are used.

| Instrument | Type / unit | Meaning | | --- | --- | --- | | tracelet.executions | Counter / {execution} | Accepted terminal transitions; operation, resource, outcome | | tracelet.execution.duration | Histogram / s | Construction-to-terminal time, same dimensions | | tracelet.io.attempts | Counter / {attempt} | Accepted attempts; operation, resource, success, coarse 1xx..5xx/other status | | tracelet.io.duration | Histogram / s | Valid individual durations, including zero | | tracelet.io.bytes.in / .out | Counter / By | Known byte observations | | tracelet.io.measurement.unavailable | Counter / {measurement} | Missing/invalid by field/reason plus I/O dimensions | | tracelet.business.NAME | Counter or UpDownCounter / configured unit | Registered deltas; Counter drops negative deltas, UpDownCounter preserves them | | tracelet.adapter.events | ObservableCounter / {event} | Fixed diagnostic reason counters |

Unknown business names/types are diagnosed and omitted. Gauge registrations affect traces only; application-wide business gauges should use the application's meter directly. Snapshot reads/resetIO never replay/reset exported counters. Metrics are independent of trace sampling. Histograms receive individual observations, never local percentiles. Configure bucket boundaries and SDK cardinality limits in app-owned views/readers.

Each synchronous instrument independently caps dimension sets and drops excess new sets. A bounded lifetime sum guard drops values that would make an instrument/dimension aggregate nonfinite; this is conservative for delta readers. It does not provide arbitrary precision or prevent downstream overflow when SDK views merge dimensions or services aggregate. SDKs may apply additional limits.

Runtime

Cache export includes CPU user/system cumulative seconds, core-equivalent CPU utilization, RSS, uptime, isolate heap/external/array-buffer bytes, event-loop utilization and mean/max/p50/p95/p99 delay gauges in seconds. CPU time is an ObservableCounter; other measurements are gauges. Delay sample count and sampler interval are also gauges. Workers omit process metrics; isolate series include tracelet.thread.id. Array-buffer bytes are included in external memory; do not sum them.

| Runtime instrument | Unit / dimensions | | --- | --- | | tracelet.process.cpu.time | s; cpu.mode=user/system | | tracelet.process.cpu.utilization | 1; core-equivalents, can exceed 1 | | tracelet.process.memory.rss | By | | tracelet.process.uptime | s | | tracelet.node.heap.used / .total | By; thread | | tracelet.node.memory.external / .array_buffers | By; thread | | tracelet.node.event_loop.utilization | 1; thread | | tracelet.node.event_loop.delay | s; thread, statistic=mean/max/p50/p95/p99 | | tracelet.node.event_loop.delay.samples | {sample}; thread, interval count (not cumulative) | | tracelet.runtime.sample.interval | s; thread | | tracelet.runtime.sample.age | s; thread | | tracelet.runtime.sample.valid | 1; no dimensions | | tracelet.runtime.sample.errors | {error}; thread, fixed reason |

tracelet.runtime.sample.age reports seconds since last successful sample. tracelet.runtime.sample.valid is 1 only when running, status ok, and cache age <= three configured intervals; otherwise 0. tracelet.runtime.sample.errors is an ObservableCounter by fixed reason. Initial deltas and invalid groups are not observed. Multiple readers never collect/reset the sampler.

SDK history caveat: the tested cumulative SDK retains prior values even when later callbacks omit them or are removed. Use sample.valid=1 and freshness when interpreting runtime data; omission does not guarantee remote series disappearance. After disposal even validity can remain in SDK history. Shut down/export app-owned providers deliberately; disposal is not remote series deletion. Partial samples conservatively mark the whole sample invalid.

Deployment limitations

Package installation is separate from production-readiness validation. Collector/OTLP transport, host metrics, Linux, sustained retention/outage tests, SDK 3 migration and LogicMonitor ingestion remain separate work.

License

MIT. See LICENSE.