From 11719ed943fb2b7713c80d27d67e656cfa4bfc5c Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Wed, 21 Jul 2021 17:44:08 +0300 Subject: [PATCH 1/7] style: use single quotes everywhere and add a rule to eslint (#2351) --- eslint.config.js | 1 + .../src/CollectorExporterNodeBase.ts | 2 +- .../src/CollectorMetricExporter.ts | 2 +- .../src/CollectorTraceExporter.ts | 2 +- .../test/helper.ts | 32 +++++++++---------- .../src/jaeger.ts | 2 +- .../test/jaeger.test.ts | 16 +++++----- .../test/common/autoLoader.test.ts | 2 +- .../test/registration.test.ts | 2 +- .../opentelemetry-sdk-node/test/sdk.test.ts | 12 +++---- .../src/shim.ts | 10 +++--- .../test/Shim.test.ts | 2 +- .../test/common/Tracer.test.ts | 6 ++-- .../test/registration.test.ts | 4 +-- 14 files changed, 48 insertions(+), 47 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index a1514132f9..c78e7b660d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -10,6 +10,7 @@ module.exports = { "project": "./tsconfig.json" }, rules: { + "quotes": [2, "single", { "avoidEscape": true }], "@typescript-eslint/no-floating-promises": 2, "@typescript-eslint/no-this-alias": "off", "brace-style": ["error", "1tbs"], diff --git a/packages/opentelemetry-exporter-collector-grpc/src/CollectorExporterNodeBase.ts b/packages/opentelemetry-exporter-collector-grpc/src/CollectorExporterNodeBase.ts index 0c14f0063b..1ddac9722d 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/CollectorExporterNodeBase.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/CollectorExporterNodeBase.ts @@ -26,7 +26,7 @@ import { ServiceClientType, } from './types'; import { ServiceClient } from './types'; -import { getEnv, baggageUtils } from "@opentelemetry/core"; +import { getEnv, baggageUtils } from '@opentelemetry/core'; /** * Collector Metric Exporter abstract base class diff --git a/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts b/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts index c909241a73..e1c84942cf 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts @@ -23,7 +23,7 @@ import { CollectorExporterConfigNode, ServiceClientType } from './types'; import { CollectorExporterNodeBase } from './CollectorExporterNodeBase'; import { baggageUtils, getEnv } from '@opentelemetry/core'; import { validateAndNormalizeUrl } from './util'; -import { Metadata } from "@grpc/grpc-js"; +import { Metadata } from '@grpc/grpc-js'; const DEFAULT_COLLECTOR_URL = 'localhost:4317'; diff --git a/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts index f0b63cbb79..cfb147fa39 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts @@ -23,7 +23,7 @@ import { import { CollectorExporterConfigNode, ServiceClientType } from './types'; import { baggageUtils, getEnv } from '@opentelemetry/core'; import { validateAndNormalizeUrl } from './util'; -import { Metadata } from "@grpc/grpc-js"; +import { Metadata } from '@grpc/grpc-js'; const DEFAULT_COLLECTOR_URL = 'localhost:4317'; diff --git a/packages/opentelemetry-exporter-collector-grpc/test/helper.ts b/packages/opentelemetry-exporter-collector-grpc/test/helper.ts index 6e66e5a866..b9346c92d0 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/helper.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/helper.ts @@ -410,31 +410,31 @@ export function ensureResourceIsCorrect( assert.deepStrictEqual(resource, { attributes: [ { - "key": "service.name", - "value": { - "stringValue": `unknown_service:${process.argv0}`, - "value": "stringValue" + 'key': 'service.name', + 'value': { + 'stringValue': `unknown_service:${process.argv0}`, + 'value': 'stringValue' } }, { - "key": "telemetry.sdk.language", - "value": { - "stringValue": "nodejs", - "value": "stringValue" + 'key': 'telemetry.sdk.language', + 'value': { + 'stringValue': 'nodejs', + 'value': 'stringValue' } }, { - "key": "telemetry.sdk.name", - "value": { - "stringValue": "opentelemetry", - "value": "stringValue" + 'key': 'telemetry.sdk.name', + 'value': { + 'stringValue': 'opentelemetry', + 'value': 'stringValue' } }, { - "key": "telemetry.sdk.version", - "value": { - "stringValue": VERSION, - "value": "stringValue" + 'key': 'telemetry.sdk.version', + 'value': { + 'stringValue': VERSION, + 'value': 'stringValue' } }, { diff --git a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts index 335767366d..f6514fadd7 100644 --- a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts +++ b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts @@ -156,7 +156,7 @@ export class JaegerExporter implements SpanExporter { } const serviceNameTag = span.tags.find(t => t.key === ResourceAttributes.SERVICE_NAME) - const serviceName = serviceNameTag?.vStr || "unknown_service"; + const serviceName = serviceNameTag?.vStr || 'unknown_service'; sender.setProcess({ serviceName, diff --git a/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts b/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts index 0766e5a72a..b18ea08d36 100644 --- a/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts +++ b/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts @@ -93,8 +93,8 @@ describe('JaegerExporter', () => { const process: ThriftProcess = exporter['_getSender']({ tags: [{ - key: "service.name", - vStr: "opentelemetry" + key: 'service.name', + vStr: 'opentelemetry' }] } as any)._process; assert.strictEqual(exporter['_sender']._host, 'remotehost'); @@ -109,8 +109,8 @@ describe('JaegerExporter', () => { const exporter = new JaegerExporter(); const sender = exporter['_getSender']({ tags: [{ - key: "service.name", - vStr: "opentelemetry" + key: 'service.name', + vStr: 'opentelemetry' }] } as any); assert.strictEqual(sender._host, 'localhost'); @@ -121,8 +121,8 @@ describe('JaegerExporter', () => { const exporter = new JaegerExporter(); const sender = exporter['_getSender']({ tags: [{ - key: "service.name", - vStr: "opentelemetry" + key: 'service.name', + vStr: 'opentelemetry' }] } as any); assert.strictEqual(sender._host, 'env-set-host'); @@ -135,8 +135,8 @@ describe('JaegerExporter', () => { }); const sender = exporter['_getSender']({ tags: [{ - key: "service.name", - vStr: "opentelemetry" + key: 'service.name', + vStr: 'opentelemetry' }] } as any); assert.strictEqual(sender._host, 'option-set-host'); diff --git a/packages/opentelemetry-instrumentation/test/common/autoLoader.test.ts b/packages/opentelemetry-instrumentation/test/common/autoLoader.test.ts index 181eb12c0e..c378f83fe6 100644 --- a/packages/opentelemetry-instrumentation/test/common/autoLoader.test.ts +++ b/packages/opentelemetry-instrumentation/test/common/autoLoader.test.ts @@ -22,7 +22,7 @@ import { InstrumentationBase, registerInstrumentations } from '../../src'; class DummyTracerProvider implements TracerProvider { getTracer(name: string, version?: string): Tracer { - throw new Error("not implemented"); + throw new Error('not implemented'); } } class FooInstrumentation extends InstrumentationBase { diff --git a/packages/opentelemetry-node/test/registration.test.ts b/packages/opentelemetry-node/test/registration.test.ts index e199898a13..4db2d334b4 100644 --- a/packages/opentelemetry-node/test/registration.test.ts +++ b/packages/opentelemetry-node/test/registration.test.ts @@ -78,7 +78,7 @@ describe('API registration', () => { contextManager: null, }); - assert.strictEqual(context['_getContextManager'](), ctxManager, "context manager should not change"); + assert.strictEqual(context['_getContextManager'](), ctxManager, 'context manager should not change'); assert.ok( propagation['_getGlobalPropagator']() instanceof CompositePropagator diff --git a/packages/opentelemetry-sdk-node/test/sdk.test.ts b/packages/opentelemetry-sdk-node/test/sdk.test.ts index 3f80f61678..931a6845d5 100644 --- a/packages/opentelemetry-sdk-node/test/sdk.test.ts +++ b/packages/opentelemetry-sdk-node/test/sdk.test.ts @@ -113,9 +113,9 @@ describe('Node SDK', () => { await sdk.start(); - assert.strictEqual(context['_getContextManager'](), ctxManager, "context manager should not change"); - assert.strictEqual(propagation['_getGlobalPropagator'](), propagator, "propagator should not change"); - assert.strictEqual((trace.getTracerProvider() as ProxyTracerProvider).getDelegate(), delegate, "tracer provider should not have changed"); + assert.strictEqual(context['_getContextManager'](), ctxManager, 'context manager should not change'); + assert.strictEqual(propagation['_getGlobalPropagator'](), propagator, 'propagator should not change'); + assert.strictEqual((trace.getTracerProvider() as ProxyTracerProvider).getDelegate(), delegate, 'tracer provider should not have changed'); assert.ok(metrics.getMeterProvider() instanceof NoopMeterProvider); }); @@ -173,9 +173,9 @@ describe('Node SDK', () => { await sdk.start(); - assert.strictEqual(context['_getContextManager'](), ctxManager, "context manager should not change"); - assert.strictEqual(propagation['_getGlobalPropagator'](), propagator, "propagator should not change"); - assert.strictEqual((trace.getTracerProvider() as ProxyTracerProvider).getDelegate(), delegate, "tracer provider should not have changed"); + assert.strictEqual(context['_getContextManager'](), ctxManager, 'context manager should not change'); + assert.strictEqual(propagation['_getGlobalPropagator'](), propagator, 'propagator should not change'); + assert.strictEqual((trace.getTracerProvider() as ProxyTracerProvider).getDelegate(), delegate, 'tracer provider should not have changed'); assert.ok(metrics.getMeterProvider() instanceof MeterProvider); }); diff --git a/packages/opentelemetry-shim-opentracing/src/shim.ts b/packages/opentelemetry-shim-opentracing/src/shim.ts index 482fe9c56c..e1423d7e88 100644 --- a/packages/opentelemetry-shim-opentracing/src/shim.ts +++ b/packages/opentelemetry-shim-opentracing/src/shim.ts @@ -17,7 +17,7 @@ import * as api from '@opentelemetry/api'; import { SpanAttributes, SpanAttributeValue, SpanStatusCode, TextMapPropagator } from '@opentelemetry/api'; import * as opentracing from 'opentracing'; -import { SemanticAttributes } from "@opentelemetry/semantic-conventions"; +import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; function translateReferences(references: opentracing.Reference[]): api.Link[] { const links: api.Link[] = []; @@ -301,7 +301,7 @@ export class SpanShim extends opentracing.Span { const entries = Object.entries(attributes); const errorEntry = entries.find(([key]) => key === 'error.object'); const error = errorEntry?.[1]; - if (typeof error === "string") { + if (typeof error === 'string') { this._span.recordException(error, timestamp); return; } @@ -309,15 +309,15 @@ export class SpanShim extends opentracing.Span { const mappedAttributes: api.SpanAttributes = {}; for (const [k, v] of entries) { switch (k) { - case "error.kind": { + case 'error.kind': { mappedAttributes[SemanticAttributes.EXCEPTION_TYPE] = v; break; } - case "message": { + case 'message': { mappedAttributes[SemanticAttributes.EXCEPTION_MESSAGE] = v; break; } - case "stack": { + case 'stack': { mappedAttributes[SemanticAttributes.EXCEPTION_STACKTRACE] = v; break; } diff --git a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts index 882ebe3ca1..321f25359c 100644 --- a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts +++ b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts @@ -36,7 +36,7 @@ import { import { performance } from 'perf_hooks'; import { B3Propagator } from '@opentelemetry/propagator-b3'; import { JaegerPropagator } from '@opentelemetry/propagator-jaeger'; -import { SemanticAttributes } from "@opentelemetry/semantic-conventions"; +import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; describe('OpenTracing Shim', () => { const compositePropagator = new CompositePropagator({ diff --git a/packages/opentelemetry-tracing/test/common/Tracer.test.ts b/packages/opentelemetry-tracing/test/common/Tracer.test.ts index 30180ef468..b0e56c2161 100644 --- a/packages/opentelemetry-tracing/test/common/Tracer.test.ts +++ b/packages/opentelemetry-tracing/test/common/Tracer.test.ts @@ -238,7 +238,7 @@ describe('Tracer', () => { tracerProvider ); - const spy = sinon.spy(tracer, "startSpan"); + const spy = sinon.spy(tracer, 'startSpan'); assert.strictEqual(tracer.startActiveSpan('my-span', span => { try { @@ -259,7 +259,7 @@ describe('Tracer', () => { tracerProvider ); - const spy = sinon.spy(tracer, "startSpan"); + const spy = sinon.spy(tracer, 'startSpan'); assert.strictEqual(tracer.startActiveSpan('my-span', {attributes: {foo: 'bar'}}, span => { try { @@ -283,7 +283,7 @@ describe('Tracer', () => { const ctx = context.active().setValue(ctxKey, 'bar') - const spy = sinon.spy(tracer, "startSpan"); + const spy = sinon.spy(tracer, 'startSpan'); assert.strictEqual(tracer.startActiveSpan('my-span', {attributes: {foo: 'bar'}}, ctx, span => { try { diff --git a/packages/opentelemetry-web/test/registration.test.ts b/packages/opentelemetry-web/test/registration.test.ts index baab6a4d77..e2c497883c 100644 --- a/packages/opentelemetry-web/test/registration.test.ts +++ b/packages/opentelemetry-web/test/registration.test.ts @@ -68,7 +68,7 @@ describe('API registration', () => { contextManager: null, }); - assert.strictEqual(context['_getContextManager'](), ctxManager, "context manager should not change"); + assert.strictEqual(context['_getContextManager'](), ctxManager, 'context manager should not change'); assert.ok( propagation['_getGlobalPropagator']() instanceof CompositePropagator @@ -84,7 +84,7 @@ describe('API registration', () => { propagator: null, }); - assert.strictEqual(propagation["_getGlobalPropagator"](), propagator, "propagator should not change") + assert.strictEqual(propagation['_getGlobalPropagator'](), propagator, 'propagator should not change') assert.ok(context['_getContextManager']() instanceof StackContextManager); const apiTracerProvider = trace.getTracerProvider() as ProxyTracerProvider; From c55142f88a1bca6999e9ac3d3463f312f1525b42 Mon Sep 17 00:00:00 2001 From: Liz Fong-Jones Date: Wed, 21 Jul 2021 11:40:48 -0400 Subject: [PATCH 2/7] fix(@opentelemetry/exporter-collector-grpc) regression from #2130 when host specified without protocol (#2322) * fix regression from #2130 when host specified without protocol * Update util.test.ts * Apply suggestions from code review Co-authored-by: Naseem * revert package.json changes * Update util.ts * add tests as per @msnev request * Update packages/opentelemetry-exporter-collector-grpc/src/util.ts Co-authored-by: Naseem Co-authored-by: Naseem --- .../src/util.ts | 6 +- .../test/util.test.ts | 81 +++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 packages/opentelemetry-exporter-collector-grpc/test/util.test.ts diff --git a/packages/opentelemetry-exporter-collector-grpc/src/util.ts b/packages/opentelemetry-exporter-collector-grpc/src/util.ts index 39330afc3b..299a6e7e81 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/util.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/util.ts @@ -108,8 +108,12 @@ export function send( } export function validateAndNormalizeUrl(url: string): string { + const hasProtocol = url.match(/^([\w]{1,8}):\/\//); + if (!hasProtocol) { + url = `https://${url}`; + } const target = new URL(url); - if (target.pathname !== '/') { + if (target.pathname && target.pathname !== '/') { diag.warn( 'URL path should not be set when using grpc, the path part of the URL will be ignored.' ); diff --git a/packages/opentelemetry-exporter-collector-grpc/test/util.test.ts b/packages/opentelemetry-exporter-collector-grpc/test/util.test.ts new file mode 100644 index 0000000000..ba08009cd5 --- /dev/null +++ b/packages/opentelemetry-exporter-collector-grpc/test/util.test.ts @@ -0,0 +1,81 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as sinon from 'sinon'; +import * as assert from 'assert'; + +import { diag } from '@opentelemetry/api'; +import { validateAndNormalizeUrl } from '../src/util'; + +// Tests added to detect breakage released in #2130 +describe('validateAndNormalizeUrl()', () => { + const tests = [ + { + name: 'bare hostname should return same value', + input: 'api.datacat.io', + expected: 'api.datacat.io', + }, + { + name: 'host:port should return same value', + input: 'api.datacat.io:1234', + expected: 'api.datacat.io:1234', + }, + { + name: 'grpc://host:port should trim off protocol', + input: 'grpc://api.datacat.io:1234', + expected: 'api.datacat.io:1234', + }, + { + name: 'bad protocol should warn but return host:port', + input: 'badproto://api.datacat.io:1234', + expected: 'api.datacat.io:1234', + warn: 'URL protocol should be http(s):// or grpc(s)://. Using grpc://.', + }, + { + name: 'path on end of url should warn but return host:port', + input: 'grpc://api.datacat.io:1234/a/b/c', + expected: 'api.datacat.io:1234', + warn: 'URL path should not be set when using grpc, the path part of the URL will be ignored.', + }, + { + name: ':// in path should not be used for protocol even if protocol not specified', + input: 'api.datacat.io/a/b://c', + expected: 'api.datacat.io', + warn: 'URL path should not be set when using grpc, the path part of the URL will be ignored.', + }, + { + name: ':// in path is valid when a protocol is specified', + input: 'grpc://api.datacat.io/a/b://c', + expected: 'api.datacat.io', + warn: 'URL path should not be set when using grpc, the path part of the URL will be ignored.', + }, + ]; + tests.forEach(test => { + it(test.name, () => { + const diagWarn = sinon.stub(diag, 'warn'); + try { + assert.strictEqual(validateAndNormalizeUrl(test.input), (test.expected)); + if (test.warn) { + sinon.assert.calledWith(diagWarn, test.warn); + } else { + sinon.assert.notCalled(diagWarn); + } + } finally { + diagWarn.restore(); + } + }); + }); +}); From cb06b788b27ff080326b74bf4c3d08f419a06529 Mon Sep 17 00:00:00 2001 From: Niko Achilles Kokkinos Date: Wed, 21 Jul 2021 18:57:23 +0300 Subject: [PATCH 3/7] fix: headers are appended to existing one (open-telemetry#2335) (#2357) * fix: headers are appended to existing one (open-telemetry#2335) * test(browser-util): added 2 more test-cases refactored desc, it wording * test: split tests review * fix: review headers are appended to existing one (open-telemetry#2335) * test: review DRY * fix: review lint Co-authored-by: Valentin Marchaud Co-authored-by: Daniel Dyla --- .../src/platform/browser/util.ts | 13 +- .../test/browser/util.test.ts | 128 ++++++++++++++++++ 2 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 packages/opentelemetry-exporter-collector/test/browser/util.test.ts diff --git a/packages/opentelemetry-exporter-collector/src/platform/browser/util.ts b/packages/opentelemetry-exporter-collector/src/platform/browser/util.ts index a695ee6944..5c57517235 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/browser/util.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/browser/util.ts @@ -55,9 +55,16 @@ export function sendWithXhr( ) { const xhr = new XMLHttpRequest(); xhr.open('POST', url); - xhr.setRequestHeader('Accept', 'application/json'); - xhr.setRequestHeader('Content-Type', 'application/json'); - Object.entries(headers).forEach(([k, v]) => { + + const defaultHeaders = { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }; + + Object.entries({ + ...defaultHeaders, + ...headers, + }).forEach(([k, v]) => { xhr.setRequestHeader(k, v); }); diff --git a/packages/opentelemetry-exporter-collector/test/browser/util.test.ts b/packages/opentelemetry-exporter-collector/test/browser/util.test.ts new file mode 100644 index 0000000000..ecb6c4c801 --- /dev/null +++ b/packages/opentelemetry-exporter-collector/test/browser/util.test.ts @@ -0,0 +1,128 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as sinon from 'sinon'; +import { sendWithXhr } from '../../src/platform/browser/util'; +import { ensureHeadersContain } from '../helper'; + +describe('util - browser', () => { + let server: any; + const body = ''; + const url = ''; + + let onSuccessStub: sinon.SinonStub; + let onErrorStub: sinon.SinonStub; + + beforeEach(() => { + onSuccessStub = sinon.stub(); + onErrorStub = sinon.stub(); + server = sinon.fakeServer.create(); + }); + + afterEach(() => { + server.restore(); + sinon.restore(); + }); + + describe('when XMLHTTPRequest is used', () => { + let expectedHeaders: Record; + beforeEach(()=>{ + expectedHeaders = { + // ;charset=utf-8 is applied by sinon.fakeServer + 'Content-Type': 'application/json;charset=utf-8', + 'Accept': 'application/json', + } + }); + describe('and Content-Type header is set', () => { + beforeEach(()=>{ + const explicitContentType = { + 'Content-Type': 'application/json', + }; + sendWithXhr(body, url, explicitContentType, onSuccessStub, onErrorStub); + }); + it('Request Headers should contain "Content-Type" header', done => { + + setTimeout(() => { + const { requestHeaders } = server.requests[0]; + ensureHeadersContain(requestHeaders, expectedHeaders); + done(); + }); + }); + it('Request Headers should contain "Accept" header', done => { + + setTimeout(() => { + const { requestHeaders } = server.requests[0]; + ensureHeadersContain(requestHeaders, expectedHeaders); + done(); + }); + }); + }); + + describe('and empty headers are set', () => { + beforeEach(()=>{ + const emptyHeaders = {}; + sendWithXhr(body, url, emptyHeaders, onSuccessStub, onErrorStub); + }); + it('Request Headers should contain "Content-Type" header', done => { + + setTimeout(() => { + const { requestHeaders } = server.requests[0]; + ensureHeadersContain(requestHeaders, expectedHeaders); + done(); + }); + }); + it('Request Headers should contain "Accept" header', done => { + + setTimeout(() => { + const { requestHeaders } = server.requests[0]; + ensureHeadersContain(requestHeaders, expectedHeaders); + done(); + }); + }); + }); + describe('and custom headers are set', () => { + let customHeaders: Record; + beforeEach(()=>{ + customHeaders = { aHeader: 'aValue', bHeader: 'bValue' }; + sendWithXhr(body, url, customHeaders, onSuccessStub, onErrorStub); + }); + it('Request Headers should contain "Content-Type" header', done => { + + setTimeout(() => { + const { requestHeaders } = server.requests[0]; + ensureHeadersContain(requestHeaders, expectedHeaders); + done(); + }); + }); + it('Request Headers should contain "Accept" header', done => { + + setTimeout(() => { + const { requestHeaders } = server.requests[0]; + ensureHeadersContain(requestHeaders, expectedHeaders); + done(); + }); + }); + it('Request Headers should contain custom headers', done => { + + setTimeout(() => { + const { requestHeaders } = server.requests[0]; + ensureHeadersContain(requestHeaders, customHeaders); + done(); + }); + }); + }); + }); +}); From 39c6ea52fa51721b56b578886b28d5afb9d5ee90 Mon Sep 17 00:00:00 2001 From: Ofer Adelstein <12687466+CptSchnitz@users.noreply.github.com> Date: Wed, 21 Jul 2021 22:52:28 +0300 Subject: [PATCH 4/7] examples opentelemetry-api version fix (#2358) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gerhard Stöbich Co-authored-by: Daniel Dyla --- examples/basic-tracer-node/package.json | 2 +- examples/collector-exporter-node/README.md | 4 ++-- examples/collector-exporter-node/package.json | 2 +- examples/grpc-js/package.json | 2 +- examples/grpc/package.json | 2 +- examples/http/package.json | 2 +- examples/https/package.json | 2 +- examples/metrics/package.json | 1 + examples/opentracing-shim/package.json | 1 + examples/prometheus/package.json | 1 + examples/tracer-web/package.json | 2 +- 11 files changed, 12 insertions(+), 9 deletions(-) diff --git a/examples/basic-tracer-node/package.json b/examples/basic-tracer-node/package.json index c26b35b03c..be9ed25981 100644 --- a/examples/basic-tracer-node/package.json +++ b/examples/basic-tracer-node/package.json @@ -24,7 +24,7 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^1.0.0", + "@opentelemetry/api": "^1.0.1", "@opentelemetry/exporter-jaeger": "0.23.0", "@opentelemetry/tracing": "0.23.0" }, diff --git a/examples/collector-exporter-node/README.md b/examples/collector-exporter-node/README.md index 2b30ff8246..543514476b 100644 --- a/examples/collector-exporter-node/README.md +++ b/examples/collector-exporter-node/README.md @@ -24,14 +24,14 @@ npm install ```shell script # from this directory - npm start:tracing + npm run start:tracing ``` 3. Run metrics app ```shell script # from this directory - npm start:metrics + npm run start:metrics ``` 4. Open page at - you should be able to see the spans in zipkin diff --git a/examples/collector-exporter-node/package.json b/examples/collector-exporter-node/package.json index cfdd88b4c8..e0c2619d3c 100644 --- a/examples/collector-exporter-node/package.json +++ b/examples/collector-exporter-node/package.json @@ -28,7 +28,7 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^1.0.0", + "@opentelemetry/api": "^1.0.1", "@opentelemetry/core": "0.23.0", "@opentelemetry/exporter-collector": "0.23.0", "@opentelemetry/exporter-collector-grpc": "0.23.0", diff --git a/examples/grpc-js/package.json b/examples/grpc-js/package.json index 514d0d257b..a6b5de42fe 100644 --- a/examples/grpc-js/package.json +++ b/examples/grpc-js/package.json @@ -29,7 +29,7 @@ }, "dependencies": { "@grpc/grpc-js": "^1.2.12", - "@opentelemetry/api": "^1.0.0", + "@opentelemetry/api": "^1.0.1", "@opentelemetry/exporter-jaeger": "0.23.0", "@opentelemetry/exporter-zipkin": "0.23.0", "@opentelemetry/instrumentation": "0.23.0", diff --git a/examples/grpc/package.json b/examples/grpc/package.json index 52dfccd049..5dc7d8be2d 100644 --- a/examples/grpc/package.json +++ b/examples/grpc/package.json @@ -28,7 +28,7 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^1.0.0", + "@opentelemetry/api": "^1.0.1", "@opentelemetry/exporter-jaeger": "0.23.0", "@opentelemetry/exporter-zipkin": "0.23.0", "@opentelemetry/instrumentation": "0.23.0", diff --git a/examples/http/package.json b/examples/http/package.json index b772babad9..e8ecd44f7c 100644 --- a/examples/http/package.json +++ b/examples/http/package.json @@ -28,7 +28,7 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^1.0.0", + "@opentelemetry/api": "^1.0.1", "@opentelemetry/exporter-jaeger": "0.23.0", "@opentelemetry/exporter-zipkin": "0.23.0", "@opentelemetry/instrumentation": "0.23.0", diff --git a/examples/https/package.json b/examples/https/package.json index 37e53c7cec..12b4458df6 100644 --- a/examples/https/package.json +++ b/examples/https/package.json @@ -29,7 +29,7 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^1.0.0", + "@opentelemetry/api": "^1.0.1", "@opentelemetry/exporter-jaeger": "0.23.0", "@opentelemetry/exporter-zipkin": "0.23.0", "@opentelemetry/instrumentation": "0.23.0", diff --git a/examples/metrics/package.json b/examples/metrics/package.json index 568a471eff..804f95b858 100644 --- a/examples/metrics/package.json +++ b/examples/metrics/package.json @@ -26,6 +26,7 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { + "@opentelemetry/api": "^1.0.1", "@opentelemetry/core": "0.23.0", "@opentelemetry/exporter-prometheus": "0.23.0", "@opentelemetry/metrics": "0.23.0" diff --git a/examples/opentracing-shim/package.json b/examples/opentracing-shim/package.json index 656e2cec62..cd1c1b92f2 100644 --- a/examples/opentracing-shim/package.json +++ b/examples/opentracing-shim/package.json @@ -29,6 +29,7 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { + "@opentelemetry/api": "^1.0.1", "@opentelemetry/exporter-jaeger": "0.23.0", "@opentelemetry/exporter-zipkin": "0.23.0", "@opentelemetry/instrumentation": "0.23.0", diff --git a/examples/prometheus/package.json b/examples/prometheus/package.json index 299f871743..2d84ce5a4c 100644 --- a/examples/prometheus/package.json +++ b/examples/prometheus/package.json @@ -9,6 +9,7 @@ "author": "OpenTelemetry Authors", "license": "Apache-2.0", "dependencies": { + "@opentelemetry/api": "^1.0.1", "@opentelemetry/exporter-prometheus": "0.23.0", "@opentelemetry/metrics": "0.23.0" } diff --git a/examples/tracer-web/package.json b/examples/tracer-web/package.json index e35b311552..43589bc5ee 100644 --- a/examples/tracer-web/package.json +++ b/examples/tracer-web/package.json @@ -34,7 +34,7 @@ "webpack-merge": "^4.2.2" }, "dependencies": { - "@opentelemetry/api": "^1.0.0", + "@opentelemetry/api": "^1.0.1", "@opentelemetry/context-zone": "0.23.0", "@opentelemetry/core": "0.23.0", "@opentelemetry/exporter-collector": "0.23.0", From b613a2a10e783caa2bcf3b165bc369a6b3653880 Mon Sep 17 00:00:00 2001 From: Bartlomiej Obecny Date: Thu, 22 Jul 2021 10:34:47 +0200 Subject: [PATCH 5/7] chore: adding Rauno56 to js approvers (#2366) Co-authored-by: Daniel Dyla Co-authored-by: Valentin Marchaud --- .github/CODEOWNERS | 2 +- README.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 17ec720284..82a1493dab 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -12,4 +12,4 @@ # https://help.github.com/en/articles/about-code-owners # -* @dyladan @mayurkale22 @OlivierAlbertini @vmarchaud @markwolff @obecny @mwear @naseemkullah @legendecas @Flarna @johnbley @MSNev +* @dyladan @mayurkale22 @OlivierAlbertini @vmarchaud @markwolff @obecny @mwear @naseemkullah @legendecas @Flarna @johnbley @MSNev @Rauno56 diff --git a/README.md b/README.md index ce59d523d2..dcc83ace99 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ Approvers ([@open-telemetry/js-approvers](https://github.com/orgs/open-telemetry - [Naseem K. Ullah](https://github.com/naseemkullah), Transit - [Neville Wylie](https://github.com/MSNev), Microsoft - [Olivier Albertini](https://github.com/OlivierAlbertini), Ville de Montréal +- [Rauno Viskus](https://github.com/Rauno56), Splunk *Find more about the approver role in [community repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver).* From 884d20ab417bf0283ec84a72b9a0fae8ebcb82a1 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 23 Jul 2021 19:37:18 +0200 Subject: [PATCH 6/7] chore(deps): update all non-major dependencies (#2372) --- package.json | 10 +++++----- packages/opentelemetry-api-metrics/package.json | 2 +- .../opentelemetry-context-async-hooks/package.json | 2 +- .../opentelemetry-context-zone-peer-dep/package.json | 4 ++-- packages/opentelemetry-context-zone/package.json | 4 ++-- packages/opentelemetry-core/package.json | 2 +- .../opentelemetry-exporter-collector-grpc/package.json | 4 ++-- .../package.json | 4 ++-- packages/opentelemetry-exporter-collector/package.json | 4 ++-- packages/opentelemetry-exporter-jaeger/package.json | 2 +- .../opentelemetry-exporter-prometheus/package.json | 2 +- packages/opentelemetry-exporter-zipkin/package.json | 4 ++-- .../opentelemetry-instrumentation-fetch/package.json | 4 ++-- .../opentelemetry-instrumentation-grpc/package.json | 4 ++-- .../opentelemetry-instrumentation-http/package.json | 2 +- .../package.json | 4 ++-- packages/opentelemetry-instrumentation/package.json | 4 ++-- packages/opentelemetry-metrics/package.json | 2 +- packages/opentelemetry-node/package.json | 2 +- packages/opentelemetry-propagator-b3/package.json | 2 +- packages/opentelemetry-propagator-jaeger/package.json | 2 +- .../opentelemetry-resource-detector-aws/package.json | 2 +- .../opentelemetry-resource-detector-gcp/package.json | 2 +- packages/opentelemetry-resources/package.json | 2 +- packages/opentelemetry-sdk-node/package.json | 2 +- .../opentelemetry-semantic-conventions/package.json | 2 +- packages/opentelemetry-shim-opentracing/package.json | 2 +- packages/opentelemetry-tracing/package.json | 2 +- packages/opentelemetry-web/package.json | 4 ++-- 29 files changed, 44 insertions(+), 44 deletions(-) diff --git a/package.json b/package.json index 840a023215..6b40ff613c 100644 --- a/package.json +++ b/package.json @@ -47,11 +47,11 @@ "devDependencies": { "@commitlint/cli": "12.1.4", "@commitlint/config-conventional": "12.1.4", - "@typescript-eslint/eslint-plugin": "4.28.3", - "@typescript-eslint/parser": "4.28.3", + "@typescript-eslint/eslint-plugin": "4.28.4", + "@typescript-eslint/parser": "4.28.4", "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "7.30.0", + "eslint": "7.31.0", "eslint-config-airbnb-base": "14.2.1", "eslint-plugin-header": "3.1.1", "eslint-plugin-import": "2.23.4", @@ -60,8 +60,8 @@ "husky": "4.3.8", "lerna": "3.22.1", "lerna-changelog": "1.0.1", - "markdownlint-cli": "0.27.1", - "typedoc": "0.21.2", + "markdownlint-cli": "0.28.1", + "typedoc": "0.21.4", "typescript": "4.3.5", "update-ts-references": "2.4.0" }, diff --git a/packages/opentelemetry-api-metrics/package.json b/packages/opentelemetry-api-metrics/package.json index ebb9f89aae..7a8c8937d2 100644 --- a/packages/opentelemetry-api-metrics/package.json +++ b/packages/opentelemetry-api-metrics/package.json @@ -60,7 +60,7 @@ "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/webpack-env": "1.16.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-context-async-hooks/package.json b/packages/opentelemetry-context-async-hooks/package.json index 5f875a6a1b..991872c538 100644 --- a/packages/opentelemetry-context-async-hooks/package.json +++ b/packages/opentelemetry-context-async-hooks/package.json @@ -44,7 +44,7 @@ "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/shimmer": "1.0.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", diff --git a/packages/opentelemetry-context-zone-peer-dep/package.json b/packages/opentelemetry-context-zone-peer-dep/package.json index 745138208a..2e059f9e21 100644 --- a/packages/opentelemetry-context-zone-peer-dep/package.json +++ b/packages/opentelemetry-context-zone-peer-dep/package.json @@ -45,7 +45,7 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.14.6", + "@babel/core": "7.14.8", "@opentelemetry/api": "^1.0.1", "@types/mocha": "8.2.3", "@types/node": "14.17.5", @@ -53,7 +53,7 @@ "@types/webpack-env": "1.16.2", "@types/zone.js": "0.5.12", "babel-loader": "8.2.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-context-zone/package.json b/packages/opentelemetry-context-zone/package.json index 3bf77bd48f..9ec67d3b21 100644 --- a/packages/opentelemetry-context-zone/package.json +++ b/packages/opentelemetry-context-zone/package.json @@ -42,13 +42,13 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.14.6", + "@babel/core": "7.14.8", "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", "babel-loader": "8.2.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", "karma-mocha": "2.0.1", diff --git a/packages/opentelemetry-core/package.json b/packages/opentelemetry-core/package.json index 1359caf4a9..806faf37b5 100644 --- a/packages/opentelemetry-core/package.json +++ b/packages/opentelemetry-core/package.json @@ -61,7 +61,7 @@ "@types/semver": "7.3.7", "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-exporter-collector-grpc/package.json b/packages/opentelemetry-exporter-collector-grpc/package.json index aa36b4a5fe..ab0d37d9a2 100644 --- a/packages/opentelemetry-exporter-collector-grpc/package.json +++ b/packages/opentelemetry-exporter-collector-grpc/package.json @@ -45,13 +45,13 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.14.6", + "@babel/core": "7.14.8", "@opentelemetry/api": "^1.0.1", "@opentelemetry/api-metrics": "0.23.0", "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/sinon": "10.0.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "cpx": "1.5.0", "mocha": "7.2.0", "nyc": "15.1.0", diff --git a/packages/opentelemetry-exporter-collector-proto/package.json b/packages/opentelemetry-exporter-collector-proto/package.json index b3aaea5eb2..2cbb673997 100644 --- a/packages/opentelemetry-exporter-collector-proto/package.json +++ b/packages/opentelemetry-exporter-collector-proto/package.json @@ -45,13 +45,13 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.14.6", + "@babel/core": "7.14.8", "@opentelemetry/api": "^1.0.1", "@opentelemetry/api-metrics": "0.23.0", "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/sinon": "10.0.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "cpx": "1.5.0", "mocha": "7.2.0", "nyc": "15.1.0", diff --git a/packages/opentelemetry-exporter-collector/package.json b/packages/opentelemetry-exporter-collector/package.json index ef5bc3fa9b..ec2fcffe73 100644 --- a/packages/opentelemetry-exporter-collector/package.json +++ b/packages/opentelemetry-exporter-collector/package.json @@ -53,14 +53,14 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.14.6", + "@babel/core": "7.14.8", "@opentelemetry/api": "^1.0.1", "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", "babel-loader": "8.2.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "cpx": "1.5.0", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", diff --git a/packages/opentelemetry-exporter-jaeger/package.json b/packages/opentelemetry-exporter-jaeger/package.json index b3e9e726f0..e1f77bcb92 100644 --- a/packages/opentelemetry-exporter-jaeger/package.json +++ b/packages/opentelemetry-exporter-jaeger/package.json @@ -45,7 +45,7 @@ "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/sinon": "10.0.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "mocha": "7.2.0", "nock": "12.0.3", "nyc": "15.1.0", diff --git a/packages/opentelemetry-exporter-prometheus/package.json b/packages/opentelemetry-exporter-prometheus/package.json index 1ebf9411f5..1f02b1f82e 100644 --- a/packages/opentelemetry-exporter-prometheus/package.json +++ b/packages/opentelemetry-exporter-prometheus/package.json @@ -43,7 +43,7 @@ "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/sinon": "10.0.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", diff --git a/packages/opentelemetry-exporter-zipkin/package.json b/packages/opentelemetry-exporter-zipkin/package.json index cdab7efd5b..2735915402 100644 --- a/packages/opentelemetry-exporter-zipkin/package.json +++ b/packages/opentelemetry-exporter-zipkin/package.json @@ -51,14 +51,14 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.14.6", + "@babel/core": "7.14.8", "@opentelemetry/api": "^1.0.1", "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", "babel-loader": "8.2.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-instrumentation-fetch/package.json b/packages/opentelemetry-instrumentation-fetch/package.json index 053630adc4..c85bbaf951 100644 --- a/packages/opentelemetry-instrumentation-fetch/package.json +++ b/packages/opentelemetry-instrumentation-fetch/package.json @@ -46,7 +46,7 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.14.6", + "@babel/core": "7.14.8", "@opentelemetry/api": "^1.0.1", "@opentelemetry/context-zone": "0.23.0", "@opentelemetry/propagator-b3": "0.23.0", @@ -57,7 +57,7 @@ "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", "babel-loader": "8.2.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-instrumentation-grpc/package.json b/packages/opentelemetry-instrumentation-grpc/package.json index 27ad6cccbb..2d40eb7794 100644 --- a/packages/opentelemetry-instrumentation-grpc/package.json +++ b/packages/opentelemetry-instrumentation-grpc/package.json @@ -41,7 +41,7 @@ "access": "public" }, "devDependencies": { - "@grpc/grpc-js": "1.3.5", + "@grpc/grpc-js": "1.3.6", "@grpc/proto-loader": "0.6.4", "@opentelemetry/api": "^1.0.1", "@opentelemetry/context-async-hooks": "0.23.0", @@ -53,7 +53,7 @@ "@types/semver": "7.3.7", "@types/shimmer": "1.0.2", "@types/sinon": "10.0.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "grpc": "1.24.10", "mocha": "7.2.0", "node-pre-gyp": "0.17.0", diff --git a/packages/opentelemetry-instrumentation-http/package.json b/packages/opentelemetry-instrumentation-http/package.json index fb7dc859a4..f388701d65 100644 --- a/packages/opentelemetry-instrumentation-http/package.json +++ b/packages/opentelemetry-instrumentation-http/package.json @@ -53,7 +53,7 @@ "@types/sinon": "10.0.2", "@types/superagent": "4.1.12", "axios": "0.21.1", - "codecov": "3.8.2", + "codecov": "3.8.3", "got": "9.6.0", "mocha": "7.2.0", "nock": "12.0.3", diff --git a/packages/opentelemetry-instrumentation-xml-http-request/package.json b/packages/opentelemetry-instrumentation-xml-http-request/package.json index 7ecb4236e7..ab799e64c0 100644 --- a/packages/opentelemetry-instrumentation-xml-http-request/package.json +++ b/packages/opentelemetry-instrumentation-xml-http-request/package.json @@ -46,7 +46,7 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.14.6", + "@babel/core": "7.14.8", "@opentelemetry/api": "^1.0.1", "@opentelemetry/context-zone": "0.23.0", "@opentelemetry/propagator-b3": "0.23.0", @@ -56,7 +56,7 @@ "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", "babel-loader": "8.2.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-instrumentation/package.json b/packages/opentelemetry-instrumentation/package.json index 81345ed5d6..d3e99d311a 100644 --- a/packages/opentelemetry-instrumentation/package.json +++ b/packages/opentelemetry-instrumentation/package.json @@ -68,7 +68,7 @@ "@opentelemetry/api": "^1.0.1" }, "devDependencies": { - "@babel/core": "7.14.6", + "@babel/core": "7.14.8", "@opentelemetry/api": "^1.0.1", "@types/mocha": "8.2.3", "@types/node": "14.17.5", @@ -77,7 +77,7 @@ "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", "babel-loader": "8.2.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "cpx": "1.5.0", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", diff --git a/packages/opentelemetry-metrics/package.json b/packages/opentelemetry-metrics/package.json index 64f8962785..3cc763316d 100644 --- a/packages/opentelemetry-metrics/package.json +++ b/packages/opentelemetry-metrics/package.json @@ -49,7 +49,7 @@ "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/sinon": "10.0.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", diff --git a/packages/opentelemetry-node/package.json b/packages/opentelemetry-node/package.json index d3bb4929fd..996f985d8d 100644 --- a/packages/opentelemetry-node/package.json +++ b/packages/opentelemetry-node/package.json @@ -49,7 +49,7 @@ "@types/semver": "7.3.7", "@types/shimmer": "1.0.2", "@types/sinon": "10.0.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", diff --git a/packages/opentelemetry-propagator-b3/package.json b/packages/opentelemetry-propagator-b3/package.json index 2d52f69d15..57c739ea94 100644 --- a/packages/opentelemetry-propagator-b3/package.json +++ b/packages/opentelemetry-propagator-b3/package.json @@ -52,7 +52,7 @@ "@opentelemetry/api": "^1.0.1", "@types/mocha": "8.2.3", "@types/node": "14.17.5", - "codecov": "3.8.2", + "codecov": "3.8.3", "istanbul-instrumenter-loader": "3.0.1", "mocha": "7.2.0", "nyc": "15.1.0", diff --git a/packages/opentelemetry-propagator-jaeger/package.json b/packages/opentelemetry-propagator-jaeger/package.json index 5014b8e070..5b32fcc016 100644 --- a/packages/opentelemetry-propagator-jaeger/package.json +++ b/packages/opentelemetry-propagator-jaeger/package.json @@ -52,7 +52,7 @@ "@types/node": "14.17.5", "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-resource-detector-aws/package.json b/packages/opentelemetry-resource-detector-aws/package.json index ff95bd96c7..248081b7b5 100644 --- a/packages/opentelemetry-resource-detector-aws/package.json +++ b/packages/opentelemetry-resource-detector-aws/package.json @@ -43,7 +43,7 @@ "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/sinon": "10.0.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "mocha": "7.2.0", "nock": "12.0.3", "nyc": "15.1.0", diff --git a/packages/opentelemetry-resource-detector-gcp/package.json b/packages/opentelemetry-resource-detector-gcp/package.json index ca0bf0bbc6..42dbba0009 100644 --- a/packages/opentelemetry-resource-detector-gcp/package.json +++ b/packages/opentelemetry-resource-detector-gcp/package.json @@ -44,7 +44,7 @@ "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/semver": "7.3.7", - "codecov": "3.8.2", + "codecov": "3.8.3", "mocha": "7.2.0", "nock": "12.0.3", "nyc": "15.1.0", diff --git a/packages/opentelemetry-resources/package.json b/packages/opentelemetry-resources/package.json index edc5c02c95..707630f99d 100644 --- a/packages/opentelemetry-resources/package.json +++ b/packages/opentelemetry-resources/package.json @@ -52,7 +52,7 @@ "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/sinon": "10.0.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "mocha": "7.2.0", "nock": "12.0.3", "nyc": "15.1.0", diff --git a/packages/opentelemetry-sdk-node/package.json b/packages/opentelemetry-sdk-node/package.json index 96b79f2ae0..4a84a603d3 100644 --- a/packages/opentelemetry-sdk-node/package.json +++ b/packages/opentelemetry-sdk-node/package.json @@ -60,7 +60,7 @@ "@types/node": "14.17.5", "@types/semver": "7.3.7", "@types/sinon": "10.0.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "gcp-metadata": "^4.1.4", "istanbul-instrumenter-loader": "3.0.1", "mocha": "7.2.0", diff --git a/packages/opentelemetry-semantic-conventions/package.json b/packages/opentelemetry-semantic-conventions/package.json index a543ce6f00..060d01e943 100644 --- a/packages/opentelemetry-semantic-conventions/package.json +++ b/packages/opentelemetry-semantic-conventions/package.json @@ -46,7 +46,7 @@ "@types/mocha": "8.2.3", "@types/node": "14.17.5", "@types/sinon": "10.0.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "mocha": "7.2.0", "nock": "12.0.3", "nyc": "15.1.0", diff --git a/packages/opentelemetry-shim-opentracing/package.json b/packages/opentelemetry-shim-opentracing/package.json index 96684b480c..8a62cb1830 100644 --- a/packages/opentelemetry-shim-opentracing/package.json +++ b/packages/opentelemetry-shim-opentracing/package.json @@ -44,7 +44,7 @@ "@opentelemetry/tracing": "0.23.0", "@types/mocha": "8.2.3", "@types/node": "14.17.5", - "codecov": "3.8.2", + "codecov": "3.8.3", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", diff --git a/packages/opentelemetry-tracing/package.json b/packages/opentelemetry-tracing/package.json index 2679898709..de1560dfbd 100644 --- a/packages/opentelemetry-tracing/package.json +++ b/packages/opentelemetry-tracing/package.json @@ -59,7 +59,7 @@ "@types/node": "14.17.5", "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", diff --git a/packages/opentelemetry-web/package.json b/packages/opentelemetry-web/package.json index ae2a258319..5e0625ba8e 100644 --- a/packages/opentelemetry-web/package.json +++ b/packages/opentelemetry-web/package.json @@ -45,7 +45,7 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.14.6", + "@babel/core": "7.14.8", "@opentelemetry/api": "^1.0.1", "@opentelemetry/context-zone": "0.23.0", "@opentelemetry/propagator-b3": "0.23.0", @@ -56,7 +56,7 @@ "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", "babel-loader": "8.2.2", - "codecov": "3.8.2", + "codecov": "3.8.3", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.2.3", "karma-chrome-launcher": "3.1.0", From 3bc3452814e30274d7eea1f3c9da968b88b1a197 Mon Sep 17 00:00:00 2001 From: Weyert de Boer Date: Sun, 25 Jul 2021 07:41:34 +0100 Subject: [PATCH 7/7] 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