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

@shukoi/otel

v1.0.4

Published

Enterprise OpenTelemetry distributed tracing and Prometheus metrics plugin for Shukoi.

Readme

@shukoi/otel

Enterprise OpenTelemetry Distributed Tracing & Prometheus Metrics Plugin for Shukoi

npm version License: MIT

@shukoi/otel provides plug-and-play observability and telemetry for Shukoi microservices across Node.js, Bun, Cloudflare Workers, and AWS Lambda without external heavy SDK bloat.


Key Features & Invariants

  • 🔭 W3C TraceContext Compliant: Parses and serializes standard traceparent headers across REST and MCP transports, linking incoming distributed traces to child execution spans.
  • ⚡ Pure Web-Standard Edge Exporter: OtlpHttpSpanExporter (./edge) uses Web-standard fetch with zero node:* imports, operating natively in Cloudflare Workers V8 Isolates.
  • 📦 OTLP 1.34+ Specification Compliant: Emits service.name and custom resource metadata under resource.attributes, ensuring out-of-the-box compatibility with Datadog, Jaeger, Grafana Tempo, and Honeycomb.
  • 🏷️ SpanKind & Semantic Exceptions: Supports standard SpanKind ('INTERNAL', 'SERVER', 'CLIENT', 'PRODUCER', 'CONSUMER') and provides span.recordException(err) for semantic exception logging.
  • 📊 Prometheus Metrics Registry: Contiguous text exposition format generator (./prometheus) adhering to Prometheus 0.0.4 for native Kubernetes scraping via /metrics.
  • 🛡️ Bounded Queue Ceiling: Drop-oldest circular queue with backpressure protection (maxQueueSize: 2048, batchSize: 512) prevents Out-Of-Memory (OOM) failures under network partitions or collector outages.
  • 🧪 In-Memory Testing Harness: Pre-configured MockSpanExporter and MockMetricReader in @shukoi/otel/testing.

Installation

pnpm add @shukoi/otel @shukoi/core

Usage

1. Attaching Telemetry to Shukoi Microservices

import { createDefaultConfig } from '@shukoi/core';
import { createOpenTelemetryPlugin, OtlpHttpSpanExporter } from '@shukoi/otel';

// Configure OTLP HTTP span exporter
const exporter = new OtlpHttpSpanExporter({
  endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT ?? 'http://localhost:4318/v1/traces',
  serviceName: 'order-service',
  resourceAttributes: {
    'deployment.environment': process.env.NODE_ENV ?? 'development',
  },
  timeoutMs: 5000,
});

// Instantiate Shukoi OpenTelemetry plugin
export const otelPlugin = createOpenTelemetryPlugin({
  serviceName: 'order-service',
  serviceVersion: '1.0.4',
  exporter,
  maxQueueSize: 2048,
  batchSize: 512,
});

// Register plugin via ShukoiConfig
export const config = createDefaultConfig({
  plugins: [otelPlugin],
});

2. Scraping Prometheus Metrics in REST Router

import { createRestRouter } from '@shukoi/api';
import { PrometheusRegistry } from '@shukoi/otel';
import { otelPlugin, config } from './config.js';
import { orderAction } from './actions/order.js';

const app = createRestRouter([orderAction], config);

// Instantiate Prometheus registry bound to the plugin's metrics
const prometheus = new PrometheusRegistry(otelPlugin.metrics);

// Expose /metrics endpoint for Prometheus scrapers
app.get('/metrics', (c) => {
  return c.text(prometheus.scrape(), 200, {
    'Content-Type': 'text/plain; version=0.0.4',
  });
});

3. Manual Spans & Semantic Exception Recording

const tracer = otelPlugin.tracer;

// Start active child span
const span = tracer.startSpan('processPayment', parentTraceContext, 'CLIENT');

try {
  await chargeCard();
  span.setStatus('OK');
} catch (err) {
  // Records standard OpenTelemetry exception attributes and sets status to ERROR
  span.recordException(err);
  throw err;
} finally {
  span.end();
}

Configuration Reference

OpenTelemetryPluginConfig

| Option | Type | Default | Description | | :--------------- | :------------- | :----------- | :--------------------------------------------------------------------------- | | serviceName | string | Required | Logical service name for distributed tracing and metrics. | | serviceVersion | string | undefined | Optional semver service release version. | | exporter | SpanExporter | undefined | Span exporter instance (e.g., OtlpHttpSpanExporter or MockSpanExporter). | | maxQueueSize | number | 2048 | Maximum in-memory span queue length before drop-oldest eviction kicks in. | | batchSize | number | 512 | Batch threshold triggering automatic exporter dispatch. |

OtlpHttpExporterOptions

| Option | Type | Default | Description | | :------------------- | :----------------------- | :----------------- | :------------------------------------------------------------------ | | endpoint | string | Required | OTLP/HTTP collector traces endpoint URL. | | serviceName | string | 'shukoi-service' | Service identifier emitted under resource.attributes. | | resourceAttributes | Record<string, string> | undefined | Custom key-value pairs added to resource.attributes. | | headers | Record<string, string> | undefined | Optional authentication or tenant headers (e.g., Authorization). | | timeoutMs | number | 5000 (5s) | HTTP request timeout in milliseconds using AbortSignal.timeout(). |


Testing Telemetry

Use @shukoi/otel/testing for zero-network assertions in unit tests:

import { createOpenTelemetryPlugin } from '@shukoi/otel';
import { MockSpanExporter, MockMetricReader } from '@shukoi/otel/testing';

const mockExporter = new MockSpanExporter();
const otel = createOpenTelemetryPlugin({
  serviceName: 'test-service',
  exporter: mockExporter,
});

// Run actions...
const finishedSpans = mockExporter.getFinishedSpans();
expect(finishedSpans.length).toBeGreaterThan(0);
expect(finishedSpans[0].status.code).toBe('OK');