diff --git a/apps/backend/src/tracing.js b/apps/backend/src/tracing.js index c88059e..4c01bdd 100644 --- a/apps/backend/src/tracing.js +++ b/apps/backend/src/tracing.js @@ -14,20 +14,21 @@ import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentation import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc'; import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc'; import * as resources from '@opentelemetry/resources'; -import { ATTR_SERVICE_NAME, ATTR_SERVICE_NAMESPACE } from '@opentelemetry/semantic-conventions'; import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino'; const serviceName = process.env.OTEL_SERVICE_NAME || 'farmaclic-backend'; const otlpEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4317'; +// Use plain string attribute keys (not the semantic-conventions named exports) +// so we don't depend on a specific @opentelemetry/semantic-conventions version. const resource = typeof resources.resourceFromAttributes === 'function' ? resources.resourceFromAttributes({ - [ATTR_SERVICE_NAME]: serviceName, - [ATTR_SERVICE_NAMESPACE]: 'farmaclic', + 'service.name': serviceName, + 'service.namespace': 'farmaclic', }) : new resources.Resource({ - [ATTR_SERVICE_NAME]: serviceName, - [ATTR_SERVICE_NAMESPACE]: 'farmaclic', + 'service.name': serviceName, + 'service.namespace': 'farmaclic', }); // Metrics → OTLP → Alloy → Prometheus remote_write. The PeriodicExportingMetricReader