# Resources and Semantic Conventions — OpenTelemetry

Source: https://www.skillbyai.com/en/opentelemetry/i-resource

> Consistent metadata everywhere.

## Describe the source once

A **resource** is a set of attributes describing the entity producing telemetry: `service.name`, `service.version`, `deployment.environment.name`, host, container, cloud and Kubernetes attributes. Set them through `OTEL_RESOURCE_ATTRIBUTES` or resource detectors, and every span, metric and log carries them. **Semantic conventions** define standard names for common attributes (HTTP, databases, messaging, RPC, exceptions) so backends and teams interpret data the same way.

## Setting resource attributes

Environment variables read by OpenTelemetry SDKs.

```bash
export OTEL_SERVICE_NAME=checkout
export OTEL_RESOURCE_ATTRIBUTES="service.version=3.4.0,deployment.environment.name=prod,service.namespace=shop"

# HTTP server span attributes defined by the semantic conventions include, for example:
#   http.request.method, url.path, http.route, http.response.status_code, server.address
```

## Always set service.version

Comparing error rates between versions is one of the fastest ways to spot a bad deployment.

**Quiz:** Which attribute belongs on the resource rather than individual spans?

- [ ] app.cart.items
- [ ] http.response.status_code
- [x] service.name
- [ ] exception.message

*Answer:* service.name. Resources describe the source.
