diff --git a/server/dev-server.js b/server/dev-server.js index f73d729e72..2b1e5b051a 100644 --- a/server/dev-server.js +++ b/server/dev-server.js @@ -3,7 +3,7 @@ require('../build/check-versions')(); const { setupTracing } = require('./util/tracer'); -setupTracing('ui'); +setupTracing(); // dependencies require('dotenv').config({ path: '/etc/kiva-ui-server/config.env' }); diff --git a/server/index.js b/server/index.js index 0362debf9d..656c658303 100644 --- a/server/index.js +++ b/server/index.js @@ -3,7 +3,7 @@ require('dotenv').config({ path: '/etc/kiva-ui-server/config.env' }); // eslint-disable-next-line import/order const { setupTracing } = require('./util/tracer'); -setupTracing('ui'); +setupTracing(); const cluster = require('cluster'); const http = require('http'); diff --git a/server/util/tracer.js b/server/util/tracer.js index 441e8a4e6c..a2eba7e527 100644 --- a/server/util/tracer.js +++ b/server/util/tracer.js @@ -44,12 +44,13 @@ function ignoreTheseSpans(spanName, spanKind, attributes) { return spanKind !== opentelemetry.SpanKind.SERVER; } -function setupTracing(serviceName) { +function setupTracing() { + const serviceName = process.env?.OTEL_SERVICE_NAME || 'ui'; if (!otlpDisabled) { const provider = new NodeTracerProvider({ resource: new Resource({ [SemanticResourceAttributes.SERVICE_NAME]: serviceName, - [SemanticResourceAttributes.SERVICE_NAMESPACE]: 'kiva', + [SemanticResourceAttributes.SERVICE_NAMESPACE]: process.env?.OTEL_SERVICE_NAMESPACE || 'kiva', }), sampler: filterSampler(ignoreTheseSpans, new AlwaysOnSampler()), });