Skip to content

refactor(examples): update semconv usage to ATTR_ exports #2819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/connect/tracing.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { diag, DiagConsoleLogger, DiagLogLevel } = opentelemetry;
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);

const { Resource } = require('@opentelemetry/resources');
const { SEMRESATTRS_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');
const { ATTR_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
Expand All @@ -25,7 +25,7 @@ module.exports = (serviceName) => {
const exporter = new CollectorTraceExporter();
const provider = new NodeTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: serviceName,
[ATTR_SERVICE_NAME]: serviceName,
}),
spanProcessors: [
new SimpleSpanProcessor(exporter),
Expand Down
4 changes: 2 additions & 2 deletions examples/graphql/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const { OTLPTraceExporter } = require('@opentelemetry/exporter-otlp-http');
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');
const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-express');
const { Resource } = require('@opentelemetry/resources');
const { SEMRESATTRS_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');
const { ATTR_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');

const provider = new NodeTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'graphql-service',
[ATTR_SERVICE_NAME]: 'graphql-service',
}),
spanProcessors: [
new SimpleSpanProcessor(new OTLPTraceExporter()),
Expand Down
4 changes: 2 additions & 2 deletions examples/koa/src/tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { JaegerExporter } from '@opentelemetry/exporter-jaeger';
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
import { Resource } from '@opentelemetry/resources';
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions'
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions'

const EXPORTER = process.env.EXPORTER || '';

Expand All @@ -24,7 +24,7 @@ export const setupTracing = (serviceName: string) => {

const provider = new NodeTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: serviceName
[ATTR_SERVICE_NAME]: serviceName
}),
spanProcessors: [
new SimpleSpanProcessor(exporter),
Expand Down
4 changes: 2 additions & 2 deletions examples/memcached/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { SimpleSpanProcessor, ConsoleSpanExporter } = require('@opentelemetry/sdk-trace-base');
const { Resource } = require('@opentelemetry/resources');
const { SEMRESATTRS_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');
const { ATTR_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');

const { MemcachedInstrumentation } = require('@opentelemetry/instrumentation-memcached');

module.exports = (serviceName) => {
const exporter = new ConsoleSpanExporter();
const provider = new NodeTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: serviceName,
[ATTR_SERVICE_NAME]: serviceName,
}),
spanProcessors: [
new SimpleSpanProcessor(exporter),
Expand Down
4 changes: 2 additions & 2 deletions examples/mysql/src/tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
import { MySQLInstrumentation } from '@opentelemetry/instrumentation-mysql';
import { Resource } from '@opentelemetry/resources';
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
import {
MeterProvider,
PeriodicExportingMetricReader,
Expand Down Expand Up @@ -39,7 +39,7 @@ export const setupTracing = (serviceName: string) => {

const tracerProvider = new NodeTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: serviceName,
[ATTR_SERVICE_NAME]: serviceName,
}),
spanProcessors,
});
Expand Down
4 changes: 2 additions & 2 deletions examples/react-load/react/src/web-tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ZoneContextManager } from '@opentelemetry/context-zone';
import { CollectorTraceExporter } from '@opentelemetry/exporter-collector';
import { diag, DiagConsoleLogger } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions'
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions'

export default (serviceName) => {
const exporter = new CollectorTraceExporter({
Expand All @@ -14,7 +14,7 @@ export default (serviceName) => {

const provider = new WebTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: "react-load-example"
[ATTR_SERVICE_NAME]: "react-load-example"
}),
spanProcessors: [
new SimpleSpanProcessor(new ConsoleSpanExporter()),
Expand Down
4 changes: 2 additions & 2 deletions examples/redis/src/tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
import { RedisInstrumentation } from '@opentelemetry/instrumentation-redis';
import { Resource } from '@opentelemetry/resources';
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';

const EXPORTER = process.env.EXPORTER || '';

Expand All @@ -23,7 +23,7 @@ export const setupTracing = (serviceName: string) => {

const provider = new NodeTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: serviceName,
[ATTR_SERVICE_NAME]: serviceName,
}),
spanProcessors: [
new SimpleSpanProcessor(exporter),
Expand Down
4 changes: 2 additions & 2 deletions examples/web/examples/document-load/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { B3Propagator } from '@opentelemetry/propagator-b3';
import { CompositePropagator, W3CTraceContextPropagator } from '@opentelemetry/core';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { Resource } from '@opentelemetry/resources';
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';

const provider = new WebTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'web-service-dl',
[ATTR_SERVICE_NAME]: 'web-service-dl',
}),
spanProcessors: [
new SimpleSpanProcessor(new ConsoleSpanExporter()),
Expand Down
4 changes: 2 additions & 2 deletions examples/web/examples/meta/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { B3Propagator } from '@opentelemetry/propagator-b3';
import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { Resource } from '@opentelemetry/resources';
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';

const providerWithZone = new WebTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'web-service-meta',
[ATTR_SERVICE_NAME]: 'web-service-meta',
}),
spanProcessors: [
new SimpleSpanProcessor(new ConsoleSpanExporter()),
Expand Down
4 changes: 2 additions & 2 deletions examples/web/examples/user-interaction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { B3Propagator } from '@opentelemetry/propagator-b3';
import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { Resource } from '@opentelemetry/resources';
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';

const providerWithZone = new WebTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'web-service-ui',
[ATTR_SERVICE_NAME]: 'web-service-ui',
}),
spanProcessors: [
new SimpleSpanProcessor(new ConsoleSpanExporter()),
Expand Down
Loading