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

@lntrn/otel

v0.2.1

Published

Lantern's add-on for the OpenTelemetry Node SDK: node --import @lntrn/otel/register sends traces, metrics and logs to Lantern's edge or client ingest through the stock NodeSDK and OTLP exporters.

Readme

@lntrn/otel

Lantern's add-on for the OpenTelemetry Node SDK.

Already on OpenTelemetry? Add this

npm install @lntrn/otel @opentelemetry/api @opentelemetry/auto-instrumentations-node
export OTEL_SERVICE_NAME=checkout-api
export LNTRN_EDGE_USER=<org>.<id> LNTRN_EDGE_PASSWORD=…        # an edge credential
export LNTRN_NAMESPACE=checkout LNTRN_ENVIRONMENT=prod
node --import @lntrn/otel/register server.js

That replaces your instrumentation.mjs. @lntrn/otel/register starts a stock NodeSDK before the app loads:

  • the stock OTLP/HTTP protobuf exporters for traces, metrics and logs;
  • @opentelemetry/auto-instrumentations-node when it is installed, with fs off and query strings kept off spans: a server span has url.path and no url.query, and a client span's url.full is origin + path (an OAuth callback's code is never recorded);
  • OpenTelemetry's ES module hook, so ESM libraries (pino, express, …) are instrumented too;
  • a flush before the process exits, when the event loop empties and on SIGTERM/SIGINT.

Your code keeps using @opentelemetry/api as before.

In a container: CMD ["node", "--import", "@lntrn/otel/register", "server.js"], or NODE_OPTIONS="--import @lntrn/otel/register".

Already starting NodeSDK yourself? Call setup() instead, with the same options plus your own:

// instrumentation.mjs, loaded with --import
import { register } from "node:module";
import { setup, noQueryInstrumentationConfig } from "@lntrn/otel";
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";

register("@opentelemetry/instrumentation/hook.mjs", import.meta.url);
const lantern = setup({
  serviceName: "checkout-api",
  // noQueryInstrumentationConfig keeps query strings off spans, as register does.
  instrumentations: [getNodeAutoInstrumentations({ ...noQueryInstrumentationConfig() })],
  sdk: { /* sampler, views, … anything else NodeSDK takes */ },
});
process.once("SIGTERM", () => lantern.shutdown().finally(() => process.exit(0)));

Requires Node 22.15 or newer, as @opentelemetry/sdk-node 0.300 does. Tested with sdk-node 0.300.0 and @opentelemetry/api 1.10.0.

Targets

setup() picks the first one configured, unless target (or LNTRN_TARGET) names one:

| Target | When | Sends to | Auth | |---|---|---|---| | edge | LNTRN_EDGE_USER + LNTRN_EDGE_PASSWORD | https://otlp.lntrn.dev | HTTP Basic, the edge credential | | device | token or LNTRN_DEVICE_TOKEN | https://in.lntrn.dev | Bearer <device token> | | gateway | LNTRN_ENDPOINT with no credential | that endpoint, e.g. an in-cluster collector | none | | otel | OTEL_EXPORTER_OTLP_ENDPOINT (or a signal's own) | wherever OTEL_EXPORTER_OTLP_* say: plain NodeSDK | OTEL_EXPORTER_OTLP_HEADERS | | none | nothing configured, or OTEL_SDK_DISABLED=true | nowhere. Spans still get ids, so log lines still carry them | |

Details:

  • LNTRN_ENDPOINT (endpoint) replaces the edge's or the ingest's address, e.g. https://forwarder.otlp.lntrn.dev.
  • The paths /v1/traces, /v1/metrics and /v1/logs are appended.
  • Lantern's endpoints are OTLP/HTTP only. There is no gRPC.

Node processes on devices

A process running on hardware you don't control can't hold an edge credential. Examples: an emulation node, a kiosk, a desktop app's main process. It sends to the client ingest with a device token instead:

import { setup } from "@lntrn/otel";

setup({
  serviceName: "emulation-node",
  // Called only when the cached token is due for renewal: a minute before exp.
  token: () => fetchTokenFromYourBackend(),   // or mintToken({...}) from @lntrn/device/server, where the key lives
});

The token cache is @lntrn/device/otel's TokenCache, the same one the JS device add-on uses. Concurrent exports share one fetch, and a failed fetch keeps the old token while it is still valid. The ingest files the records under the token's project.

Resource

| Attribute | From | |---|---| | service.name | serviceName; OTEL_SERVICE_NAME wins | | service.version | serviceVersion | | service.namespace | namespace or LNTRN_NAMESPACE | | deployment.environment.name | environment or LNTRN_ENVIRONMENT | | vcs.repository.url.full | repositoryUrl, then LNTRN_VCS_REPOSITORY_URL, then GitLab CI's CI_PROJECT_URL | | vcs.ref.head.revision | revision, then LNTRN_VCS_REVISION, then GitLab CI's CI_COMMIT_SHA | | anything | attributes; OTEL_RESOURCE_ATTRIBUTES wins |

lanternDetector() is the namespace, environment and vcs part as a ResourceDetector, for a NodeSDK you configure entirely yourself.

Which commit is running

vcs.repository.url.full and vcs.ref.head.revision are the OpenTelemetry semantic-convention attributes for the repository and commit a service was built from. Lantern uses them to say what changed before an alert. The URL loses any credentials, a trailing / and .git. An attribute with no source is left out.

A container runs where GitLab's variables don't exist, so carry them from the image build into its environment. The k8s pipeline passes them as build args when the project sets DOCKER_BUILD_ARGS: "CI_PROJECT_URL=$CI_PROJECT_URL CI_COMMIT_SHA=$CI_COMMIT_SHA":

ARG CI_PROJECT_URL CI_COMMIT_SHA
ENV LNTRN_VCS_REPOSITORY_URL=${CI_PROJECT_URL} LNTRN_VCS_REVISION=${CI_COMMIT_SHA}

Prefer the LNTRN_VCS_* names in the image. A process running inside a GitLab job sees that job's CI_*, which may be another project's.

Turning a signal off

OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER or OTEL_LOGS_EXPORTER set to none (or disableTraces/disableMetrics/disableLogs) leaves that signal without an exporter. In Kubernetes, with Lantern's agent collecting container output, set OTEL_LOGS_EXPORTER=none. pino's OpenTelemetry instrumentation still writes trace_id and span_id into every stdout line.

LNTRN_INSTRUMENTATIONS=none stops register from loading the auto-instrumentations.

Releasing

Bump "version" in package.json, add the CHANGELOG entry, and merge to main. CI (.xeonr-ci.yaml, app lntrn-otel-node) tests, builds and publishes any version the registry hasn't got, and tags it node-vX.Y.Z.