otel-instrumentation
Use when an "enable observability" card asks for metrics, traces or logs - what the developer task must add per language (Go, Node/TS, Python, Java/Kotlin, .NET, Ruby, PHP), the zero-code agents, the OTEL_* environment variables and resource attributes, and how to reach GCP, AWS, Vercel or a plain OTLP endpoint
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-15
- Stars
- ★ 122
- Forks
- 18
01 前言 Front Matter
- name
- otel-instrumentation
- source
- open-telemetry/opentelemetry.io docs (CC BY 4.0), adapted
- category
- observability
- description
- Use when an "enable observability" card asks for metrics, traces or logs - what the developer task must add per language (Go, Node/TS, Python, Java/Kotlin, .NET, Ruby, PHP), the zero-code agents, the OTEL_* environment variables and resource attributes, and how to reach GCP, AWS, Vercel or a plain OTLP endpoint
03 SKILL.md 正文
OpenTelemetry instrumentation
You never write this code yourself. This skill is what you put into the developer's task: exact packages, where the SDK starts, the environment it reads, and acceptance criteria that can be observed in the target environment.
Always the same
Every service gets the same identity, set through the environment rather than in code:
| Variable | Value |
|---|---|
OTEL_SERVICE_NAME |
the component's name, stable across deploys (checkout-api) |
OTEL_RESOURCE_ATTRIBUTES |
`service.version=<release tag or commit>,deployment.environment.name=<production |
OTEL_EXPORTER_OTLP_ENDPOINT |
the collector or backend base URL (http://otel-collector:4318) |
OTEL_EXPORTER_OTLP_PROTOCOL |
http/protobuf (default for most SDKs) or grpc (port 4317) |
OTEL_EXPORTER_OTLP_HEADERS |
auth for a hosted endpoint (authorization=Bearer …) — a secret, declared with declare_env_vars, never committed |
OTEL_TRACES_SAMPLER / _ARG |
parentbased_traceidratio / 0.1 for a busy production service; parentbased_always_on otherwise |
OTEL_METRICS_EXPORTER, OTEL_LOGS_EXPORTER |
otlp (or none when the platform already ships stdout logs) |
service.version is what lets a deploy-impact read tell the release apart; leaving it out makes every release look the same.
Per language
- Go — no general zero-code agent (the eBPF
opentelemetry-go-instrumentationis not production-grade for most stacks). Addgo.opentelemetry.io/otel,go.opentelemetry.io/otel/sdk,.../exporters/otlp/otlptrace/otlptracehttpand.../otlpmetric/otlpmetrichttp; build the tracer and meter providers inmainfromresource.Default()merged with the env, register them globally, andShutdownthem on exit. Wrap the router withgo.opentelemetry.io/contrib/instrumentation/net/http/otelhttp(orotelgin,otelecho,otelgrpc), outbound clients withotelhttp.NewTransport, the database withgithub.com/XSAM/otelsql. Logs: thego.opentelemetry.io/contrib/bridges/otelsloghandler, or keepslogJSON on stdout withtrace_id/span_idfields. - Node.js / TypeScript — zero-code:
@opentelemetry/api+@opentelemetry/auto-instrumentations-node, started withNODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register". With code:@opentelemetry/sdk-nodeandgetNodeAutoInstrumentations()in aninstrumentation.tsloaded before anything else (--import ./instrumentation.mjsfor ESM). Next.js:@vercel/otelwithregisterOTel({ serviceName })ininstrumentation.ts. - Python — zero-code:
opentelemetry-distroandopentelemetry-exporter-otlp, thenopentelemetry-bootstrap -a installin the image build, and run underopentelemetry-instrument(opentelemetry-instrument gunicorn app:app; with gunicorn's--preloador forking servers, initialise inpost_fork). Logs:OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true. - Java / Kotlin — zero-code: the
opentelemetry-javaagent.jarfrom the opentelemetry-java-instrumentation releases, attached withJAVA_TOOL_OPTIONS=-javaagent:/otel/opentelemetry-javaagent.jar. Spring Boot without an agent (native images):io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter. Micrometer metrics:micrometer-registry-otlp. - .NET — zero-code: OpenTelemetry .NET Automatic Instrumentation (its install script sets the
CORECLR_*profiler variables). With code:OpenTelemetry.Extensions.Hosting,OpenTelemetry.Instrumentation.AspNetCore,OpenTelemetry.Instrumentation.Http,OpenTelemetry.Exporter.OpenTelemetryProtocol, thenbuilder.Services.AddOpenTelemetry().WithTracing(t => t.AddAspNetCoreInstrumentation().AddHttpClientInstrumentation()).WithMetrics(m => m.AddAspNetCoreInstrumentation()).UseOtlpExporter();andbuilder.Logging.AddOpenTelemetry(). - Ruby —
opentelemetry-sdk,opentelemetry-exporter-otlp,opentelemetry-instrumentation-all; in an initializerOpenTelemetry::SDK.configure { |c| c.use_all }. - PHP — the
opentelemetryPECL extension plusopen-telemetry/sdkandopen-telemetry/exporter-otlp, withOTEL_PHP_AUTOLOAD_ENABLED=true; framework packages such asopen-telemetry/opentelemetry-auto-laravelor-auto-symfonydo the instrumentation.
Prefer the zero-code route wherever it exists: it is one image or start-command change the developer can verify, instead of edits through the codebase.
Where it goes
- Google Cloud (
own_cloud, gcp). Traces go by OTLP to the Cloud Telemetry API,https://telemetry.googleapis.com(enabletelemetry.googleapis.comon the project); it needs Google credentials, so the service exports to an OpenTelemetry Collector (a Cloud Run sidecar, or a GKE deployment) whoseotlphttpexporter uses thegoogleclientauthextension. Metrics go through that collector'sgooglemanagedprometheusexporter (Managed Service for Prometheus), read back by agcp_monitoringdata source. Logs: JSON on stdout — Cloud Run and GKE ship it to Cloud Logging; put the trace id inlogging.googleapis.com/trace. The runtime service account needsroles/cloudtrace.agent(or the Telemetry API's traces writer role),roles/monitoring.metricWriterandroles/logging.logWriter— granting them is abefore_deploystep for a person. - AWS (
own_cloud, aws). Run the AWS Distro for OpenTelemetry (ADOT) collector: an ECS sidecar, the EKS add-on, or the ADOT Lambda layer (AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-instrument). Itsawsxrayexporter sends traces to X-Ray,awsemfsends metrics to CloudWatch (read back by anaws_cloudwatchdata source),awscloudwatchlogssends logs. The task role needsAWSXRayDaemonWriteAccessandCloudWatchAgentServerPolicy. - Vercel.
@vercel/otel, exporting to the OTLP endpoint of the team's backend (OTEL_EXPORTER_OTLP_ENDPOINTin the project's environment variables) or through a Vercel observability integration. otlp_endpoint. SetOTEL_EXPORTER_OTLP_ENDPOINTto it; its credentials go inOTEL_EXPORTER_OTLP_HEADERS.self_hosted. Seeself-hosted-stack; the service exports to that stack's collector.
Acceptance criteria that can be checked
- "Given the service is deployed to production, when it serves a request, then a span with
service.name=checkout-apianddeployment.environment.name=productionreaches <target> within a minute." - "Given the service runs, then
http.server.request.durationis exported withhttp.routeandhttp.response.status_code" (the route label is what makes per-endpoint golden signals possible). - "Given a request fails, then its log line carries the
trace_idof that request's span."
Never "the SDK is installed" or "it compiles" — those pass without one span arriving.
After it ships
list_data_source_metrics shows whether the new metric names (http_server_request_duration_seconds_* in Prometheus naming) are there, and propose_signal_binding binds the golden signals to them. No data source reads the target yet: say so on the card — a person adds it under Operations → Data sources.
04 同仓库更多 Skills
visual-craft
暂无简介
ux-copy
Use when you write any words a user reads in a mockup or a hand-off - content language and voice, buttons, labels, errors, empty states, confirmations, numbers and dates, and the longest-string check
screen-mockup-html
Use when you draw screens as the design task's HTML mockup - ONE canvas document holding every screen and every variant side by side, the sanitizer-safe recipe, phone and wide frames, the states grid, static control states, and the loopback self-check with screenshots at 375, 768 and 1440 attached to the task
performance-awareness
How the performance score moves for your role. Use when the score context shows a declining trend, or before handing off work you have not self-checked against every criterion.
design-variants
Use when a screen design needs variants - how many, variants as side-by-side rows on the one canvas, what makes two variants genuinely different, recommending one, how the human's choice is read, and narrowing to the chosen one in revision
design-system-authoring
Use when you derive, change or extend a design system - where tokens live per stack, the DTCG token tree, role-based names for both themes, base vs layer vs drift, the DESIGN.md section order, the inventory format, the contrast check and the lint every proposal returns