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

@observantic/sdk

v1.0.4

Published

Zero-friction OpenTelemetry SDK and auto-instrumentation for Observantic platform

Readme

@observantic/sdk

The official Node.js SDK and zero-friction OpenTelemetry auto-instrumentation package for the Observantic observability platform.

npm version License: Apache 2.0


⚡ Quick Start

1. Install

npm install @observantic/sdk

2. Initialize in your application

Initialize @observantic/sdk at the very top of your application entry point before importing express or other modules:

import { initObservantic } from "@observantic/sdk";

initObservantic({
  apiKey: "cw_live_sec_your_api_key_here",
  endpoint: "https://api.observantic.com",
  serviceName: "my-express-app",
  environment: "production",
});

import express from "express";

const app = express();

app.get("/users", (req, res) => {
  res.json({ message: "Hello Observantic!" });
});

app.listen(3000, () => console.log("Server running on port 3000"));

⚙️ Configuration

Programmatic Options (ObservanticOptions)

You can pass options directly into initObservantic(options):

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | apiKey | string | process.env.OBSERVANTIC_API_KEY | Ingestion API key for your Observantic workspace. | | endpoint | string | https://api.observantic.com | Observantic base ingestion endpoint URL. | | serviceName | string | process.env.npm_package_name | "node-service" | Service name displayed in the Observantic dashboard. | | environment | string | process.env.NODE_ENV | "development" | Environment (e.g., production, staging). | | serviceVersion | string | process.env.npm_package_version | "1.0.0" | Version of your application. | | traceSampleRate | number | 1.0 | Sampling ratio from 0.0 (0%) to 1.0 (100%). | | autoShutdown | boolean | true | Automatically flush telemetry on SIGTERM and SIGINT. | | debug | boolean | false | Enable OpenTelemetry internal diagnostic logging. | | disabled | boolean | false | Disable all telemetry collection (e.g. in unit tests). | | headers | Record<string, string> | {} | Custom HTTP headers sent to the OTLP exporter. | | resourceAttributes | Record<string, any> | {} | Custom resource attributes attached to all spans/metrics/logs. | | batchTimeoutMillis | number | 5000 | Batch delay before flushing spans. | | signals | { traces?, metrics?, logs? } | All true | Selectively enable or disable individual telemetry signals. |

Environment Variables

Alternatively, configure the SDK entirely through environment variables without hardcoding secrets:

# Required authentication
export OBSERVANTIC_API_KEY="cw_live_sec_xxxxx"

# Optional overrides
export OBSERVANTIC_ENDPOINT="https://api.observantic.com"
export OBSERVANTIC_SERVICE_NAME="auth-service"
export OBSERVANTIC_ENVIRONMENT="production"
export OBSERVANTIC_SERVICE_VERSION="2.4.0"
export OBSERVANTIC_TRACE_SAMPLE_RATE="1.0"
export OBSERVANTIC_DEBUG="false"
export OBSERVANTIC_DISABLED="false"

Then initialize with zero arguments:

import { initObservantic } from "@observantic/sdk";

initObservantic();

🔍 Features

🚀 Express & Node.js Auto-Instrumentation

Automatically instruments HTTP requests, routes, middleware, and database operations without requiring manual span creation:

  • Preserves Trace ID & Span ID across asynchronous workflows.
  • Captures HTTP method, status codes, route templates, client IP, and query parameters.
  • Records unhandled exceptions and errors automatically.

📊 Custom Tracing & OpenTelemetry API Re-exports

@observantic/sdk re-exports standard OpenTelemetry APIs (trace, context, metrics, logs, SpanStatusCode, SpanKind) so you don't need additional dependencies for manual instrumentation:

import { initObservantic, trace, SpanStatusCode } from "@observantic/sdk";

const client = initObservantic({ apiKey: "cw_live_sec_..." });
const tracer = client.getTracer("order-processor");

async function processOrder(orderId) {
  return await tracer.startActiveSpan("order.process", async (span) => {
    try {
      span.setAttribute("order.id", orderId);
      span.setAttribute("order.amount", 99.99);

      // Business logic
      const result = await saveToDatabase(orderId);
      return result;
    } catch (err) {
      span.recordException(err);
      span.setStatus({ code: SpanStatusCode.ERROR, message: err.message });
      throw err;
    } finally {
      span.end();
    }
  });
}

🤖 AI & LLM Observability (Generations)

Observantic provides first-class GenAI observability to track LLM completions, prompt inputs, generated outputs, token usage, and cost estimates. These calls are rendered with rich prompt/completion preview in the Observantic Tracing UI:

import { trackGeneration } from "@observantic/sdk";
import OpenAI from "openai";

const openai = new OpenAI();

const response = await trackGeneration({
  name: "chat.completion",
  model: "gpt-4o",
  system: "openai",
  input: "Summarize the latest AI trends in 2026",
  run: async (span) => {
    return await openai.chat.completions.create({
      model: "gpt-4o",
      messages: [{ role: "user", content: "Summarize the latest AI trends in 2026" }],
    });
  },
});

You can also attach AI attributes to an existing span:

import { recordGeneration } from "@observantic/sdk";

recordGeneration(span, {
  model: "claude-3-5-sonnet",
  system: "anthropic",
  input: promptText,
  output: completionText,
  tokens: { prompt: 150, completion: 320, total: 470 },
  cost: 0.005,
});

📈 Custom Metrics

import { metrics } from "@observantic/sdk";

const meter = metrics.getMeter("order-service");
const orderCounter = meter.createCounter("orders_total", {
  description: "Total number of completed orders",
});

orderCounter.add(1, { "order.type": "subscription" });

🛑 Graceful Shutdown

The SDK automatically registers shutdown handlers for SIGTERM and SIGINT to ensure all in-flight spans and metrics are flushed to Observantic before process exit.

You can also trigger shutdown manually:

import { shutdownObservantic } from "@observantic/sdk";

await shutdownObservantic();

🏗 Architecture

User Application (Express / Node.js)
      ↓
@observantic/sdk (initObservantic)
      ↓
OpenTelemetry NodeSDK
      ↓
OTLP HTTP Exporters (Traces, Logs, Metrics)
      ↓ (HTTP POST + Bearer Auth)
Observantic Ingestion (/v1/traces, /v1/logs, /v1/metrics)
  • Standard OpenTelemetry protocol (OTLP/HTTP).
  • Ingestion token sent via Authorization: Bearer <apiKey> and x-cw-token: <apiKey> headers.
  • Zero vendor lock-in: compatible with the entire OpenTelemetry ecosystem.

📄 License

Apache-2.0