From 13182438410f7b816ea2fb5260a5e7ca0924c7f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoni=20Nu=C3=B1ez=20Romeu?= Date: Mon, 13 Jul 2026 16:35:45 +0200 Subject: [PATCH] fix(backend): use string resource attribute keys instead of semantic-conventions named exports The resolved @opentelemetry/semantic-conventions version in CI does not export ATTR_SERVICE_NAMESPACE/ATTR_SERVICE_NAME as named exports, breaking the backend test import. Use plain 'service.name'/'service.namespace' string keys so the code is independent of the semantic-conventions version. --- apps/backend/src/tracing.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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