From a0e69159bde6b7c9e243167f7ef06a786013cca2 Mon Sep 17 00:00:00 2001 From: Andrei Zenkou Date: Tue, 12 Jul 2022 16:20:25 +0200 Subject: [PATCH 1/5] Fixed missed attributes. Updated method value for some cases. --- .../src/enums/AttributeNames.ts | 2 ++ .../src/grpc-js/clientUtils.ts | 1 - .../src/grpc-js/index.ts | 18 +++++++++++++++--- .../src/grpc/clientUtils.ts | 1 - .../src/grpc/index.ts | 15 +++++++++++++-- .../src/utils.ts | 15 +++++++++++++++ 6 files changed, 45 insertions(+), 7 deletions(-) diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts index 9dfd3e0923..63777627df 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts @@ -20,6 +20,8 @@ export enum AttributeNames { GRPC_KIND = 'grpc.kind', // SERVER or CLIENT GRPC_METHOD = 'grpc.method', + RPC_SYSTEM = 'rpc.system', + RPC_SERVICE = 'rpc.service', GRPC_ERROR_NAME = 'grpc.error_name', GRPC_ERROR_MESSAGE = 'grpc.error_message', } diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/clientUtils.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/clientUtils.ts index 5671d3a815..4be00c2d84 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/clientUtils.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/clientUtils.ts @@ -128,7 +128,6 @@ export function makeGrpcClientRemoteCall( } span.setAttributes({ - [AttributeNames.GRPC_METHOD]: original.path, [AttributeNames.GRPC_KIND]: SpanKind.CLIENT, }); diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts index 7e854d7b77..408cdab3d1 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts @@ -50,6 +50,7 @@ import { } from './clientUtils'; import { EventEmitter } from 'events'; import { AttributeNames } from '../enums/AttributeNames'; +import { _extractMethodAndService } from '../utils'; export class GrpcJsInstrumentation extends InstrumentationBase { constructor( @@ -188,10 +189,15 @@ export class GrpcJsInstrumentation extends InstrumentationBase { keys: carrier => Object.keys(carrier.getMap()), }), () => { + const { service, method } = _extractMethodAndService(name) + const span = instrumentation.tracer .startSpan(spanName, spanOptions) .setAttributes({ [AttributeNames.GRPC_KIND]: spanOptions.kind, + [AttributeNames.RPC_SYSTEM]: 'grpc', + [AttributeNames.GRPC_METHOD]: method, + [AttributeNames.RPC_SERVICE]: service, }); context.with(trace.setSpan(context.active(), span), () => { @@ -283,9 +289,15 @@ export class GrpcJsInstrumentation extends InstrumentationBase { original, args ); - const span = instrumentation.tracer.startSpan(name, { - kind: SpanKind.CLIENT, - }); + const { service, method } = _extractMethodAndService(original.path) + + const span = instrumentation.tracer + .startSpan(name, { kind: SpanKind.CLIENT }) + .setAttributes({ + [AttributeNames.RPC_SYSTEM]: 'grpc', + [AttributeNames.GRPC_METHOD]: method, + [AttributeNames.RPC_SERVICE]: service, + }) return context.with(trace.setSpan(context.active(), span), () => makeGrpcClientRemoteCall(original, args, metadata, this)(span) ); diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts index 331e744344..f9335ff5bb 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts @@ -100,7 +100,6 @@ export const makeGrpcClientRemoteCall = function ( span.addEvent('sent'); span.setAttributes({ - [AttributeNames.GRPC_METHOD]: original.path, [AttributeNames.GRPC_KIND]: SpanKind.CLIENT, }); diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts index cbc6bb7560..f2be1562a7 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts @@ -41,7 +41,7 @@ import { serverStreamAndBidiHandler, } from './serverUtils'; import { makeGrpcClientRemoteCall, getMetadata } from './clientUtils'; -import { _methodIsIgnored } from '../utils'; +import { _extractMethodAndService, _methodIsIgnored } from '../utils'; import { AttributeNames } from '../enums/AttributeNames'; /** @@ -195,10 +195,15 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< keys: metadata => Object.keys(metadata.getMap()), }), () => { + const { service, method } = _extractMethodAndService(name); + const span = instrumentation.tracer .startSpan(spanName, spanOptions) .setAttributes({ [AttributeNames.GRPC_KIND]: spanOptions.kind, + [AttributeNames.RPC_SYSTEM]: 'grpc', + [AttributeNames.GRPC_METHOD]: method, + [AttributeNames.RPC_SERVICE]: service, }); context.with(trace.setSpan(context.active(), span), () => { @@ -292,9 +297,15 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< )}`; const args = Array.prototype.slice.call(arguments); const metadata = getMetadata(grpcClient, original, args); + const { service, method } = _extractMethodAndService(original.path) const span = instrumentation.tracer.startSpan(name, { kind: SpanKind.CLIENT, - }); + }) + .setAttributes({ + [AttributeNames.RPC_SYSTEM]: 'grpc', + [AttributeNames.GRPC_METHOD]: method, + [AttributeNames.RPC_SERVICE]: service, + }); return context.with(trace.setSpan(context.active(), span), () => makeGrpcClientRemoteCall( grpcClient, diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/utils.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/utils.ts index 14e0a86eb9..b307aa77db 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/utils.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/utils.ts @@ -95,3 +95,18 @@ export const _methodIsIgnored = ( return false; }; + +/** + * Return method and service values getting from grpc name/path + * @param name the grpc name/path + */ +export const _extractMethodAndService = (name: string): { service: string, method: string } => { + const serviceMethod = name.replace(/^\//, '').split('/'); + const service = serviceMethod.shift() || ''; + const method = serviceMethod.join('/'); + + return ({ + service, + method + }) +}; From 3ae0bfb38eaa0968741aee3de32aad22b0c2e3bb Mon Sep 17 00:00:00 2001 From: Andrei Zenkou Date: Wed, 13 Jul 2022 11:14:26 +0200 Subject: [PATCH 2/5] Updated naming of method attribute to be consistent --- .../src/enums/AttributeNames.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts index 63777627df..601f1c3a4d 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts @@ -19,7 +19,7 @@ */ export enum AttributeNames { GRPC_KIND = 'grpc.kind', // SERVER or CLIENT - GRPC_METHOD = 'grpc.method', + GRPC_METHOD = 'rpc.method', RPC_SYSTEM = 'rpc.system', RPC_SERVICE = 'rpc.service', GRPC_ERROR_NAME = 'grpc.error_name', From 95ce965bb1d86ee583a2a2c24c437cd1e12609ad Mon Sep 17 00:00:00 2001 From: Andrei Zenkou Date: Fri, 15 Jul 2022 09:58:06 +0200 Subject: [PATCH 3/5] Added conventions from OTel package for some attributes. --- .../src/enums/AttributeNames.ts | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts index 601f1c3a4d..3d4c3b0673 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts @@ -17,11 +17,26 @@ /** * https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md */ -export enum AttributeNames { - GRPC_KIND = 'grpc.kind', // SERVER or CLIENT - GRPC_METHOD = 'rpc.method', - RPC_SYSTEM = 'rpc.system', - RPC_SERVICE = 'rpc.service', - GRPC_ERROR_NAME = 'grpc.error_name', - GRPC_ERROR_MESSAGE = 'grpc.error_message', +import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; + +interface AttributesType { + GRPC_KIND: string; + RPC_SYSTEM: string; + GRPC_METHOD: string; + RPC_SERVICE: string; + GRPC_ERROR_NAME: string; + GRPC_ERROR_MESSAGE: string; } + +const RPC_METHOD = SemanticAttributes.RPC_METHOD; +const RPC_SYSTEM = SemanticAttributes.RPC_SYSTEM; +const RPC_SERVICE = SemanticAttributes.RPC_SERVICE; + +export const AttributeNames: Readonly = { + GRPC_KIND: 'grpc.kind', // SERVER or CLIENT + RPC_SYSTEM: RPC_SYSTEM, + GRPC_METHOD: RPC_METHOD, + RPC_SERVICE: RPC_SERVICE, + GRPC_ERROR_NAME: 'grpc.error_name', + GRPC_ERROR_MESSAGE: 'grpc.error_message', +}; From 1aeb31eb57718098c22936d637063c51ad05a684 Mon Sep 17 00:00:00 2001 From: andrewzenkov Date: Thu, 21 Jul 2022 18:14:18 +0200 Subject: [PATCH 4/5] Remove useless GRPC_KIND attribute. Moved static value to variable --- .../src/enums/AttributeNames.ts | 2 -- .../src/enums/AttributeValues.ts | 23 +++++++++++++++++++ .../src/grpc-js/clientUtils.ts | 5 ---- .../src/grpc-js/index.ts | 4 ++-- .../src/grpc/clientUtils.ts | 4 ---- .../src/grpc/index.ts | 6 ++--- 6 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeValues.ts diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts index 3d4c3b0673..e6a0be9fc4 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts @@ -20,7 +20,6 @@ import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; interface AttributesType { - GRPC_KIND: string; RPC_SYSTEM: string; GRPC_METHOD: string; RPC_SERVICE: string; @@ -33,7 +32,6 @@ const RPC_SYSTEM = SemanticAttributes.RPC_SYSTEM; const RPC_SERVICE = SemanticAttributes.RPC_SERVICE; export const AttributeNames: Readonly = { - GRPC_KIND: 'grpc.kind', // SERVER or CLIENT RPC_SYSTEM: RPC_SYSTEM, GRPC_METHOD: RPC_METHOD, RPC_SERVICE: RPC_SERVICE, diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeValues.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeValues.ts new file mode 100644 index 0000000000..0cdcb14311 --- /dev/null +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeValues.ts @@ -0,0 +1,23 @@ +/* + * 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. + */ + +interface AttributeValuesType { + RPC_SYSTEM: string +} + +export const AttributeValues: Readonly = { + RPC_SYSTEM: 'grpc' +}; diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/clientUtils.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/clientUtils.ts index 4be00c2d84..946cc20185 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/clientUtils.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/clientUtils.ts @@ -17,7 +17,6 @@ import { GrpcJsInstrumentation } from './'; import type { GrpcClientFunc, SendUnaryDataCallback } from './types'; import { - SpanKind, Span, SpanStatusCode, SpanStatus, @@ -127,10 +126,6 @@ export function makeGrpcClientRemoteCall( } } - span.setAttributes({ - [AttributeNames.GRPC_KIND]: SpanKind.CLIENT, - }); - setSpanContext(metadata); const call = original.apply(self, args); diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts index 408cdab3d1..2f0d06df2e 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts @@ -51,6 +51,7 @@ import { import { EventEmitter } from 'events'; import { AttributeNames } from '../enums/AttributeNames'; import { _extractMethodAndService } from '../utils'; +import {AttributeValues} from '../enums/AttributeValues'; export class GrpcJsInstrumentation extends InstrumentationBase { constructor( @@ -194,8 +195,7 @@ export class GrpcJsInstrumentation extends InstrumentationBase { const span = instrumentation.tracer .startSpan(spanName, spanOptions) .setAttributes({ - [AttributeNames.GRPC_KIND]: spanOptions.kind, - [AttributeNames.RPC_SYSTEM]: 'grpc', + [AttributeNames.RPC_SYSTEM]: AttributeValues.RPC_SYSTEM, [AttributeNames.GRPC_METHOD]: method, [AttributeNames.RPC_SERVICE]: service, }); diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts index f9335ff5bb..5f8fa8af44 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/clientUtils.ts @@ -22,7 +22,6 @@ import { context, Span, SpanStatusCode, - SpanKind, SpanStatus, propagation, } from '@opentelemetry/api'; @@ -99,9 +98,6 @@ export const makeGrpcClientRemoteCall = function ( } span.addEvent('sent'); - span.setAttributes({ - [AttributeNames.GRPC_KIND]: SpanKind.CLIENT, - }); setSpanContext(metadata); const call = original.apply(self, args); diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts index f2be1562a7..4c02e1794b 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts @@ -43,6 +43,7 @@ import { import { makeGrpcClientRemoteCall, getMetadata } from './clientUtils'; import { _extractMethodAndService, _methodIsIgnored } from '../utils'; import { AttributeNames } from '../enums/AttributeNames'; +import {AttributeValues} from "../enums/AttributeValues"; /** * Holding reference to grpc module here to access constant of grpc modules @@ -200,8 +201,7 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< const span = instrumentation.tracer .startSpan(spanName, spanOptions) .setAttributes({ - [AttributeNames.GRPC_KIND]: spanOptions.kind, - [AttributeNames.RPC_SYSTEM]: 'grpc', + [AttributeNames.RPC_SYSTEM]: AttributeValues.RPC_SYSTEM, [AttributeNames.GRPC_METHOD]: method, [AttributeNames.RPC_SERVICE]: service, }); @@ -302,7 +302,7 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< kind: SpanKind.CLIENT, }) .setAttributes({ - [AttributeNames.RPC_SYSTEM]: 'grpc', + [AttributeNames.RPC_SYSTEM]: AttributeValues.RPC_SYSTEM, [AttributeNames.GRPC_METHOD]: method, [AttributeNames.RPC_SERVICE]: service, }); From fbbe6f439652087a191545c00206aad37b25a67d Mon Sep 17 00:00:00 2001 From: andrewzenkov Date: Mon, 25 Jul 2022 13:00:28 +0200 Subject: [PATCH 5/5] Updated attributes name by using npm OTel convention directly --- .../src/enums/AttributeNames.ts | 11 ---------- .../src/grpc-js/index.ts | 22 +++++++++---------- .../src/grpc/index.ts | 18 +++++++-------- .../src/utils.ts | 2 +- 4 files changed, 21 insertions(+), 32 deletions(-) diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts index e6a0be9fc4..9d0facd20f 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/enums/AttributeNames.ts @@ -17,24 +17,13 @@ /** * https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md */ -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; interface AttributesType { - RPC_SYSTEM: string; - GRPC_METHOD: string; - RPC_SERVICE: string; GRPC_ERROR_NAME: string; GRPC_ERROR_MESSAGE: string; } -const RPC_METHOD = SemanticAttributes.RPC_METHOD; -const RPC_SYSTEM = SemanticAttributes.RPC_SYSTEM; -const RPC_SERVICE = SemanticAttributes.RPC_SERVICE; - export const AttributeNames: Readonly = { - RPC_SYSTEM: RPC_SYSTEM, - GRPC_METHOD: RPC_METHOD, - RPC_SERVICE: RPC_SERVICE, GRPC_ERROR_NAME: 'grpc.error_name', GRPC_ERROR_MESSAGE: 'grpc.error_message', }; diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts index 2f0d06df2e..4a1c8e9f3a 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts @@ -49,9 +49,9 @@ import { getMetadata, } from './clientUtils'; import { EventEmitter } from 'events'; -import { AttributeNames } from '../enums/AttributeNames'; import { _extractMethodAndService } from '../utils'; -import {AttributeValues} from '../enums/AttributeValues'; +import { AttributeValues } from '../enums/AttributeValues'; +import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; export class GrpcJsInstrumentation extends InstrumentationBase { constructor( @@ -190,14 +190,14 @@ export class GrpcJsInstrumentation extends InstrumentationBase { keys: carrier => Object.keys(carrier.getMap()), }), () => { - const { service, method } = _extractMethodAndService(name) + const { service, method } = _extractMethodAndService(name); const span = instrumentation.tracer .startSpan(spanName, spanOptions) .setAttributes({ - [AttributeNames.RPC_SYSTEM]: AttributeValues.RPC_SYSTEM, - [AttributeNames.GRPC_METHOD]: method, - [AttributeNames.RPC_SERVICE]: service, + [SemanticAttributes.RPC_SYSTEM]: AttributeValues.RPC_SYSTEM, + [SemanticAttributes.RPC_METHOD]: method, + [SemanticAttributes.RPC_SERVICE]: service, }); context.with(trace.setSpan(context.active(), span), () => { @@ -289,15 +289,15 @@ export class GrpcJsInstrumentation extends InstrumentationBase { original, args ); - const { service, method } = _extractMethodAndService(original.path) + const { service, method } = _extractMethodAndService(original.path); const span = instrumentation.tracer .startSpan(name, { kind: SpanKind.CLIENT }) .setAttributes({ - [AttributeNames.RPC_SYSTEM]: 'grpc', - [AttributeNames.GRPC_METHOD]: method, - [AttributeNames.RPC_SERVICE]: service, - }) + [SemanticAttributes.RPC_SYSTEM]: 'grpc', + [SemanticAttributes.RPC_METHOD]: method, + [SemanticAttributes.RPC_SERVICE]: service, + }); return context.with(trace.setSpan(context.active(), span), () => makeGrpcClientRemoteCall(original, args, metadata, this)(span) ); diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts index 4c02e1794b..dc12345b65 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts @@ -42,8 +42,8 @@ import { } from './serverUtils'; import { makeGrpcClientRemoteCall, getMetadata } from './clientUtils'; import { _extractMethodAndService, _methodIsIgnored } from '../utils'; -import { AttributeNames } from '../enums/AttributeNames'; -import {AttributeValues} from "../enums/AttributeValues"; +import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import {AttributeValues} from '../enums/AttributeValues'; /** * Holding reference to grpc module here to access constant of grpc modules @@ -201,9 +201,9 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< const span = instrumentation.tracer .startSpan(spanName, spanOptions) .setAttributes({ - [AttributeNames.RPC_SYSTEM]: AttributeValues.RPC_SYSTEM, - [AttributeNames.GRPC_METHOD]: method, - [AttributeNames.RPC_SERVICE]: service, + [SemanticAttributes.RPC_SYSTEM]: AttributeValues.RPC_SYSTEM, + [SemanticAttributes.RPC_METHOD]: method, + [SemanticAttributes.RPC_SERVICE]: service, }); context.with(trace.setSpan(context.active(), span), () => { @@ -297,14 +297,14 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< )}`; const args = Array.prototype.slice.call(arguments); const metadata = getMetadata(grpcClient, original, args); - const { service, method } = _extractMethodAndService(original.path) + const { service, method } = _extractMethodAndService(original.path); const span = instrumentation.tracer.startSpan(name, { kind: SpanKind.CLIENT, }) .setAttributes({ - [AttributeNames.RPC_SYSTEM]: AttributeValues.RPC_SYSTEM, - [AttributeNames.GRPC_METHOD]: method, - [AttributeNames.RPC_SERVICE]: service, + [SemanticAttributes.RPC_SYSTEM]: AttributeValues.RPC_SYSTEM, + [SemanticAttributes.RPC_METHOD]: method, + [SemanticAttributes.RPC_SERVICE]: service, }); return context.with(trace.setSpan(context.active(), span), () => makeGrpcClientRemoteCall( diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/utils.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/utils.ts index b307aa77db..16bf81a728 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/utils.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/utils.ts @@ -108,5 +108,5 @@ export const _extractMethodAndService = (name: string): { service: string, metho return ({ service, method - }) + }); };