by Theo V.

A complete JavaScript/TypeScript implementation of OpenTelemetry for collecting traces, metrics, and logs from Node.js and browser applications. Supports OTLP exporters, auto-instrumentation, and integrations with Jaeger, Zipkin, and Prometheus.
This block provides the full OpenTelemetry JavaScript SDK and API monorepo, covering distributed tracing, metrics, logging, context propagation, and diagnostics for Node.js and browser environments. It is structured as a Lerna/Nx monorepo with individual packages under api/, packages/, and experimental/. The typical buyer is a platform or backend engineer who needs to add observability instrumentation to a TypeScript/Node.js or browser application.
.github/ - CI workflows, issue templates, and PR templates for GitHub Actionsapi/ - The @opentelemetry/api package: core interfaces for tracing, metrics, context, baggage, and diagnosticsbundler-tests/ - Webpack 4/5 and Node bundler integration smoke testsdoc/ - Project-level documentation and design notese2e-tests/ - End-to-end test suites for SDK packagesexamples/ - Runnable example applications demonstrating SDK usageexperimental/ - Experimental packages that may change without noticeintegration-tests/ - Cross-package compatibility and integration testspackages/ - Stable SDK packages (core, exporters, propagators, resources, SDK traces/metrics/logs)scripts/ - Monorepo tooling and release automation scriptssemantic-conventions/ - OpenTelemetry semantic convention constantslerna.json - Lerna monorepo configurationnx.json - Nx task pipeline configurationtsconfig.base.json - Shared TypeScript base configurationpackage.json - Root workspace manifestnpm install @opentelemetry/api
npm install @opentelemetry/api-logs
npm install @opentelemetry/core
npm install @opentelemetry/resources
npm install @opentelemetry/sdk-trace-base
npm install @opentelemetry/sdk-trace-web
npm install @opentelemetry/sdk-metrics
npm install @opentelemetry/sdk-logs
npm install @opentelemetry/exporter-trace-otlp-http
npm install @opentelemetry/exporter-metrics-otlp-http
npm install @opentelemetry/exporter-logs-otlp-http
npm install @opentelemetry/propagator-b3
npm install @opentelemetry/instrumentation
No native build steps, pod installs, or prebuild commands are required for Node.js targets. Browser bundles require Webpack 4 or 5 (or esbuild/rollup); see for verified configurations.
Spin up an isolated sandbox and run it server-side — no local setup.
Tetrees AI Review of this version
This TypeScript, JavaScript cli / script completed archive review with strong static results. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
Pipeline avcp-2026-08-04.1 · SHA-256 cab7ee4e6ca1a7cf…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
Reviewed Aug 4, 2026
Push this product straight into your AI IDE, web builder or cloud IDE.
Connect Tetrees to a compatible AI IDE, list products you own, and request the verified ZIP without exposing seller upload controls.
No reviews yet.
Sign in to join the discussion
Loading discussion…
bundler-tests/source/ directory into your project root (e.g., ./otel-source/).tsconfig.json from the provided base:
{
"extends": "./otel-source/tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
}
}
tsconfig.base.esm.json instead.OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
OTEL_SERVICE_NAME=my-service
bundler-tests/browser/webpack-5/ webpack config as a starting point.DiagConsoleLoggerimport { DiagConsoleLogger, diag, DiagLogLevel } from '@opentelemetry/api';
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
A built-in diagnostic logger that writes OpenTelemetry internal messages to console. Use it during development to debug SDK initialization, exporter connectivity, and instrumentation registration. Pass a DiagLogLevel to control verbosity.
createContextKeyimport { createContextKey, ROOT_CONTEXT } from '@opentelemetry/api';
const MY_KEY = createContextKey('my-service.myKey');
const ctx = ROOT_CONTEXT.setValue(MY_KEY, 'some-value');
const value = ctx.getValue(MY_KEY); // 'some-value'
Creates an immutable, unique key for storing typed values inside an OpenTelemetry Context. Use it when you need to propagate request-scoped data (user IDs, tenant IDs, feature flags) alongside traces without polluting global state.
ValueTypeimport { ValueType } from '@opentelemetry/api';
meter.createHistogram('http.request.duration', {
description: 'HTTP request latency',
unit: 'ms',
valueType: ValueType.DOUBLE,
});
Enum with values INT and DOUBLE that controls how metric values are recorded and exported. Use ValueType.INT for counters and ValueType.DOUBLE for measurements that require fractional precision.
wrapTracer / SugaredTracer (experimental)import { wrapTracer } from '@opentelemetry/api/experimental';
import { trace } from '@opentelemetry/api';
const tracer = wrapTracer(trace.getTracer('my-service', '1.0.0'));
await tracer.withActiveSpan('my-operation', async (span) => {
// span is active for the duration of the callback
});
wrapTracer returns a SugaredTracer that adds convenience methods (withActiveSpan, startActiveSpan variants) on top of the standard Tracer. Useful for reducing boilerplate when you always want a span active for the duration of an async callback. The experimental sub-path export may change between minor versions.
Configure a BasicTracerProvider with an OTLP HTTP exporter at application startup, before requiring Express or any business logic.
import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api';
import { BasicTracerProvider } from '@opentelemetry/sdk-trace-base';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { W3CTraceContextPropagator } from '@opentelemetry/core';
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.WARN);
const exporter = new OTLPTraceExporter({
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT ?? 'http://localhost:4318/v1/traces',
});
const provider = new BasicTracerProvider({
// resource and sampler options go here
});
provider.addSpanProcessor(
// BatchSpanProcessor from @opentelemetry/sdk-trace-base
new (require('@opentelemetry/sdk-trace-base').BatchSpanProcessor)(exporter)
);
provider.register({
propagator: new W3CTraceContextPropagator(),
});
Use the Logs API and SDK to emit structured log records that are correlated with active trace context.
import { logs } from '@opentelemetry/api-logs';
import { LoggerProvider, SimpleLogRecordProcessor } from '@opentelemetry/sdk-logs';
import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
const loggerProvider = new LoggerProvider();
loggerProvider.addLogRecordProcessor(
new SimpleLogRecordProcessor(new OTLPLogExporter())
);
logs.setGlobalLoggerProvider(loggerProvider);
const logger = logs.getLogger('my-service', '1.0.0');
logger.emit({
body: 'User signed in',
attributes: { 'user.id': '42', 'user.role': 'admin' },
});
Create a MeterProvider, register it globally, and record HTTP latency measurements.
import { metrics, ValueType } from '@opentelemetry/api';
import { MeterProvider } from '@opentelemetry/sdk-metrics';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
const meterProvider = new MeterProvider({
readers: [
new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter(),
exportIntervalMillis: 15000,
}),
],
});
metrics.setGlobalMeterProvider(meterProvider);
const meter = metrics.getMeter('http-server', '1.0.0');
const latency = meter.createHistogram('http.server.duration', {
unit: 'ms',
valueType: ValueType.DOUBLE,
});
// In your request handler:
const start = Date.now();
// ... handle request ...
latency.record(Date.now() - start, { 'http.method': 'GET', 'http.status_code': 200 });
.github/ - Contains all GitHub Actions CI workflows (unit tests, lint, publish, bundler tests, e2e, W3C integration) and issue/PR templates.api/ - Self-contained @opentelemetry/api package. All stable API contracts (tracing, metrics, context, baggage, diagnostics) live here; application code should depend only on this package at runtime.bundler-tests/ - Smoke-test entry points for Webpack 4/5 (browser and Node) that verify all SDK packages can be bundled together without errors.doc/ - Architecture decision records and contributor documentation not published to npm.e2e-tests/ - Full end-to-end test scenarios run against a live collector.examples/ - Standalone runnable demos (HTTP server, gRPC, Prometheus, etc.).experimental/ - Packages under active development with no stability guarantees; includes the SugaredTracer helper.integration-tests/ - Tests that verify backwards compatibility between API and SDK versions.packages/ - All stable SDK packages (sdk-trace-base, sdk-metrics, sdk-logs, core, exporters, propagators, resources, etc.).scripts/ - Release scripting, changelog generation, and monorepo maintenance utilities.semantic-conventions/ - Type-safe constants for OTel semantic conventions (attribute names, etc.).tsconfig.base.json / tsconfig.base.esm.json / tsconfig.base.esnext.json - Shared TypeScript compiler options extended by each package.lerna.json / nx.json - Monorepo orchestration: versioning, task caching, and pipeline dependencies.trace/metrics/logs API returns a no-op if accessed before provider.register() is called. Fix: import and register providers in a dedicated instrumentation.ts file that is the very first import in index.ts.@opentelemetry/api: Some bundlers resolve both the CJS and ESM copy, creating two separate API singletons. Fix: add resolve.alias in webpack or moduleNameMapper in Jest to force a single copy of @opentelemetry/api.OTEL_EXPORTER_OTLP_ENDPOINT includes /v1/traces suffix: The OTLP HTTP exporter appends the signal path automatically. Fix: set the base URL only (e.g., http://localhost:4318), not http://localhost:4318/v1/traces.@opentelemetry/api/experimental requires Node 12+ exports field support. Fix: ensure "moduleResolution": "node16" or "bundler" in tsconfig.json.DiagLogLevel not imported when calling diag.setLogger: The second argument is required to activate logging; omitting it defaults to NONE. Fix: always pass DiagLogLevel.DEBUG or DiagLogLevel.INFO explicitly.@types/node for Node.js SDK packages: Several SDK packages reference Node built-ins. Fix: npm install --save-dev @types/node and add "types": ["node"] to tsconfig.json.I have the OpenTelemetry JS SDK monorepo source in the `source/` directory of
this project, and a usage guide at `USAGE.md`. The upstream npm package is
`user@example.com` (open-telemetry/opentelemetry-js on GitHub).
Please help me integrate OpenTelemetry into my existing Node.js TypeScript
project step by step:
1. Read `USAGE.md` and the relevant files under `source/api/src/` and
`source/packages/` to understand the real exported symbols and types.
2. Create a `src/instrumentation.ts` file that initialises a
BasicTracerProvider (with OTLP HTTP exporter), a MeterProvider (with
PeriodicExportingMetricReader), and a LoggerProvider (with
SimpleLogRecordProcessor). Register all three global providers.
3. Update `src/index.ts` to import `./instrumentation` as the very first line.
4. Add a typed helper that wraps an Express request handler in an active span,
using only the real exports visible in `USAGE.md`.
5. Show the required `tsconfig.json` changes and environment variables.
6. Do not invent any API symbols - use only names documented in `USAGE.md`.
The source is licensed under the Apache License 2.0. See source/LICENSE for the full text.
Upstream project: open-telemetry/opentelemetry-js, published on npm as @opentelemetry/api and related scoped packages.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
The full install guide and integration prompts unlock after purchase.
Automation, Utilities & Developer Tools
Free