From 5782cc2f9435aa954750d96be5ff9b044594722f Mon Sep 17 00:00:00 2001 From: maryliag Date: Fri, 19 Apr 2024 13:54:41 -0400 Subject: [PATCH] chore(examples/express): use exported strings for attributes Use exported strings for Semantic Resource Attributes Signed-off-by: maryliag --- examples/express/package.json | 2 +- examples/express/src/tracer.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/express/package.json b/examples/express/package.json index f3bac84d8e..61442eeac2 100644 --- a/examples/express/package.json +++ b/examples/express/package.json @@ -40,7 +40,7 @@ "@opentelemetry/resources": "^1.18.1", "@opentelemetry/sdk-trace-base": "^1.18.1", "@opentelemetry/sdk-trace-node": "^1.18.1", - "@opentelemetry/semantic-conventions": "^1.18.1", + "@opentelemetry/semantic-conventions": "^1.23.0", "axios": "^1.6.0", "cross-env": "^7.0.3", "express": "^4.17.1" diff --git a/examples/express/src/tracer.ts b/examples/express/src/tracer.ts index 93a1515f69..4ad569644f 100644 --- a/examples/express/src/tracer.ts +++ b/examples/express/src/tracer.ts @@ -14,7 +14,7 @@ import { Sampler, AlwaysOnSampler, SimpleSpanProcessor } from '@opentelemetry/sd import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto'; import { ZipkinExporter } from '@opentelemetry/exporter-zipkin'; import { Resource } from '@opentelemetry/resources'; -import { SemanticAttributes, SemanticResourceAttributes as ResourceAttributesSC } from '@opentelemetry/semantic-conventions'; +import { SEMRESATTRS_SERVICE_NAME, SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions'; const Exporter = (process.env.EXPORTER || '').toLowerCase().startsWith('z') ? ZipkinExporter : OTLPTraceExporter; import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'; @@ -23,7 +23,7 @@ const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http'); export const setupTracing = (serviceName: string) => { const provider = new NodeTracerProvider({ resource: new Resource({ - [ResourceAttributesSC.SERVICE_NAME]: serviceName, + [SEMRESATTRS_SERVICE_NAME]: serviceName, }), sampler: filterSampler(ignoreHealthCheck, new AlwaysOnSampler()), }); @@ -65,5 +65,5 @@ function filterSampler(filterFn: FilterFunction, parent: Sampler): Sampler { } function ignoreHealthCheck(spanName: string, spanKind: SpanKind, attributes: Attributes) { - return spanKind !== opentelemetry.SpanKind.SERVER || attributes[SemanticAttributes.HTTP_ROUTE] !== "/health"; + return spanKind !== opentelemetry.SpanKind.SERVER || attributes[SEMATTRS_HTTP_ROUTE] !== "/health"; }