Relocate the ~6k-file docs tree from the repo root into plugins/document-navigator/docs/ so the plugin is self-contained and portable. docs/superpowers/ (specs and plans) stays at the repo root. Moved via cp+rm rather than git mv because directory rename() fails with EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the identical-content files at commit time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
10 KiB
10 KiB
@suaveplan/opentelemetry - OpenTelemetry SDK setup and configuration helpers: tracer/meter/logger providers, resource detection, exporter configuration, and sampling strategies
Summary
OpenTelemetry SDK setup and configuration helpers for Suaveplan. Provides batteries-included OTel initialization helpers, resource detection, ergonomic span/metrics wrappers, W3C trace-context propagation utilities, and a no-op SDK façade that works without any heavyweight @opentelemetry/sdk-* packages.
Documentation tree
- propagation — (no submodules)
- propagation — (no submodules)
- noop-sdk — Provides
NoopSdk, a zero-dependency implementation of theOtelSdkinterface that delegates all tracer and meter loo… - sdk-factory — Provides the
createSdkfactory function — the primary entry point for constructing anOtelSdkinstance from a valid… - errors — (no submodules)
- opentelemetry-error — (no submodules)
- schemas — (no submodules)
- otel-config.schema — (no submodules)
- metrics-utils — Provides thin factory and recording helpers that wrap the
@opentelemetry/apimetrics API with sensible defaults and e… - resource — Builds a frozen OpenTelemetry resource attribute map from service identity configuration fields. Resource attributes ar…
- span-utils — Provides ergonomic helper functions for working with OpenTelemetry spans. Rather than writing the same try/catch/finall…
- sdk-factory — Provides the
createSdkfactory function — the primary entry point for constructing anOtelSdkinstance from a valid… - errors — (no submodules)- opentelemetry-error — (no submodules)- schemas — (no submodules)- otel-config.schema — (no submodules)- metrics-utils — Provides thin factory and recording helpers that wrap the
@opentelemetry/apimetrics API with sensible defaults and e… - resource — Builds a frozen OpenTelemetry resource attribute map from service identity configuration fields. Resource attributes ar…
- span-utils — Provides ergonomic helper functions for working with OpenTelemetry spans. Rather than writing the same try/catch/finall…
- propagation — (no submodules)- noop-sdk — Provides
NoopSdk, a zero-dependency implementation of theOtelSdkinterface that delegates all tracer and meter loo… - sdk-factory — Provides the
createSdkfactory function — the primary entry point for constructing anOtelSdkinstance from a valid… - errors — (no submodules)- opentelemetry-error — (no submodules)- schemas — (no submodules)- otel-config.schema — (no submodules)- metrics-utils — Provides thin factory and recording helpers that wrap the
@opentelemetry/apimetrics API with sensible defaults and e… - resource — Builds a frozen OpenTelemetry resource attribute map from service identity configuration fields. Resource attributes ar…
- span-utils — Provides ergonomic helper functions for working with OpenTelemetry spans. Rather than writing the same try/catch/finall…
- propagation — (no submodules)- noop-sdk — Provides
NoopSdk, a zero-dependency implementation of theOtelSdkinterface that delegates all tracer and meter loo… - sdk-factory — Provides the
createSdkfactory function — the primary entry point for constructing anOtelSdkinstance from a valid… - errors — (no submodules)- opentelemetry-error — (no submodules)- schemas — (no submodules)- otel-config.schema — (no submodules)- metrics-utils — Provides thin factory and recording helpers that wrap the
@opentelemetry/apimetrics API with sensible defaults and e… - resource — Builds a frozen OpenTelemetry resource attribute map from service identity configuration fields. Resource attributes ar…
- span-utils — Provides ergonomic helper functions for working with OpenTelemetry spans. Rather than writing the same try/catch/finall…
- propagation — (no submodules)- noop-sdk — Provides
NoopSdk, a zero-dependency implementation of theOtelSdkinterface that delegates all tracer and meter loo… - sdk-factory — Provides the
createSdkfactory function — the primary entry point for constructing anOtelSdkinstance from a valid… - errors — (no submodules) - opentelemetry-error — (no submodules)- schemas — (no submodules) - otel-config.schema — (no submodules)- metrics-utils — Provides thin factory and recording helpers that wrap the
@opentelemetry/apimetrics API with sensible defaults and e… - resource — Builds a frozen OpenTelemetry resource attribute map from service identity configuration fields. Resource attributes ar…
- span-utils — Provides ergonomic helper functions for working with OpenTelemetry spans. Rather than writing the same try/catch/finall…
Packages
| Module | Path | Description |
|---|---|---|
errors |
src/errors/opentelemetry-error.md | Error class and code registry |
sdk |
src/core/sdk/noop-sdk.md | OtelSdk interface and NoopSdk implementation |
sdk-factory |
src/core/sdk/sdk-factory.md | createSdk — validated config → SDK instance |
span-utils |
src/utils/span-utils.md | withSpan, recordException, addAttributes, getTraceContext |
metrics-utils |
src/utils/metrics-utils.md | createCounter, createHistogram, createGauge, recordDuration |
resource |
src/utils/resource.md | createResource — OTel resource attribute builder |
propagation |
src/core/propagation/propagation.md | W3C traceparent inject/extract/parse/build |
Quick Start
import { createSdk } from "@suaveplan/opentelemetry/sdk";
import { withSpan } from "@suaveplan/opentelemetry/span-utils";
import { createCounter, recordDuration } from "@suaveplan/opentelemetry/metrics-utils";
const sdk = createSdk({
serviceName: "my-service",
serviceVersion: "1.0.0",
environment: "production",
});
await sdk.start();
const tracer = sdk.getTracer("my-service");
const meter = sdk.getMeter("my-service");
const requestCounter = createCounter(meter, "http.request.total", "Total HTTP requests");
const latency = createHistogram(meter, "http.request.duration", "Request latency", "ms");
async function handleRequest(req: Request) {
return withSpan(tracer, "http.handle", async (span) => {
span.setAttribute("http.method", req.method);
const start = Date.now();
const response = await processRequest(req);
requestCounter.add(1, { "http.status": response.status });
recordDuration(latency, start, { "http.route": "/api" });
return response;
});
}
// Graceful shutdown
process.on("SIGTERM", () => sdk.shutdown());
Subpath Exports
import { ... } from "@suaveplan/opentelemetry"; // all exports
import { createSdk, NoopSdk } from "@suaveplan/opentelemetry/sdk";
import { withSpan, recordException } from "@suaveplan/opentelemetry/span-utils";
import { createCounter, createHistogram } from "@suaveplan/opentelemetry/metrics-utils";
import { injectTraceContext, parseTraceParent } from "@suaveplan/opentelemetry/propagation";
import { OpenTelemetryError, OTEL_CODES } from "@suaveplan/opentelemetry/errors";