Skip to content

OpenTelemetry

Scope: instrumenting services for traces, metrics and logs with OpenTelemetry, and running the OpenTelemetry Collector between services and observability backends. The general rules are in general/operations-reliability.md: instrument with OpenTelemetry and follow its semantic conventions (OPS-11), and monitor the four golden signals (OPS-2). Keeping secrets and personal data out of logs is SEC-4 in general/security.md. For language-specific setup, see .NET (DOTNET-8) and the language pages of the OpenTelemetry documentation; for exporting telemetry from serverless platforms, see Serverless and edge hosting (HOST-13).

Entries are sorted by score from 1 to 10 (criteria): 9–10 start here or strongly recommended, 6–8 recommended, 1–5 further reading or conditional.

Adopted references

  • 9 OpenTelemetry documentation: the baseline: concepts, signals, context propagation, instrumentation per language, zero-code instrumentation, sampling and the Collector.
  • 8 Collector (OpenTelemetry docs): when to use a Collector, its configuration, the agent and gateway deployment patterns, scaling and internal telemetry.
  • 8 Trace Context (W3C Recommendation): the traceparent and tracestate HTTP headers that OpenTelemetry propagates by default.
  • 8 Handling sensitive data (OpenTelemetry docs): data minimization, and removing, hashing or truncating sensitive attributes with Collector processors.
  • 7 Collector configuration best practices and Collector hosting best practices (OpenTelemetry docs): securing the Collector's configuration, network exposure, permissions and resource use.
  • 7 OpenTelemetry semantic conventions: standard names for attributes, spans, metrics, events and resources, per area such as HTTP, databases and messaging.

Key rules

Resources and naming

  • 8 OTEL-1 Set service.name explicitly in every service, with the same value for all instances of the service, and add service.version and deployment.environment.name as resource attributes. Otherwise the SDK reports unknown_service. Set them with OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES, and let the SDK's resource detectors add host, container, Kubernetes and cloud attributes. (OpenTelemetry, Resources, Service semantic conventions)
  • 6 OTEL-2 Before you name a custom attribute or metric, look for it in the semantic conventions; when none fits, prefix the new name with your company's reverse domain name, such as com.acme., or with your application's name. Don't reuse an existing semantic convention namespace as the prefix: OpenTelemetry or other instrumentation may later use the same name for something else. (Semantic conventions, Naming: recommendations for application developers)

Instrumentation and context

Sampling

  • 6 OTEL-8 Choose sampling deliberately: don't sample when you produce little data, use consistent probability (head) sampling to cut volume cheaply, and add tail sampling in a Collector tier when you must keep every error or slow trace. All spans of a trace must reach the same tail-sampling Collector, so route them by trace ID with the load-balancing exporter. (OpenTelemetry, Sampling, Gateway deployment pattern, Tail sampling processor)

Collector

Sensitive data

  • 8 OTEL-12 Keep secrets and personal data out of telemetry: don't record what you don't need, and remove, hash or truncate what instrumentation captures anyway, for example with the Collector's redaction, attributes, transform or filter processors. You are responsible for what instrumentation libraries capture, too, and a hash of a small value space, such as numeric user IDs, can be reversed. (OpenTelemetry, Handling sensitive data, Collector configuration best practices: scrub sensitive data)

How to enforce

Tools that check the key rules above automatically, in CI, the IDE or a commit hook. "Partly" means the tool covers only some of what the rule asks.

  • 6 Weaver live check: an OpenTelemetry tool that receives the telemetry your tests emit over OTLP, compares it with the semantic conventions or your own registry, and exits with an error when it finds a violation, such as an attribute missing from the registry. Rego policies add your own checks. Partly checks OTEL-2 and OPS-11.
  • 5 Collector validate command: otelcol validate --config=… checks a Collector configuration without starting it, so that CI can reject an invalid one. It rejects a memory_limiter without a memory limit or check interval, but doesn't require one. Partly checks OTEL-9.

Tutorials and further reading

  • 7 Getting started (OpenTelemetry docs): where to start as a developer or as an operator.
  • 7 OpenTelemetry Demo (OpenTelemetry docs): a multi-language microservice application, instrumented with OpenTelemetry, to run with Docker or Kubernetes and explore.
  • 6 Training (OpenTelemetry): the free Linux Foundation course Getting Started with OpenTelemetry and the OpenTelemetry Certified Associate certification.