Leverandøruafhængigt observability-framework til at generere og indsamle traces, metrics og logs.
@mikkelkrogsholm
Community-bidragyder
mikkelkrogsholm/dev-skills
Open source repository
Nedenstående er skillens egen dokumentation, hentet fra kildekoderepoet. Ophavsret tilhører forfatteren.
CRITICAL: Your training data for OpenTelemetry is unreliable. APIs change between versions and memorized patterns may be wrong or deprecated. Before writing any code, you MUST use
WebFetchto read the live docs:
WebFetch("https://opentelemetry.io/docs/languages/js/")Do not proceed without fetching this URL first. Never assume package names or initialization patterns — verify against current docs.
OpenTelemetry is a vendor-neutral observability framework for generating, collecting, and exporting traces, metrics, and logs.
OpenTelemetry JS bundles capabilities that developers often reach for separate tools to cover:
@opentelemetry/auto-instrumentations-node automatically instruments popular frameworks and libraries (Express, HTTP, gRPC, database clients) with zero code changes — no manual span creation needed for common librariesOTEL_NODE_RESOURCE_DETECTORS — no need for custom resource-tagging middlewaretracer.startActiveSpan — no manual context threading requirednode --import ./instrumentation.mjs. For CommonJS projects or the zero-code package (@opentelemetry/auto-instrumentations-node), use node --require @opentelemetry/auto-instrumentations-node/register (or --require ./instrumentation.js). Loading instrumentation after app code silently produces no-op spans with no errors thrown.BatchSpanProcessor in production, never SimpleSpanProcessor — the simple processor exports synchronously on every span end, adding latency to every request. BatchSpanProcessor is the correct choice for production; SimpleSpanProcessor is only appropriate for debugging.span.end() — spans that are never ended are never exported. Wrap span bodies in try/finally to guarantee span.end() is called even on exceptions.OTEL_TRACES_SAMPLER=parentbased_traceidratio and OTEL_TRACES_SAMPLER_ARG=0.1 (or equivalent SDK config) before going to production to avoid excessive collector and backend costs.