diff --git a/docs/usage/opentelemetry.md b/docs/usage/opentelemetry.md index 0ff295ba39f4fe..bfec6276211516 100644 --- a/docs/usage/opentelemetry.md +++ b/docs/usage/opentelemetry.md @@ -30,6 +30,11 @@ This means that Renovate sends traces via [OTLP/HTTP](https://opentelemetry.io/d To activate the instrumentation, you must set the `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable. This variable controls the endpoint for the telemetry data. Once this endpoint is set, you can use all environment variables listed in the [OpenTelemetry specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md). +You can also set the following environment variables: + +- `OTEL_SERVICE_NAME`: to control the service name that will be emitted in traces, defaults to `renovate` +- `OTEL_SERVICE_NAMESPACE`: to control the service namespace that will be emitted in traces, defaults to `renovatebot.com` +- `OTEL_SERVICE_VERSION`: to control the service version that will be emitted in traces, defaults to using the release version of Renovate ## Debugging diff --git a/lib/instrumentation/index.ts b/lib/instrumentation/index.ts index 4ae908847b84a7..c1a93491089551 100644 --- a/lib/instrumentation/index.ts +++ b/lib/instrumentation/index.ts @@ -43,9 +43,12 @@ export function init(): void { const traceProvider = new NodeTracerProvider({ resource: new Resource({ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#semantic-attributes-with-sdk-provided-default-value - [SemanticResourceAttributes.SERVICE_NAME]: 'renovate', - [SemanticResourceAttributes.SERVICE_NAMESPACE]: 'renovatebot.com', - [SemanticResourceAttributes.SERVICE_VERSION]: pkg.version, + [SemanticResourceAttributes.SERVICE_NAME]: + process.env.OTEL_SERVICE_NAME ?? 'renovate', + [SemanticResourceAttributes.SERVICE_NAMESPACE]: + process.env.OTEL_SERVICE_NAMESPACE ?? 'renovatebot.com', + [SemanticResourceAttributes.SERVICE_VERSION]: + process.env.OTEL_SERVICE_VERSION ?? pkg.version, }), });