From 3bc3452814e30274d7eea1f3c9da968b88b1a197 Mon Sep 17 00:00:00 2001 From: Weyert de Boer Date: Sun, 25 Jul 2021 07:41:34 +0100 Subject: [PATCH] feat: updated spec to v1.5.0 and renamed resource class (#2345) Co-authored-by: Weyert de Boer Co-authored-by: Daniel Dyla Co-authored-by: Valentin Marchaud --- README.md | 4 ++ examples/basic-tracer-node/index.js | 4 +- examples/collector-exporter-node/metrics.js | 4 +- examples/collector-exporter-node/tracing.js | 4 +- examples/grpc-js/tracer.js | 4 +- examples/grpc/tracer.js | 4 +- examples/http/tracer.js | 4 +- examples/https/tracer.js | 4 +- examples/opentracing-shim/shim.js | 4 +- examples/tracer-web/examples/metrics/index.js | 4 +- getting-started/README.md | 4 +- getting-started/traced-example/tracing.js | 4 +- getting-started/ts-example/README.md | 3 +- .../ts-example/traced-example/tracing.ts | 4 +- .../src/platform/browser/sdk-info.ts | 10 +-- .../src/platform/node/sdk-info.ts | 10 +-- .../src/jaeger.ts | 4 +- .../test/jaeger.test.ts | 6 +- .../src/zipkin.ts | 8 +-- .../test/common/transform.test.ts | 24 +++---- .../test/node/zipkin.test.ts | 14 ++-- .../test/NodeTracerProvider.test.ts | 4 +- .../src/detectors/AwsBeanstalkDetector.ts | 14 ++-- .../src/detectors/AwsEc2Detector.ts | 18 ++--- .../src/detectors/AwsEcsDetector.ts | 10 +-- .../src/detectors/AwsEksDetector.ts | 10 +-- .../src/detectors/AwsLambdaDetector.ts | 10 +-- .../src/detectors/GcpDetector.ts | 2 +- packages/opentelemetry-resources/README.md | 4 +- .../opentelemetry-resources/src/Resource.ts | 2 +- .../platform/node/detectors/EnvDetector.ts | 2 +- .../node/detectors/ProcessDetector.ts | 2 +- .../test/Resource.test.ts | 10 +-- .../test/detectors/EnvDetector.test.ts | 8 +-- .../test/resource-assertions.test.ts | 70 +++++++++---------- .../test/util/resource-assertions.ts | 64 ++++++++--------- .../test/util/sample-detector.ts | 14 ++-- ...butes.ts => SemanticResourceAttributes.ts} | 39 +++++++++-- .../src/resource/index.ts | 2 +- .../src/trace/SemanticAttributes.ts | 20 ++++-- .../test/WebTracerProvider.test.ts | 4 +- scripts/semconv/generate.sh | 12 ++-- 42 files changed, 244 insertions(+), 208 deletions(-) rename packages/opentelemetry-semantic-conventions/src/resource/{ResourceAttributes.ts => SemanticResourceAttributes.ts} (87%) diff --git a/README.md b/README.md index dcc83ace99..70aec1d095 100644 --- a/README.md +++ b/README.md @@ -226,6 +226,10 @@ To request automatic tracing support for a module not on this list, please [file ## Upgrade guidelines +### 0.23.x to x + +- `ResourceAttributes` renamed to `SemanticResourceAttributes` in the `@opentelemetry/semantic-conventions` package + ### 0.20.x to x ### 0.19.x to 0.20.0 diff --git a/examples/basic-tracer-node/index.js b/examples/basic-tracer-node/index.js index 839f8a2744..0125c7c233 100644 --- a/examples/basic-tracer-node/index.js +++ b/examples/basic-tracer-node/index.js @@ -2,13 +2,13 @@ const opentelemetry = require('@opentelemetry/api'); const { Resource } = require('@opentelemetry/resources'); -const { ResourceAttributes } = require('@opentelemetry/semantic-conventions'); +const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions'); const { BasicTracerProvider, ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing'); const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); const provider = new BasicTracerProvider({ resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: 'basic-service', + [SemanticResourceAttributes.SERVICE_NAME]: 'basic-service', }), }); diff --git a/examples/collector-exporter-node/metrics.js b/examples/collector-exporter-node/metrics.js index bcd5b886c2..abcff409c1 100644 --- a/examples/collector-exporter-node/metrics.js +++ b/examples/collector-exporter-node/metrics.js @@ -6,7 +6,7 @@ const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector') // const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector-proto'); const { MeterProvider } = require('@opentelemetry/metrics'); const { Resource } = require('@opentelemetry/resources'); -const { ResourceAttributes } = require('@opentelemetry/semantic-conventions'); +const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions'); // Optional and only needed to see the internal diagnostic logging (during development) diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG); @@ -19,7 +19,7 @@ const meter = new MeterProvider({ exporter: metricExporter, interval: 1000, resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: 'basic-metric-service', + [SemanticResourceAttributes.SERVICE_NAME]: 'basic-metric-service', }), }).getMeter('example-exporter-collector'); diff --git a/examples/collector-exporter-node/tracing.js b/examples/collector-exporter-node/tracing.js index 03b968407e..9e6428132b 100644 --- a/examples/collector-exporter-node/tracing.js +++ b/examples/collector-exporter-node/tracing.js @@ -4,7 +4,7 @@ const opentelemetry = require('@opentelemetry/api'); const { BasicTracerProvider, ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing'); const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector'); const { Resource } = require('@opentelemetry/resources'); -const { ResourceAttributes } = require('@opentelemetry/semantic-conventions'); +const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions'); // const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-grpc'); // const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-proto'); @@ -21,7 +21,7 @@ const exporter = new CollectorTraceExporter({ const provider = new BasicTracerProvider({ resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: 'basic-service', + [SemanticResourceAttributes.SERVICE_NAME]: 'basic-service', }), }); provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); diff --git a/examples/grpc-js/tracer.js b/examples/grpc-js/tracer.js index b42f510973..cb860c2ffd 100644 --- a/examples/grpc-js/tracer.js +++ b/examples/grpc-js/tracer.js @@ -4,7 +4,7 @@ const opentelemetry = require('@opentelemetry/api'); const { registerInstrumentations } = require('@opentelemetry/instrumentation'); const { NodeTracerProvider } = require('@opentelemetry/node'); const { Resource } = require('@opentelemetry/resources'); -const { ResourceAttributes } = require('@opentelemetry/semantic-conventions'); +const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions'); const { SimpleSpanProcessor } = require('@opentelemetry/tracing'); const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin'); @@ -15,7 +15,7 @@ const EXPORTER = process.env.EXPORTER || ''; module.exports = (serviceName) => { const provider = new NodeTracerProvider({ resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: serviceName, + [SemanticResourceAttributes.SERVICE_NAME]: serviceName, }), }); diff --git a/examples/grpc/tracer.js b/examples/grpc/tracer.js index e2cbf08e4a..81eb9a6449 100644 --- a/examples/grpc/tracer.js +++ b/examples/grpc/tracer.js @@ -4,7 +4,7 @@ const opentelemetry = require('@opentelemetry/api'); const { registerInstrumentations } = require('@opentelemetry/instrumentation'); const { NodeTracerProvider } = require('@opentelemetry/node'); const { Resource } = require('@opentelemetry/resources'); -const { ResourceAttributes } = require('@opentelemetry/semantic-conventions'); +const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions'); const { SimpleSpanProcessor } = require('@opentelemetry/tracing'); const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin'); @@ -15,7 +15,7 @@ const EXPORTER = process.env.EXPORTER || ''; module.exports = (serviceName) => { const provider = new NodeTracerProvider({ resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: serviceName, + [SemanticResourceAttributes.SERVICE_NAME]: serviceName, }), }); diff --git a/examples/http/tracer.js b/examples/http/tracer.js index d73db897c2..7c034f4704 100644 --- a/examples/http/tracer.js +++ b/examples/http/tracer.js @@ -4,7 +4,7 @@ const opentelemetry = require('@opentelemetry/api'); const { registerInstrumentations } = require('@opentelemetry/instrumentation'); const { NodeTracerProvider } = require('@opentelemetry/node'); const { Resource } = require('@opentelemetry/resources'); -const { ResourceAttributes } = require('@opentelemetry/semantic-conventions'); +const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions'); const { SimpleSpanProcessor } = require('@opentelemetry/tracing'); const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin'); @@ -15,7 +15,7 @@ const EXPORTER = process.env.EXPORTER || ''; module.exports = (serviceName) => { const provider = new NodeTracerProvider({ resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: serviceName, + [SemanticResourceAttributes.SERVICE_NAME]: serviceName, }), }); diff --git a/examples/https/tracer.js b/examples/https/tracer.js index 1f7be3fb10..b323f14614 100644 --- a/examples/https/tracer.js +++ b/examples/https/tracer.js @@ -4,7 +4,7 @@ const opentelemetry = require('@opentelemetry/api'); const { registerInstrumentations } = require('@opentelemetry/instrumentation'); const { NodeTracerProvider } = require('@opentelemetry/node'); const { Resource } = require('@opentelemetry/resources'); -const { ResourceAttributes } = require('@opentelemetry/semantic-conventions'); +const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions'); const { SimpleSpanProcessor } = require('@opentelemetry/tracing'); const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin'); @@ -17,7 +17,7 @@ module.exports = (serviceName) => { let exporter; const provider = new NodeTracerProvider({ resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: serviceName, + [SemanticResourceAttributes.SERVICE_NAME]: serviceName, }), }); diff --git a/examples/opentracing-shim/shim.js b/examples/opentracing-shim/shim.js index f6c325a649..f42f281365 100644 --- a/examples/opentracing-shim/shim.js +++ b/examples/opentracing-shim/shim.js @@ -1,6 +1,6 @@ 'use strict'; -const { ResourceAttributes } = require('@opentelemetry/semantic-conventions'); +const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions'); const { Resource } = require('@opentelemetry/resources'); const { NodeTracerProvider } = require('@opentelemetry/node'); const { SimpleSpanProcessor } = require('@opentelemetry/tracing'); @@ -10,7 +10,7 @@ const { TracerShim } = require('@opentelemetry/shim-opentracing'); function shim(serviceName) { const provider = new NodeTracerProvider({ - resource: new Resource({ [ResourceAttributes.SERVICE_NAME]: serviceName }), + resource: new Resource({ [SemanticResourceAttributes.SERVICE_NAME]: serviceName }), }); provider.addSpanProcessor(new SimpleSpanProcessor(getExporter(serviceName))); diff --git a/examples/tracer-web/examples/metrics/index.js b/examples/tracer-web/examples/metrics/index.js index 91c8fe4610..8519166ceb 100644 --- a/examples/tracer-web/examples/metrics/index.js +++ b/examples/tracer-web/examples/metrics/index.js @@ -4,7 +4,7 @@ const { DiagConsoleLogger, DiagLogLevel, diag } = require('@opentelemetry/api'); const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector'); const { MeterProvider } = require('@opentelemetry/metrics'); const { Resource } = require('@opentelemetry/resources'); -const { ResourceAttributes } = require('@opentelemetry/semantic-conventions'); +const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions'); // Optional and only needed to see the internal diagnostic logging (during development) diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG); @@ -26,7 +26,7 @@ function startMetrics() { exporter: metricExporter, interval: 1000, resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: 'basic-metric-service', + [SemanticResourceAttributes.SERVICE_NAME]: 'basic-metric-service', }), }).getMeter('example-exporter-collector'); diff --git a/getting-started/README.md b/getting-started/README.md index a217dd429b..e7f7a02152 100644 --- a/getting-started/README.md +++ b/getting-started/README.md @@ -126,7 +126,7 @@ After you install these dependencies, initialize and register them. Modify `trac const { diag, DiagConsoleLogger, DiagLogLevel } = require("@opentelemetry/api"); const { NodeTracerProvider } = require("@opentelemetry/node"); const { Resource } = require('@opentelemetry/resources'); -const { ResourceAttributes } = require('@opentelemetry/semantic-conventions'); +const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions'); const { SimpleSpanProcessor } = require("@opentelemetry/tracing"); const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin"); const { registerInstrumentations } = require("@opentelemetry/instrumentation"); @@ -135,7 +135,7 @@ const { GrpcInstrumentation } = require("@opentelemetry/instrumentation-grpc"); const provider = new NodeTracerProvider({ resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: "getting-started", + [SemanticResourceAttributes.SERVICE_NAME]: "getting-started", }) }); diff --git a/getting-started/traced-example/tracing.js b/getting-started/traced-example/tracing.js index e1ac8b3264..dd0372ee76 100644 --- a/getting-started/traced-example/tracing.js +++ b/getting-started/traced-example/tracing.js @@ -3,7 +3,7 @@ const { NodeTracerProvider } = require("@opentelemetry/node"); const { SimpleSpanProcessor } = require("@opentelemetry/tracing"); const { Resource } = require('@opentelemetry/resources'); -const { ResourceAttributes } = require('@opentelemetry/semantic-conventions'); +const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions'); const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin"); const { registerInstrumentations } = require('@opentelemetry/instrumentation'); const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-express'); @@ -11,7 +11,7 @@ const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http'); const provider = new NodeTracerProvider({ resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: "getting-started", + [SemanticResourceAttributes.SERVICE_NAME]: "getting-started", }) }); diff --git a/getting-started/ts-example/README.md b/getting-started/ts-example/README.md index b4c75a5407..ee06e6fa5b 100644 --- a/getting-started/ts-example/README.md +++ b/getting-started/ts-example/README.md @@ -131,11 +131,12 @@ import { ZipkinExporter } from '@opentelemetry/exporter-zipkin'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'; import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; const provider: NodeTracerProvider = new NodeTracerProvider({ logLevel: LogLevel.ERROR, resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: 'getting-started', + [SemanticResourceAttributes.SERVICE_NAME]: 'getting-started', }), }); diff --git a/getting-started/ts-example/traced-example/tracing.ts b/getting-started/ts-example/traced-example/tracing.ts index 1d0f400fe4..ebac14e034 100644 --- a/getting-started/ts-example/traced-example/tracing.ts +++ b/getting-started/ts-example/traced-example/tracing.ts @@ -1,6 +1,6 @@ import { NodeTracerProvider } from '@opentelemetry/node'; const { Resource } = require('@opentelemetry/resources'); -const { ResourceAttributes } = require('@opentelemetry/semantic-conventions'); +const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions'); import { SimpleSpanProcessor } from '@opentelemetry/tracing'; import { ZipkinExporter } from '@opentelemetry/exporter-zipkin'; @@ -13,7 +13,7 @@ const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http'); const provider: NodeTracerProvider = new NodeTracerProvider({ resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: 'getting-started', + [SemanticResourceAttributes.SERVICE_NAME]: 'getting-started', }), }); provider.addSpanProcessor( diff --git a/packages/opentelemetry-core/src/platform/browser/sdk-info.ts b/packages/opentelemetry-core/src/platform/browser/sdk-info.ts index 04d2ea3d08..9366e21fbc 100644 --- a/packages/opentelemetry-core/src/platform/browser/sdk-info.ts +++ b/packages/opentelemetry-core/src/platform/browser/sdk-info.ts @@ -17,13 +17,13 @@ import { VERSION } from '../../version'; import { TelemetrySdkLanguageValues, - ResourceAttributes, + SemanticResourceAttributes, } from '@opentelemetry/semantic-conventions'; /** Constants describing the SDK in use */ export const SDK_INFO = { - [ResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry', - [ResourceAttributes.PROCESS_RUNTIME_NAME]: 'browser', - [ResourceAttributes.TELEMETRY_SDK_LANGUAGE]: TelemetrySdkLanguageValues.WEBJS, - [ResourceAttributes.TELEMETRY_SDK_VERSION]: VERSION, + [SemanticResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry', + [SemanticResourceAttributes.PROCESS_RUNTIME_NAME]: 'browser', + [SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]: TelemetrySdkLanguageValues.WEBJS, + [SemanticResourceAttributes.TELEMETRY_SDK_VERSION]: VERSION, }; diff --git a/packages/opentelemetry-core/src/platform/node/sdk-info.ts b/packages/opentelemetry-core/src/platform/node/sdk-info.ts index 87147644eb..6c7c4c5f02 100644 --- a/packages/opentelemetry-core/src/platform/node/sdk-info.ts +++ b/packages/opentelemetry-core/src/platform/node/sdk-info.ts @@ -17,14 +17,14 @@ import { VERSION } from '../../version'; import { TelemetrySdkLanguageValues, - ResourceAttributes, + SemanticResourceAttributes, } from '@opentelemetry/semantic-conventions'; /** Constants describing the SDK in use */ export const SDK_INFO = { - [ResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry', - [ResourceAttributes.PROCESS_RUNTIME_NAME]: 'node', - [ResourceAttributes.TELEMETRY_SDK_LANGUAGE]: + [SemanticResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry', + [SemanticResourceAttributes.PROCESS_RUNTIME_NAME]: 'node', + [SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]: TelemetrySdkLanguageValues.NODEJS, - [ResourceAttributes.TELEMETRY_SDK_VERSION]: VERSION, + [SemanticResourceAttributes.TELEMETRY_SDK_VERSION]: VERSION, }; diff --git a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts index f6514fadd7..259ee086f8 100644 --- a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts +++ b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts @@ -18,7 +18,7 @@ import { diag } from '@opentelemetry/api'; import { ExportResult, ExportResultCode, getEnv } from '@opentelemetry/core'; import { ReadableSpan, SpanExporter } from '@opentelemetry/tracing'; import { Socket } from 'dgram'; -import { ResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import { spanToThrift } from './transform'; import * as jaegerTypes from './types'; @@ -155,7 +155,7 @@ export class JaegerExporter implements SpanExporter { sender._client.unref(); } - const serviceNameTag = span.tags.find(t => t.key === ResourceAttributes.SERVICE_NAME) + const serviceNameTag = span.tags.find(t => t.key === SemanticResourceAttributes.SERVICE_NAME) const serviceName = serviceNameTag?.vStr || 'unknown_service'; sender.setProcess({ diff --git a/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts b/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts index b18ea08d36..1f45cbc90f 100644 --- a/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts +++ b/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts @@ -23,7 +23,7 @@ import { ReadableSpan } from '@opentelemetry/tracing'; import { TraceFlags } from '@opentelemetry/api'; import { Resource } from '@opentelemetry/resources'; import * as nock from 'nock'; -import { ResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; describe('JaegerExporter', () => { const readableSpan: ReadableSpan = { @@ -47,7 +47,7 @@ describe('JaegerExporter', () => { events: [], duration: [32, 800000000], resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: 'opentelemetry' + [SemanticResourceAttributes.SERVICE_NAME]: 'opentelemetry' }), instrumentationLibrary: { name: 'default', @@ -70,7 +70,7 @@ describe('JaegerExporter', () => { const scope =nock(mockedEndpoint) .post('/') .reply(202) - + const exporter = new JaegerExporter({ endpoint: mockedEndpoint, }); diff --git a/packages/opentelemetry-exporter-zipkin/src/zipkin.ts b/packages/opentelemetry-exporter-zipkin/src/zipkin.ts index cdf9df1980..975a5f261f 100644 --- a/packages/opentelemetry-exporter-zipkin/src/zipkin.ts +++ b/packages/opentelemetry-exporter-zipkin/src/zipkin.ts @@ -24,7 +24,7 @@ import { statusCodeTagName, statusDescriptionTagName, } from './transform'; -import { ResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import { prepareGetHeaders } from './utils'; /** @@ -66,7 +66,7 @@ export class ZipkinExporter implements SpanExporter { ) { const serviceName = String( this._serviceName || - spans[0].resource.attributes[ResourceAttributes.SERVICE_NAME] || + spans[0].resource.attributes[SemanticResourceAttributes.SERVICE_NAME] || this.DEFAULT_SERVICE_NAME ); @@ -128,8 +128,8 @@ export class ZipkinExporter implements SpanExporter { toZipkinSpan( span, String( - span.attributes[ResourceAttributes.SERVICE_NAME] || - span.resource.attributes[ResourceAttributes.SERVICE_NAME] || + span.attributes[SemanticResourceAttributes.SERVICE_NAME] || + span.resource.attributes[SemanticResourceAttributes.SERVICE_NAME] || serviceName ), this._statusCodeTagName, diff --git a/packages/opentelemetry-exporter-zipkin/test/common/transform.test.ts b/packages/opentelemetry-exporter-zipkin/test/common/transform.test.ts index 46f3be7ca1..f6ecb21f38 100644 --- a/packages/opentelemetry-exporter-zipkin/test/common/transform.test.ts +++ b/packages/opentelemetry-exporter-zipkin/test/common/transform.test.ts @@ -23,7 +23,7 @@ import { import { Resource } from '@opentelemetry/resources'; import { BasicTracerProvider, Span } from '@opentelemetry/tracing'; import * as assert from 'assert'; -import { ResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import { statusCodeTagName, statusDescriptionTagName, @@ -35,13 +35,13 @@ import * as zipkinTypes from '../../src/types'; const tracer = new BasicTracerProvider({ resource: Resource.default().merge( new Resource({ - [ResourceAttributes.SERVICE_NAME]: 'zipkin-test', + [SemanticResourceAttributes.SERVICE_NAME]: 'zipkin-test', }) ), }).getTracer('default'); const language = - tracer.resource.attributes[ResourceAttributes.TELEMETRY_SDK_LANGUAGE]; + tracer.resource.attributes[SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]; const parentId = '5c1c63257de34c67'; const spanContext: api.SpanContext = { @@ -54,7 +54,7 @@ const DUMMY_RESOURCE = new Resource({ service: 'ui', version: 1, cost: 112.12, - [ResourceAttributes.SERVICE_NAME]: 'zipkin-test', + [SemanticResourceAttributes.SERVICE_NAME]: 'zipkin-test', }); describe('transform', () => { @@ -102,7 +102,7 @@ describe('transform', () => { key1: 'value1', key2: 'value2', [statusCodeTagName]: 'UNSET', - [ResourceAttributes.SERVICE_NAME]: 'zipkin-test', + [SemanticResourceAttributes.SERVICE_NAME]: 'zipkin-test', 'telemetry.sdk.language': language, 'telemetry.sdk.name': 'opentelemetry', 'telemetry.sdk.version': VERSION, @@ -141,7 +141,7 @@ describe('transform', () => { parentId: undefined, tags: { [statusCodeTagName]: 'UNSET', - [ResourceAttributes.SERVICE_NAME]: 'zipkin-test', + [SemanticResourceAttributes.SERVICE_NAME]: 'zipkin-test', 'telemetry.sdk.language': language, 'telemetry.sdk.name': 'opentelemetry', 'telemetry.sdk.version': VERSION, @@ -190,7 +190,7 @@ describe('transform', () => { parentId: undefined, tags: { [statusCodeTagName]: 'UNSET', - [ResourceAttributes.SERVICE_NAME]: 'zipkin-test', + [SemanticResourceAttributes.SERVICE_NAME]: 'zipkin-test', 'telemetry.sdk.language': language, 'telemetry.sdk.name': 'opentelemetry', 'telemetry.sdk.version': VERSION, @@ -231,7 +231,7 @@ describe('transform', () => { cost: '112.12', service: 'ui', version: '1', - [ResourceAttributes.SERVICE_NAME]: 'zipkin-test', + [SemanticResourceAttributes.SERVICE_NAME]: 'zipkin-test', }); }); it('should map OpenTelemetry SpanStatus.code to a Zipkin tag', () => { @@ -258,7 +258,7 @@ describe('transform', () => { statusDescriptionTagName, Resource.empty().merge( new Resource({ - [ResourceAttributes.SERVICE_NAME]: 'zipkin-test', + [SemanticResourceAttributes.SERVICE_NAME]: 'zipkin-test', }) ) ); @@ -267,7 +267,7 @@ describe('transform', () => { key1: 'value1', key2: 'value2', [statusCodeTagName]: 'ERROR', - [ResourceAttributes.SERVICE_NAME]: 'zipkin-test', + [SemanticResourceAttributes.SERVICE_NAME]: 'zipkin-test', }); }); it('should map OpenTelemetry SpanStatus.message to a Zipkin tag', () => { @@ -295,7 +295,7 @@ describe('transform', () => { statusDescriptionTagName, Resource.empty().merge( new Resource({ - [ResourceAttributes.SERVICE_NAME]: 'zipkin-test', + [SemanticResourceAttributes.SERVICE_NAME]: 'zipkin-test', }) ) ); @@ -305,7 +305,7 @@ describe('transform', () => { key2: 'value2', [statusCodeTagName]: 'ERROR', [statusDescriptionTagName]: status.message, - [ResourceAttributes.SERVICE_NAME]: 'zipkin-test', + [SemanticResourceAttributes.SERVICE_NAME]: 'zipkin-test', }); }); }); diff --git a/packages/opentelemetry-exporter-zipkin/test/node/zipkin.test.ts b/packages/opentelemetry-exporter-zipkin/test/node/zipkin.test.ts index 31192fbd31..7650e92307 100644 --- a/packages/opentelemetry-exporter-zipkin/test/node/zipkin.test.ts +++ b/packages/opentelemetry-exporter-zipkin/test/node/zipkin.test.ts @@ -27,7 +27,7 @@ import { Resource } from '@opentelemetry/resources'; import { ZipkinExporter } from '../../src'; import * as zipkinTypes from '../../src/types'; import { TraceFlags } from '@opentelemetry/api'; -import { ResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; const MICROS_PER_SECS = 1e6; @@ -377,7 +377,7 @@ describe('Zipkin Exporter - node', () => { }, ], resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: resource_service_name, + [SemanticResourceAttributes.SERVICE_NAME]: resource_service_name, }), instrumentationLibrary: { name: 'default', version: '0.0.1' }, }; @@ -400,7 +400,7 @@ describe('Zipkin Exporter - node', () => { links: [], events: [], resource: new Resource({ - [ResourceAttributes.SERVICE_NAME]: resource_service_name_prime, + [SemanticResourceAttributes.SERVICE_NAME]: resource_service_name_prime, }), instrumentationLibrary: { name: 'default', version: '0.0.1' }, }; @@ -456,7 +456,7 @@ describe('Zipkin Exporter - node', () => { attributes: { key1: 'value1', key2: 'value2', - [ResourceAttributes.SERVICE_NAME]: span_service_name, + [SemanticResourceAttributes.SERVICE_NAME]: span_service_name, }, links: [], events: [ @@ -485,7 +485,7 @@ describe('Zipkin Exporter - node', () => { code: api.SpanStatusCode.OK, }, attributes: { - [ResourceAttributes.SERVICE_NAME]: span_service_name_prime, + [SemanticResourceAttributes.SERVICE_NAME]: span_service_name_prime, }, links: [], events: [], @@ -518,11 +518,11 @@ describe('Zipkin Exporter - node', () => { }) it('should use url from env', () => { const scope = nock('http://localhost:9412').post('/').reply(200); - + const exporter = new ZipkinExporter({ serviceName: 'my-service', }); - + exporter.export([getReadableSpan()], (result: ExportResult) => { scope.done(); assert.strictEqual(result.code, ExportResultCode.SUCCESS); diff --git a/packages/opentelemetry-node/test/NodeTracerProvider.test.ts b/packages/opentelemetry-node/test/NodeTracerProvider.test.ts index 7057965ab8..f3c37d5632 100644 --- a/packages/opentelemetry-node/test/NodeTracerProvider.test.ts +++ b/packages/opentelemetry-node/test/NodeTracerProvider.test.ts @@ -23,7 +23,7 @@ import { AlwaysOnSampler, AlwaysOffSampler } from '@opentelemetry/core'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { Span } from '@opentelemetry/tracing'; import { Resource } from '@opentelemetry/resources'; -import { ResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import * as assert from 'assert'; import * as path from 'path'; import { ContextManager, ROOT_CONTEXT } from '@opentelemetry/api'; @@ -145,7 +145,7 @@ describe('NodeTracerProvider', () => { assert.ok(span); assert.ok(span.resource instanceof Resource); assert.equal( - span.resource.attributes[ResourceAttributes.TELEMETRY_SDK_LANGUAGE], + span.resource.attributes[SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE], 'nodejs' ); }); diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts index 694f55764a..b40c830e5a 100644 --- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts +++ b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts @@ -23,7 +23,7 @@ import { import { CloudProviderValues, CloudPlatformValues, - ResourceAttributes, + SemanticResourceAttributes, } from '@opentelemetry/semantic-conventions'; import * as fs from 'fs'; import * as util from 'util'; @@ -69,14 +69,14 @@ export class AwsBeanstalkDetector implements Detector { const parsedData = JSON.parse(rawData); return new Resource({ - [ResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AWS, - [ResourceAttributes.CLOUD_PLATFORM]: + [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AWS, + [SemanticResourceAttributes.CLOUD_PLATFORM]: CloudPlatformValues.AWS_ELASTIC_BEANSTALK, - [ResourceAttributes.SERVICE_NAME]: + [SemanticResourceAttributes.SERVICE_NAME]: CloudPlatformValues.AWS_ELASTIC_BEANSTALK, - [ResourceAttributes.SERVICE_NAMESPACE]: parsedData.environment_name, - [ResourceAttributes.SERVICE_VERSION]: parsedData.version_label, - [ResourceAttributes.SERVICE_INSTANCE_ID]: parsedData.deployment_id, + [SemanticResourceAttributes.SERVICE_NAMESPACE]: parsedData.environment_name, + [SemanticResourceAttributes.SERVICE_VERSION]: parsedData.version_label, + [SemanticResourceAttributes.SERVICE_INSTANCE_ID]: parsedData.deployment_id, }); } catch (e) { diag.debug(`AwsBeanstalkDetector failed: ${e.message}`); diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts index 99d30c9049..b34c0d7d11 100644 --- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts +++ b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts @@ -22,7 +22,7 @@ import { import { CloudProviderValues, CloudPlatformValues, - ResourceAttributes, + SemanticResourceAttributes, } from '@opentelemetry/semantic-conventions'; import * as http from 'http'; @@ -67,14 +67,14 @@ class AwsEc2Detector implements Detector { const hostname = await this._fetchHost(token); return new Resource({ - [ResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AWS, - [ResourceAttributes.CLOUD_PLATFORM]: CloudPlatformValues.AWS_EC2, - [ResourceAttributes.CLOUD_ACCOUNT_ID]: accountId, - [ResourceAttributes.CLOUD_REGION]: region, - [ResourceAttributes.CLOUD_AVAILABILITY_ZONE]: availabilityZone, - [ResourceAttributes.HOST_ID]: instanceId, - [ResourceAttributes.HOST_TYPE]: instanceType, - [ResourceAttributes.HOST_NAME]: hostname, + [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AWS, + [SemanticResourceAttributes.CLOUD_PLATFORM]: CloudPlatformValues.AWS_EC2, + [SemanticResourceAttributes.CLOUD_ACCOUNT_ID]: accountId, + [SemanticResourceAttributes.CLOUD_REGION]: region, + [SemanticResourceAttributes.CLOUD_AVAILABILITY_ZONE]: availabilityZone, + [SemanticResourceAttributes.HOST_ID]: instanceId, + [SemanticResourceAttributes.HOST_TYPE]: instanceType, + [SemanticResourceAttributes.HOST_NAME]: hostname, }); } diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts index 0f73666778..02d0c598bc 100644 --- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts +++ b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts @@ -23,7 +23,7 @@ import { import { CloudProviderValues, CloudPlatformValues, - ResourceAttributes, + SemanticResourceAttributes, } from '@opentelemetry/semantic-conventions'; import * as util from 'util'; import * as fs from 'fs'; @@ -53,10 +53,10 @@ export class AwsEcsDetector implements Detector { return !hostName && !containerId ? Resource.empty() : new Resource({ - [ResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AWS, - [ResourceAttributes.CLOUD_PLATFORM]: CloudPlatformValues.AWS_ECS, - [ResourceAttributes.CONTAINER_NAME]: hostName || '', - [ResourceAttributes.CONTAINER_ID]: containerId || '', + [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AWS, + [SemanticResourceAttributes.CLOUD_PLATFORM]: CloudPlatformValues.AWS_ECS, + [SemanticResourceAttributes.CONTAINER_NAME]: hostName || '', + [SemanticResourceAttributes.CONTAINER_ID]: containerId || '', }); } diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetector.ts index c7348e325f..39c041427a 100644 --- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetector.ts +++ b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetector.ts @@ -22,7 +22,7 @@ import { import { CloudProviderValues, CloudPlatformValues, - ResourceAttributes, + SemanticResourceAttributes, } from '@opentelemetry/semantic-conventions'; import * as https from 'https'; import * as fs from 'fs'; @@ -79,10 +79,10 @@ export class AwsEksDetector implements Detector { return !containerId && !clusterName ? Resource.empty() : new Resource({ - [ResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AWS, - [ResourceAttributes.CLOUD_PLATFORM]: CloudPlatformValues.AWS_EKS, - [ResourceAttributes.K8S_CLUSTER_NAME]: clusterName || '', - [ResourceAttributes.CONTAINER_ID]: containerId || '', + [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AWS, + [SemanticResourceAttributes.CLOUD_PLATFORM]: CloudPlatformValues.AWS_EKS, + [SemanticResourceAttributes.K8S_CLUSTER_NAME]: clusterName || '', + [SemanticResourceAttributes.CONTAINER_ID]: containerId || '', }); } catch (e) { diag.warn('Process is not running on K8S', e); diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetector.ts index 757bd6725c..5c8156d260 100644 --- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetector.ts +++ b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsLambdaDetector.ts @@ -21,7 +21,7 @@ import { } from '@opentelemetry/resources'; import { CloudProviderValues, - ResourceAttributes, + SemanticResourceAttributes, } from '@opentelemetry/semantic-conventions'; /** @@ -40,17 +40,17 @@ export class AwsLambdaDetector implements Detector { const region = process.env.AWS_REGION; const attributes = { - [ResourceAttributes.CLOUD_PROVIDER]: String(CloudProviderValues.AWS), + [SemanticResourceAttributes.CLOUD_PROVIDER]: String(CloudProviderValues.AWS), }; if (region) { - attributes[ResourceAttributes.CLOUD_REGION] = region; + attributes[SemanticResourceAttributes.CLOUD_REGION] = region; } if (functionName) { - attributes[ResourceAttributes.FAAS_NAME] = functionName; + attributes[SemanticResourceAttributes.FAAS_NAME] = functionName; } if (functionVersion) { - attributes[ResourceAttributes.FAAS_VERSION] = functionVersion; + attributes[SemanticResourceAttributes.FAAS_VERSION] = functionVersion; } return new Resource(attributes); diff --git a/packages/opentelemetry-resource-detector-gcp/src/detectors/GcpDetector.ts b/packages/opentelemetry-resource-detector-gcp/src/detectors/GcpDetector.ts index 39477a1b00..e2b8c62e46 100644 --- a/packages/opentelemetry-resource-detector-gcp/src/detectors/GcpDetector.ts +++ b/packages/opentelemetry-resource-detector-gcp/src/detectors/GcpDetector.ts @@ -26,7 +26,7 @@ import { import { getEnv } from '@opentelemetry/core'; import { CloudProviderValues, - ResourceAttributes as SemanticResourceAttributes, + SemanticResourceAttributes, } from '@opentelemetry/semantic-conventions'; /** diff --git a/packages/opentelemetry-resources/README.md b/packages/opentelemetry-resources/README.md index b29aded79a..29c1c897ac 100644 --- a/packages/opentelemetry-resources/README.md +++ b/packages/opentelemetry-resources/README.md @@ -18,11 +18,11 @@ npm install --save @opentelemetry/resources ## Usage ```typescript -import { ResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import { Resource } from '@opentelemetry/resources'; const resource = new Resource({ - [ResourceAttributes.SERVICE_NAME]: 'api-service', + [SemanticResourceAttributes.SERVICE_NAME]: 'api-service', }); const another_resource = new Resource({ diff --git a/packages/opentelemetry-resources/src/Resource.ts b/packages/opentelemetry-resources/src/Resource.ts index 161995ac0f..f048ea3580 100644 --- a/packages/opentelemetry-resources/src/Resource.ts +++ b/packages/opentelemetry-resources/src/Resource.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { ResourceAttributes as SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import { SDK_INFO } from '@opentelemetry/core'; import { ResourceAttributes } from './types'; import { defaultServiceName } from './platform'; diff --git a/packages/opentelemetry-resources/src/platform/node/detectors/EnvDetector.ts b/packages/opentelemetry-resources/src/platform/node/detectors/EnvDetector.ts index b496433b4d..a053c4da47 100644 --- a/packages/opentelemetry-resources/src/platform/node/detectors/EnvDetector.ts +++ b/packages/opentelemetry-resources/src/platform/node/detectors/EnvDetector.ts @@ -16,7 +16,7 @@ import { diag } from '@opentelemetry/api'; import { getEnv } from '@opentelemetry/core'; -import { ResourceAttributes as SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import { Detector, Resource, diff --git a/packages/opentelemetry-resources/src/platform/node/detectors/ProcessDetector.ts b/packages/opentelemetry-resources/src/platform/node/detectors/ProcessDetector.ts index bb223fc1a0..1df2d9b65f 100644 --- a/packages/opentelemetry-resources/src/platform/node/detectors/ProcessDetector.ts +++ b/packages/opentelemetry-resources/src/platform/node/detectors/ProcessDetector.ts @@ -15,7 +15,7 @@ */ import { diag } from '@opentelemetry/api'; -import { ResourceAttributes as SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import { Detector, Resource, ResourceDetectionConfig } from '../../../'; import { ResourceAttributes } from '../../../types'; diff --git a/packages/opentelemetry-resources/test/Resource.test.ts b/packages/opentelemetry-resources/test/Resource.test.ts index d321a4422c..b2e656b309 100644 --- a/packages/opentelemetry-resources/test/Resource.test.ts +++ b/packages/opentelemetry-resources/test/Resource.test.ts @@ -17,7 +17,7 @@ import * as assert from 'assert'; import { SDK_INFO } from '@opentelemetry/core'; import { Resource } from '../src'; -import { ResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; describe('Resource', () => { const resource1 = new Resource({ @@ -103,10 +103,10 @@ describe('Resource', () => { describe('.default()', () => { it('should return a default resource', () => { const resource = Resource.default(); - assert.strictEqual(resource.attributes[ResourceAttributes.TELEMETRY_SDK_NAME], SDK_INFO[ResourceAttributes.TELEMETRY_SDK_NAME]); - assert.strictEqual(resource.attributes[ResourceAttributes.TELEMETRY_SDK_LANGUAGE], SDK_INFO[ResourceAttributes.TELEMETRY_SDK_LANGUAGE]); - assert.strictEqual(resource.attributes[ResourceAttributes.TELEMETRY_SDK_VERSION], SDK_INFO[ResourceAttributes.TELEMETRY_SDK_VERSION]); - assert.strictEqual(resource.attributes[ResourceAttributes.SERVICE_NAME], `unknown_service:${process.argv0}`); + assert.strictEqual(resource.attributes[SemanticResourceAttributes.TELEMETRY_SDK_NAME], SDK_INFO[SemanticResourceAttributes.TELEMETRY_SDK_NAME]); + assert.strictEqual(resource.attributes[SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE], SDK_INFO[SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]); + assert.strictEqual(resource.attributes[SemanticResourceAttributes.TELEMETRY_SDK_VERSION], SDK_INFO[SemanticResourceAttributes.TELEMETRY_SDK_VERSION]); + assert.strictEqual(resource.attributes[SemanticResourceAttributes.SERVICE_NAME], `unknown_service:${process.argv0}`); }); }); }); diff --git a/packages/opentelemetry-resources/test/detectors/EnvDetector.test.ts b/packages/opentelemetry-resources/test/detectors/EnvDetector.test.ts index 66c228fe0f..64c1ff3756 100644 --- a/packages/opentelemetry-resources/test/detectors/EnvDetector.test.ts +++ b/packages/opentelemetry-resources/test/detectors/EnvDetector.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { ResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import { envDetector, Resource } from '../../src'; import { assertK8sResource, @@ -35,9 +35,9 @@ describe('envDetector()', () => { it('should return resource information from environment variable', async () => { const resource: Resource = await envDetector.detect(); assertK8sResource(resource, { - [ResourceAttributes.K8S_POD_NAME]: 'pod-xyz-123', - [ResourceAttributes.K8S_CLUSTER_NAME]: 'c1', - [ResourceAttributes.K8S_NAMESPACE_NAME]: 'default', + [SemanticResourceAttributes.K8S_POD_NAME]: 'pod-xyz-123', + [SemanticResourceAttributes.K8S_CLUSTER_NAME]: 'c1', + [SemanticResourceAttributes.K8S_NAMESPACE_NAME]: 'default', }); }); }); diff --git a/packages/opentelemetry-resources/test/resource-assertions.test.ts b/packages/opentelemetry-resources/test/resource-assertions.test.ts index 57a470da4d..cde2b8a9f2 100644 --- a/packages/opentelemetry-resources/test/resource-assertions.test.ts +++ b/packages/opentelemetry-resources/test/resource-assertions.test.ts @@ -15,7 +15,7 @@ */ import { SDK_INFO } from '@opentelemetry/core'; -import { ResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import { Resource } from '../src/Resource'; import { assertCloudResource, @@ -29,17 +29,17 @@ import { describe('assertCloudResource', () => { it('requires one cloud label', () => { const resource = new Resource({ - [ResourceAttributes.CLOUD_PROVIDER]: 'gcp', + [SemanticResourceAttributes.CLOUD_PROVIDER]: 'gcp', }); assertCloudResource(resource, {}); }); it('validates optional attributes', () => { const resource = new Resource({ - [ResourceAttributes.CLOUD_PROVIDER]: 'gcp', - [ResourceAttributes.CLOUD_ACCOUNT_ID]: 'opentelemetry', - [ResourceAttributes.CLOUD_REGION]: 'us-central1', - [ResourceAttributes.CLOUD_AVAILABILITY_ZONE]: 'us-central1-a', + [SemanticResourceAttributes.CLOUD_PROVIDER]: 'gcp', + [SemanticResourceAttributes.CLOUD_ACCOUNT_ID]: 'opentelemetry', + [SemanticResourceAttributes.CLOUD_REGION]: 'us-central1', + [SemanticResourceAttributes.CLOUD_AVAILABILITY_ZONE]: 'us-central1-a', }); assertCloudResource(resource, { provider: 'gcp', @@ -53,18 +53,18 @@ describe('assertCloudResource', () => { describe('assertContainerResource', () => { it('requires one container label', () => { const resource = new Resource({ - [ResourceAttributes.CONTAINER_NAME]: 'opentelemetry-autoconf', + [SemanticResourceAttributes.CONTAINER_NAME]: 'opentelemetry-autoconf', }); assertContainerResource(resource, {}); }); it('validates optional attributes', () => { const resource = new Resource({ - [ResourceAttributes.CONTAINER_NAME]: 'opentelemetry-autoconf', - [ResourceAttributes.CONTAINER_ID]: 'abc', - [ResourceAttributes.CONTAINER_IMAGE_NAME]: + [SemanticResourceAttributes.CONTAINER_NAME]: 'opentelemetry-autoconf', + [SemanticResourceAttributes.CONTAINER_ID]: 'abc', + [SemanticResourceAttributes.CONTAINER_IMAGE_NAME]: 'gcr.io/opentelemetry/operator', - [ResourceAttributes.CONTAINER_IMAGE_TAG]: '0.1', + [SemanticResourceAttributes.CONTAINER_IMAGE_TAG]: '0.1', }); assertContainerResource(resource, { name: 'opentelemetry-autoconf', @@ -78,20 +78,20 @@ describe('assertContainerResource', () => { describe('assertHostResource', () => { it('requires one host label', () => { const resource = new Resource({ - [ResourceAttributes.HOST_ID]: 'opentelemetry-test-id', + [SemanticResourceAttributes.HOST_ID]: 'opentelemetry-test-id', }); assertHostResource(resource, {}); }); it('validates optional attributes', () => { const resource = new Resource({ - [ResourceAttributes.HOST_ID]: 'opentelemetry-test-id', - [ResourceAttributes.HOST_NAME]: 'opentelemetry-test-name', - [ResourceAttributes.HOST_TYPE]: 'n1-standard-1', - [ResourceAttributes.HOST_IMAGE_NAME]: + [SemanticResourceAttributes.HOST_ID]: 'opentelemetry-test-id', + [SemanticResourceAttributes.HOST_NAME]: 'opentelemetry-test-name', + [SemanticResourceAttributes.HOST_TYPE]: 'n1-standard-1', + [SemanticResourceAttributes.HOST_IMAGE_NAME]: 'infra-ami-eks-worker-node-7d4ec78312, CentOS-8-x86_64-1905', - [ResourceAttributes.HOST_IMAGE_ID]: 'ami-07b06b442921831e5', - [ResourceAttributes.HOST_IMAGE_VERSION]: '0.1', + [SemanticResourceAttributes.HOST_IMAGE_ID]: 'ami-07b06b442921831e5', + [SemanticResourceAttributes.HOST_IMAGE_VERSION]: '0.1', }); assertHostResource(resource, { hostName: 'opentelemetry-test-hostname', @@ -108,17 +108,17 @@ describe('assertHostResource', () => { describe('assertK8sResource', () => { it('requires one k8s label', () => { const resource = new Resource({ - [ResourceAttributes.K8S_CLUSTER_NAME]: 'opentelemetry-cluster', + [SemanticResourceAttributes.K8S_CLUSTER_NAME]: 'opentelemetry-cluster', }); assertK8sResource(resource, {}); }); it('validates optional attributes', () => { const resource = new Resource({ - [ResourceAttributes.K8S_CLUSTER_NAME]: 'opentelemetry-cluster', - [ResourceAttributes.K8S_NAMESPACE_NAME]: 'default', - [ResourceAttributes.K8S_POD_NAME]: 'opentelemetry-pod-autoconf', - [ResourceAttributes.K8S_DEPLOYMENT_NAME]: 'opentelemetry', + [SemanticResourceAttributes.K8S_CLUSTER_NAME]: 'opentelemetry-cluster', + [SemanticResourceAttributes.K8S_NAMESPACE_NAME]: 'default', + [SemanticResourceAttributes.K8S_POD_NAME]: 'opentelemetry-pod-autoconf', + [SemanticResourceAttributes.K8S_DEPLOYMENT_NAME]: 'opentelemetry', }); assertK8sResource(resource, { clusterName: 'opentelemetry-cluster', @@ -132,18 +132,18 @@ describe('assertK8sResource', () => { describe('assertTelemetrySDKResource', () => { it('uses default validations', () => { const resource = new Resource({ - [ResourceAttributes.TELEMETRY_SDK_NAME]: SDK_INFO.NAME, - [ResourceAttributes.TELEMETRY_SDK_LANGUAGE]: SDK_INFO.LANGUAGE, - [ResourceAttributes.TELEMETRY_SDK_VERSION]: SDK_INFO.VERSION, + [SemanticResourceAttributes.TELEMETRY_SDK_NAME]: SDK_INFO.NAME, + [SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]: SDK_INFO.LANGUAGE, + [SemanticResourceAttributes.TELEMETRY_SDK_VERSION]: SDK_INFO.VERSION, }); assertTelemetrySDKResource(resource, {}); }); it('validates optional attributes', () => { const resource = new Resource({ - [ResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry', - [ResourceAttributes.TELEMETRY_SDK_LANGUAGE]: 'nodejs', - [ResourceAttributes.TELEMETRY_SDK_VERSION]: '0.1.0', + [SemanticResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry', + [SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]: 'nodejs', + [SemanticResourceAttributes.TELEMETRY_SDK_VERSION]: '0.1.0', }); assertTelemetrySDKResource(resource, { name: 'opentelemetry', @@ -156,8 +156,8 @@ describe('assertTelemetrySDKResource', () => { describe('assertServiceResource', () => { it('validates required attributes', () => { const resource = new Resource({ - [ResourceAttributes.SERVICE_NAME]: 'shoppingcart', - [ResourceAttributes.SERVICE_INSTANCE_ID]: + [SemanticResourceAttributes.SERVICE_NAME]: 'shoppingcart', + [SemanticResourceAttributes.SERVICE_INSTANCE_ID]: '627cc493-f310-47de-96bd-71410b7dec09', }); assertServiceResource(resource, { @@ -168,11 +168,11 @@ describe('assertServiceResource', () => { it('validates optional attributes', () => { const resource = new Resource({ - [ResourceAttributes.SERVICE_NAME]: 'shoppingcart', - [ResourceAttributes.SERVICE_INSTANCE_ID]: + [SemanticResourceAttributes.SERVICE_NAME]: 'shoppingcart', + [SemanticResourceAttributes.SERVICE_INSTANCE_ID]: '627cc493-f310-47de-96bd-71410b7dec09', - [ResourceAttributes.SERVICE_NAMESPACE]: 'shop', - [ResourceAttributes.SERVICE_VERSION]: '0.1.0', + [SemanticResourceAttributes.SERVICE_NAMESPACE]: 'shop', + [SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0', }); assertServiceResource(resource, { name: 'shoppingcart', diff --git a/packages/opentelemetry-resources/test/util/resource-assertions.ts b/packages/opentelemetry-resources/test/util/resource-assertions.ts index 5284e83575..9177aea703 100644 --- a/packages/opentelemetry-resources/test/util/resource-assertions.ts +++ b/packages/opentelemetry-resources/test/util/resource-assertions.ts @@ -17,7 +17,7 @@ import { SDK_INFO } from '@opentelemetry/core'; import * as assert from 'assert'; import { Resource } from '../../src/Resource'; -import { ResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; /** * Test utility method to validate a cloud resource @@ -37,22 +37,22 @@ export const assertCloudResource = ( assertHasOneLabel('CLOUD', resource); if (validations.provider) assert.strictEqual( - resource.attributes[ResourceAttributes.CLOUD_PROVIDER], + resource.attributes[SemanticResourceAttributes.CLOUD_PROVIDER], validations.provider ); if (validations.accountId) assert.strictEqual( - resource.attributes[ResourceAttributes.CLOUD_ACCOUNT_ID], + resource.attributes[SemanticResourceAttributes.CLOUD_ACCOUNT_ID], validations.accountId ); if (validations.region) assert.strictEqual( - resource.attributes[ResourceAttributes.CLOUD_REGION], + resource.attributes[SemanticResourceAttributes.CLOUD_REGION], validations.region ); if (validations.zone) assert.strictEqual( - resource.attributes[ResourceAttributes.CLOUD_AVAILABILITY_ZONE], + resource.attributes[SemanticResourceAttributes.CLOUD_AVAILABILITY_ZONE], validations.zone ); }; @@ -75,22 +75,22 @@ export const assertContainerResource = ( assertHasOneLabel('CONTAINER', resource); if (validations.name) assert.strictEqual( - resource.attributes[ResourceAttributes.CONTAINER_NAME], + resource.attributes[SemanticResourceAttributes.CONTAINER_NAME], validations.name ); if (validations.id) assert.strictEqual( - resource.attributes[ResourceAttributes.CONTAINER_ID], + resource.attributes[SemanticResourceAttributes.CONTAINER_ID], validations.id ); if (validations.imageName) assert.strictEqual( - resource.attributes[ResourceAttributes.CONTAINER_IMAGE_NAME], + resource.attributes[SemanticResourceAttributes.CONTAINER_IMAGE_NAME], validations.imageName ); if (validations.imageTag) assert.strictEqual( - resource.attributes[ResourceAttributes.CONTAINER_IMAGE_TAG], + resource.attributes[SemanticResourceAttributes.CONTAINER_IMAGE_TAG], validations.imageTag ); }; @@ -116,32 +116,32 @@ export const assertHostResource = ( assertHasOneLabel('HOST', resource); if (validations.id) assert.strictEqual( - resource.attributes[ResourceAttributes.HOST_ID], + resource.attributes[SemanticResourceAttributes.HOST_ID], validations.id ); if (validations.name) assert.strictEqual( - resource.attributes[ResourceAttributes.HOST_NAME], + resource.attributes[SemanticResourceAttributes.HOST_NAME], validations.name ); if (validations.hostType) assert.strictEqual( - resource.attributes[ResourceAttributes.HOST_TYPE], + resource.attributes[SemanticResourceAttributes.HOST_TYPE], validations.hostType ); if (validations.imageName) assert.strictEqual( - resource.attributes[ResourceAttributes.HOST_IMAGE_NAME], + resource.attributes[SemanticResourceAttributes.HOST_IMAGE_NAME], validations.imageName ); if (validations.imageId) assert.strictEqual( - resource.attributes[ResourceAttributes.HOST_IMAGE_ID], + resource.attributes[SemanticResourceAttributes.HOST_IMAGE_ID], validations.imageId ); if (validations.imageVersion) assert.strictEqual( - resource.attributes[ResourceAttributes.HOST_IMAGE_VERSION], + resource.attributes[SemanticResourceAttributes.HOST_IMAGE_VERSION], validations.imageVersion ); }; @@ -164,22 +164,22 @@ export const assertK8sResource = ( assertHasOneLabel('K8S', resource); if (validations.clusterName) assert.strictEqual( - resource.attributes[ResourceAttributes.K8S_CLUSTER_NAME], + resource.attributes[SemanticResourceAttributes.K8S_CLUSTER_NAME], validations.clusterName ); if (validations.namespaceName) assert.strictEqual( - resource.attributes[ResourceAttributes.K8S_NAMESPACE_NAME], + resource.attributes[SemanticResourceAttributes.K8S_NAMESPACE_NAME], validations.namespaceName ); if (validations.podName) assert.strictEqual( - resource.attributes[ResourceAttributes.K8S_POD_NAME], + resource.attributes[SemanticResourceAttributes.K8S_POD_NAME], validations.podName ); if (validations.deploymentName) assert.strictEqual( - resource.attributes[ResourceAttributes.K8S_DEPLOYMENT_NAME], + resource.attributes[SemanticResourceAttributes.K8S_DEPLOYMENT_NAME], validations.deploymentName ); }; @@ -207,17 +207,17 @@ export const assertTelemetrySDKResource = ( if (validations.name) assert.strictEqual( - resource.attributes[ResourceAttributes.TELEMETRY_SDK_NAME], + resource.attributes[SemanticResourceAttributes.TELEMETRY_SDK_NAME], validations.name ); if (validations.language) assert.strictEqual( - resource.attributes[ResourceAttributes.TELEMETRY_SDK_LANGUAGE], + resource.attributes[SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE], validations.language ); if (validations.version) assert.strictEqual( - resource.attributes[ResourceAttributes.TELEMETRY_SDK_VERSION], + resource.attributes[SemanticResourceAttributes.TELEMETRY_SDK_VERSION], validations.version ); }; @@ -238,21 +238,21 @@ export const assertServiceResource = ( } ) => { assert.strictEqual( - resource.attributes[ResourceAttributes.SERVICE_NAME], + resource.attributes[SemanticResourceAttributes.SERVICE_NAME], validations.name ); assert.strictEqual( - resource.attributes[ResourceAttributes.SERVICE_INSTANCE_ID], + resource.attributes[SemanticResourceAttributes.SERVICE_INSTANCE_ID], validations.instanceId ); if (validations.namespace) assert.strictEqual( - resource.attributes[ResourceAttributes.SERVICE_NAMESPACE], + resource.attributes[SemanticResourceAttributes.SERVICE_NAMESPACE], validations.namespace ); if (validations.version) assert.strictEqual( - resource.attributes[ResourceAttributes.SERVICE_VERSION], + resource.attributes[SemanticResourceAttributes.SERVICE_VERSION], validations.version ); }; @@ -273,24 +273,24 @@ export const assertProcessResource = ( } ) => { assert.strictEqual( - resource.attributes[ResourceAttributes.PROCESS_PID], + resource.attributes[SemanticResourceAttributes.PROCESS_PID], validations.pid ); if (validations.name) { assert.strictEqual( - resource.attributes[ResourceAttributes.PROCESS_EXECUTABLE_NAME], + resource.attributes[SemanticResourceAttributes.PROCESS_EXECUTABLE_NAME], validations.name ); } if (validations.command) { assert.strictEqual( - resource.attributes[ResourceAttributes.PROCESS_COMMAND], + resource.attributes[SemanticResourceAttributes.PROCESS_COMMAND], validations.command ); } if (validations.commandLine) { assert.strictEqual( - resource.attributes[ResourceAttributes.PROCESS_COMMAND_LINE], + resource.attributes[SemanticResourceAttributes.PROCESS_COMMAND_LINE], validations.commandLine ); } @@ -306,7 +306,7 @@ export const assertEmptyResource = (resource: Resource) => { }; const assertHasOneLabel = (prefix: string, resource: Resource): void => { - const hasOne = Object.entries(ResourceAttributes).find(([key, value]) => { + const hasOne = Object.entries(SemanticResourceAttributes).find(([key, value]) => { return ( key.startsWith(prefix) && Object.prototype.hasOwnProperty.call(resource.attributes, value) @@ -316,7 +316,7 @@ const assertHasOneLabel = (prefix: string, resource: Resource): void => { assert.ok( hasOne, 'Resource must have one of the following attributes: ' + - Object.entries(ResourceAttributes) + Object.entries(SemanticResourceAttributes) .reduce((result, [key, value]) => { if (key.startsWith(prefix)) { result.push(value); diff --git a/packages/opentelemetry-resources/test/util/sample-detector.ts b/packages/opentelemetry-resources/test/util/sample-detector.ts index 9e871557c8..841a760958 100644 --- a/packages/opentelemetry-resources/test/util/sample-detector.ts +++ b/packages/opentelemetry-resources/test/util/sample-detector.ts @@ -14,18 +14,18 @@ * limitations under the License. */ -import { ResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import { Detector, Resource } from '../../src'; class SampleDetector implements Detector { async detect(): Promise { return new Resource({ - [ResourceAttributes.CLOUD_PROVIDER]: 'provider', - [ResourceAttributes.CLOUD_ACCOUNT_ID]: 'accountId', - [ResourceAttributes.CLOUD_REGION]: 'region', - [ResourceAttributes.CLOUD_AVAILABILITY_ZONE]: 'zone', - [ResourceAttributes.HOST_ID]: 'instanceId', - [ResourceAttributes.HOST_TYPE]: 'instanceType', + [SemanticResourceAttributes.CLOUD_PROVIDER]: 'provider', + [SemanticResourceAttributes.CLOUD_ACCOUNT_ID]: 'accountId', + [SemanticResourceAttributes.CLOUD_REGION]: 'region', + [SemanticResourceAttributes.CLOUD_AVAILABILITY_ZONE]: 'zone', + [SemanticResourceAttributes.HOST_ID]: 'instanceId', + [SemanticResourceAttributes.HOST_TYPE]: 'instanceType', }); } } diff --git a/packages/opentelemetry-semantic-conventions/src/resource/ResourceAttributes.ts b/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts similarity index 87% rename from packages/opentelemetry-semantic-conventions/src/resource/ResourceAttributes.ts rename to packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts index 06d7a872d3..67f0235179 100644 --- a/packages/opentelemetry-semantic-conventions/src/resource/ResourceAttributes.ts +++ b/packages/opentelemetry-semantic-conventions/src/resource/SemanticResourceAttributes.ts @@ -15,7 +15,7 @@ */ // DO NOT EDIT, this is an Auto-generated file from scripts/semconv/templates//templates/SemanticAttributes.ts.j2 -export const ResourceAttributes = { +export const SemanticResourceAttributes = { /** * Name of the cloud provider. @@ -159,24 +159,51 @@ export const ResourceAttributes = { DEVICE_MODEL_NAME: 'device.model.name', /** - * The name of the function being executed. + * The name of the single function that this runtime instance executes. + * + * Note: This is the name of the function as configured/deployed on the FaaS platform and is usually different from the name of the callback function (which may be stored in the [`code.namespace`/`code.function`](../../trace/semantic_conventions/span-general.md#source-code-attributes) span attributes). */ FAAS_NAME: 'faas.name', /** - * The unique ID of the function being executed. + * The unique ID of the single function that this runtime instance executes. * - * Note: For example, in AWS Lambda this field corresponds to the [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) value, in GCP to the URI of the resource, and in Azure to the [FunctionDirectory](https://github.com/Azure/azure-functions-host/wiki/Retrieving-information-about-the-currently-running-function) field. + * Note: Depending on the cloud provider, use: + +* **AWS Lambda:** The function [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html). +Take care not to use the "invoked ARN" directly but replace any +[alias suffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html) with the resolved function version, as the same runtime instance may be invokable with multiple +different aliases. +* **GCP:** The [URI of the resource](https://cloud.google.com/iam/docs/full-resource-names) +* **Azure:** The [Fully Qualified Resource ID](https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id). + +On some providers, it may not be possible to determine the full ID at startup, +which is why this field cannot be made required. For example, on AWS the account ID +part of the ARN is not available without calling another AWS API +which may be deemed too slow for a short-running lambda function. +As an alternative, consider setting `faas.id` as a span attribute instead. */ FAAS_ID: 'faas.id', /** - * The version string of the function being executed as defined in [Version Attributes](../../resource/semantic_conventions/README.md#version-attributes). + * The immutable version of the function being executed. + * + * Note: Depending on the cloud provider and platform, use: + +* **AWS Lambda:** The [function version](https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html) + (an integer represented as a decimal string). +* **Google Cloud Run:** The [revision](https://cloud.google.com/run/docs/managing/revisions) + (i.e., the function name plus the revision suffix). +* **Google Cloud Functions:** The value of the + [`K_REVISION` environment variable](https://cloud.google.com/functions/docs/env-var#runtime_environment_variables_set_automatically). +* **Azure Functions:** Not applicable. Do not set this attribute. */ FAAS_VERSION: 'faas.version', /** - * The execution environment ID as a string. + * The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version. + * + * Note: * **AWS Lambda:** Use the (full) log stream name. */ FAAS_INSTANCE: 'faas.instance', diff --git a/packages/opentelemetry-semantic-conventions/src/resource/index.ts b/packages/opentelemetry-semantic-conventions/src/resource/index.ts index e3810b5eeb..9e9c593f2c 100644 --- a/packages/opentelemetry-semantic-conventions/src/resource/index.ts +++ b/packages/opentelemetry-semantic-conventions/src/resource/index.ts @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export * from './ResourceAttributes'; +export * from './SemanticResourceAttributes'; diff --git a/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts b/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts index 30f20a7b2e..0450508f60 100644 --- a/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts +++ b/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts @@ -17,6 +17,13 @@ // DO NOT EDIT, this is an Auto-generated file from scripts/semconv/templates//templates/SemanticAttributes.ts.j2 export const SemanticAttributes = { + /** + * The full invoked ARN as provided on the `Context` passed to the function (`Lambda-Runtime-Invoked-Function-Arn` header on the `/runtime/invocation/next` applicable). + * + * Note: This may be different from `faas.id` if an alias is involved. + */ + AWS_LAMBDA_INVOKED_ARN: 'aws.lambda.invoked_arn', + /** * An identifier for the database management system (DBMS) product being used. See below for a list of well-known identifiers. */ @@ -608,12 +615,16 @@ clear whether the exception will escape. RPC_SYSTEM: 'rpc.system', /** - * The full name of the service being called, including its package name, if applicable. + * The full (logical) name of the service being called, including its package name, if applicable. + * + * Note: This is the logical name of the service from the RPC interface perspective, which can be different from the name of any implementing class. The `code.namespace` attribute may be used to store the latter (despite the attribute name, it may include a class name; e.g., class with method actually executing the call on the server side, RPC client stub class on the client side). */ RPC_SERVICE: 'rpc.service', /** - * The name of the method being called, must be equal to the $method part in the span name. + * The name of the (logical) method being called, must be equal to the $method part in the span name. + * + * Note: This is the logical name of the method from the RPC interface perspective, which can be different from the name of any implementing method/function. The `code.function` attribute may be used to store the latter (e.g., method actually executing the call on the server side, RPC client stub method on the client side). */ RPC_METHOD: 'rpc.method', @@ -627,11 +638,6 @@ clear whether the exception will escape. */ RPC_JSONRPC_VERSION: 'rpc.jsonrpc.version', - /** - * `method` property from request. Unlike `rpc.method`, this may not relate to the actual method being called. Useful for client-side traces since client does not know what will be called on the server. - */ - RPC_JSONRPC_METHOD: 'rpc.jsonrpc.method', - /** * `id` property of request or response. Since protocol allows id to be int, string, `null` or missing (for notifications), value is expected to be cast to string for simplicity. Use empty string in case of `null` value. Omit entirely if this is a notification. */ diff --git a/packages/opentelemetry-web/test/WebTracerProvider.test.ts b/packages/opentelemetry-web/test/WebTracerProvider.test.ts index 18462a14a6..2c54097b3a 100644 --- a/packages/opentelemetry-web/test/WebTracerProvider.test.ts +++ b/packages/opentelemetry-web/test/WebTracerProvider.test.ts @@ -18,7 +18,7 @@ import { context, ContextManager, trace } from '@opentelemetry/api'; import { ZoneContextManager } from '@opentelemetry/context-zone'; import { B3Propagator } from '@opentelemetry/propagator-b3'; import { Resource } from '@opentelemetry/resources'; -import { ResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import { Span, Tracer } from '@opentelemetry/tracing'; import * as assert from 'assert'; import { WebTracerConfig } from '../src'; @@ -132,7 +132,7 @@ describe('WebTracerProvider', () => { assert.ok(span); assert.ok(span.resource instanceof Resource); assert.equal( - span.resource.attributes[ResourceAttributes.TELEMETRY_SDK_LANGUAGE], + span.resource.attributes[SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE], 'webjs' ); }); diff --git a/scripts/semconv/generate.sh b/scripts/semconv/generate.sh index 96cc1cb90d..f36f62b79a 100755 --- a/scripts/semconv/generate.sh +++ b/scripts/semconv/generate.sh @@ -4,7 +4,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ROOT_DIR="${SCRIPT_DIR}/../../" # freeze the spec version to make SpanAttributess generation reproducible -SPEC_VERSION=v1.4.0 +SPEC_VERSION=v1.5.0 GENERATOR_VERSION=0.3.1 cd ${SCRIPT_DIR} @@ -38,12 +38,10 @@ docker run --rm \ -f /source \ code \ --template /templates/SemanticAttributes.ts.j2 \ - --output /output/ResourceAttributes.ts \ - -Dclass=ResourceAttributes + --output /output/SemanticResourceAttributes.ts \ + -Dclass=SemanticResourceAttributes # Run the automatic linting fixing task to ensure it will pass eslint -cd "$ROOT_DIR/packages/opentelemetry-semantic-conventions" - -npm run lint:fix - cd "$ROOT_DIR" + +npm run lint:fix:changed