Skip to content

Commit

Permalink
fix: use OTEL env vars for service name and namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mcstover committed Jan 10, 2024
1 parent 2af71b9 commit 21a27d2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
2 changes: 1 addition & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 3 additions & 2 deletions server/util/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
});
Expand Down

0 comments on commit 21a27d2

Please sign in to comment.