OpenTelemetry Resource: The 'Who' of Your Telemetry
An OpenTelemetry Resource is the return address for your telemetry, describing the service instance that produced it. It attaches stable context like service name and version to every signal, enabling filtering.
WHY IT EXISTS To solve the problem of disconnected telemetry. Without a common identifier, a trace, a metric, and a log from the same service instance appear as unrelated events. This makes it impossible to get a holistic view of an application's behavior or to filter signals from a specific deployment.
THE MENTAL MODEL Think of a Resource as the return address on an envelope. Every piece of mail (a trace, metric, or log) sent from a specific house (a service instance) has the same return address. This tells the recipient exactly which service, version, and host sent the data, distinguishing it from mail sent by other houses in the neighborhood.
HOW IT WORKS You define the Resource once during application initialization, typically by setting key-value attributes. The OpenTelemetry SDK then automatically attaches these attributes to all telemetry data emitted by that instance. These attributes are immutable for the lifetime of the process. Using standard attribute names from OpenTelemetry's Semantic Conventions, like service.name and cloud.region, ensures consistency across different tools and platforms.
WHEN TO USE IT Always. A Resource is a fundamental, required component for any instrumented application. It's the foundation for making sense of telemetry data in a distributed system. You configure it at startup to identify the source of all subsequent signals, enabling powerful filtering and aggregation in your observability backend.
WHEN NOT TO USE IT The concept of a Resource is always applicable, but its attributes have a specific purpose. You must not use Resource attributes to store dynamic, high-cardinality data that changes with each request, such as a user ID or request path. That information belongs on individual spans or log records, not on the entity that describes the process itself.
ONE CANONICAL EXAMPLE A payment service is deployed as a container in Kubernetes. Its Resource attributes might be: service.name: payment-service, service.version: 2.5.1, deployment.environment: production, k8s.pod.name: payment-service-789c-x2h4f, and cloud.region: us-east-1. All traces, metrics, and logs from this specific pod will share these exact attributes, making them easy to find and correlate.
Read the original → opentelemetry.io
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.