|
| 1 | +--- |
| 2 | +title: Resources |
| 3 | +weight: 70 |
| 4 | +--- |
| 5 | + |
| 6 | +## Introduction |
| 7 | + |
| 8 | +{{% docs/instrumentation/resources-intro %}} |
| 9 | + |
| 10 | +If you use [Jaeger](https://www.jaegertracing.io/) as your observability |
| 11 | +backend, resource attributes are grouped under the **Process** tab: |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +A resource is added to the `TraceProvider` or `MetricProvider` when they are |
| 16 | +created during initialization. This association can not be changed later. After |
| 17 | +a resource is added, all spans and metrics produced from a `Tracer` or `Meter` |
| 18 | +from the provider will have the resource associated with them. |
| 19 | + |
| 20 | +## Semantic Attributes with SDK-provided Default Value |
| 21 | + |
| 22 | +There are attributes provided by the OpenTelemetry SDK. One of them is the |
| 23 | +`service.name`, which represents the logical name of the service. By default, |
| 24 | +SDKs will assign the value `unknown_service` for this value, so it is |
| 25 | +recommended to set it explicitly, either in code or via setting the environment |
| 26 | +variable `OTEL_SERVICE_NAME`. |
| 27 | + |
| 28 | +Additionally, the SDK will also provides the following resource attributes to |
| 29 | +identify itself: `telemetry.sdk.name`, `telemetry.sdk.language` and |
| 30 | +`telemetry.sdk.version`. |
| 31 | + |
| 32 | +## Resource Detectors |
| 33 | + |
| 34 | +Most language-specific SDKs provide a set of resource detectors that can be used |
| 35 | +to automatically detect resource information from the environment. Common |
| 36 | +resource detectors include: |
| 37 | + |
| 38 | +- [Operating System](/docs/specs/semconv/resource/os/) |
| 39 | +- [Host](/docs/specs/semconv/resource/host/) |
| 40 | +- [Process and Process Runtime](/docs/specs/semconv/resource/process/) |
| 41 | +- [Container](/docs/specs/semconv/resource/container/) |
| 42 | +- [Kubernetes](/docs/specs/semconv/resource/k8s/) |
| 43 | +- [Cloud-Provider-Specific Attributes](/docs/specs/semconv/resource/#cloud-provider-specific-attributes) |
| 44 | +- [and more](/docs/specs/semconv/resource/) |
| 45 | + |
| 46 | +## Custom resources |
| 47 | + |
| 48 | +You can also provide your own resource attributes. You can either provide them |
| 49 | +in code or via populating the environment variable `OTEL_RESOURCE_ATTRIBUTES`. |
| 50 | +If applicable, use the |
| 51 | +[semantic conventions for your resource attributes](/docs/specs/semconv/resource). |
| 52 | +For example, you can provide the name of your |
| 53 | +[deployment environment](/docs/specs/semconv/resource/deployment-environment/) |
| 54 | +using `deployment.environment`: |
| 55 | + |
| 56 | +```shell |
| 57 | +env OTEL_RESOURCE_ATTRIBUTES=deployment.environment=production yourApp |
| 58 | +``` |
0 commit comments