Skip to content

Commit

Permalink
feat(instrumentation): add option to overwrite otlp service name/name…
Browse files Browse the repository at this point in the history
…space/version with env var (#29583)

Signed-off-by: Aviv Guiser <avivguiser@gmail.com>
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
  • Loading branch information
KyriosGN0 and secustor committed Jun 12, 2024
1 parent ff23f82 commit 4914b6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/usage/opentelemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 6 additions & 3 deletions lib/instrumentation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
});

Expand Down

0 comments on commit 4914b6c

Please sign in to comment.