Resource Detection

The "Which Service Is This?" Problem

After deploying OpenTelemetry across 12 microservices running in Kubernetes, I opened Jaeger and saw:

Service: unknown_service:node
Service: unknown_service:node
Service: unknown_service:node
... (12 identical entries)

Every service had the same name. I couldn't tell which spans belonged to which service. Traces were useless.

The problem? I forgot to configure resourcesβ€”the metadata that identifies your service.

What Are Resources?

Resources are attributes that describe your service:

  • Service name: order-service

  • Service version: 1.2.3

  • Deployment environment: production

  • Cloud provider: AWS

  • Region: us-east-1

  • Container ID: abc123

  • Kubernetes pod: order-service-7d9f8-xkj2p

These attributes are attached to every span and metric from your service.

Basic Resource Configuration

Now in Jaeger:

Automatic Resource Detection

OpenTelemetry can automatically detect resources from your environment:

Environment Variable Detection

Set environment variables and OTel picks them up automatically:

Resulting resource attributes:

Cloud Provider Detection

AWS EC2

Automatically detects:

AWS EKS (Kubernetes on AWS)

Detects:

Google Cloud

Kubernetes Detection

For Kubernetes deployments, inject metadata via downward API:

deployment.yaml:

In your application:

Result:

Custom Resource Detectors

Create your own detector for application-specific metadata:

Resource Attributes in Practice

Filtering by Environment

In Jaeger, filter traces by environment:

Alerting by Team

In Prometheus alerts:

Deployment Tracking

Correlate deployments with metrics:

When error rate spikes after deploying v1.2.3 β†’ rollback to v1.2.2!

Production Resource Configuration

Here's my production setup:

Dockerfile:

CI/CD (GitHub Actions):

Kubernetes Deployment:

Application Code:

Final Resource Attributes:

Debugging Resource Detection

Enable debug logging:

Output:

Best Practices

  1. Always set service.name - it's the most important attribute

  2. Include service.version - for deployment tracking

  3. Add team information - for alerting and ownership

  4. Use semantic conventions - follow OpenTelemetry standards

  5. Automate resource detection - use detectors, don't hardcode

  6. Test in staging - verify attributes are correct

  7. Keep cardinality low - avoid unique IDs in resource attributes

Common Mistakes

❌ Using high-cardinality values:

βœ… Use low-cardinality values:

❌ Forgetting to set resources:

βœ… Always configure resources:

What's Next

Continue to Custom Exporters to learn:

  • Sending telemetry to multiple backends

  • Custom exporter implementation

  • Cloud provider integrations

  • Export batching and retry logic


Previous: ← Sampling Strategies | Next: Custom Exporters β†’

Resources are your service's identity card.

Last updated