Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

refactor: deprecate attribute.component #1220

Merged
Merged
14 changes: 4 additions & 10 deletions packages/opentelemetry-plugin-grpc/src/grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ import {
SpanOptions,
Status,
} from '@opentelemetry/api';
import {
GeneralAttribute,
RpcAttribute,
} from '@opentelemetry/semantic-conventions';
import { RpcAttribute } from '@opentelemetry/semantic-conventions';
import { BasePlugin } from '@opentelemetry/core';
import * as events from 'events';
import * as grpcTypes from 'grpc';
Expand Down Expand Up @@ -177,7 +174,6 @@ export class GrpcPlugin extends BasePlugin<grpc> {
.startSpan(spanName, spanOptions)
.setAttributes({
[RpcAttribute.GRPC_KIND]: spanOptions.kind,
[GeneralAttribute.COMPONENT]: GrpcPlugin.component,
});

plugin._tracer.withSpan(span, () => {
Expand Down Expand Up @@ -353,11 +349,9 @@ export class GrpcPlugin extends BasePlugin<grpc> {
return function clientMethodTrace(this: grpcTypes.Client) {
const name = `grpc.${original.path.replace('/', '')}`;
const args = Array.prototype.slice.call(arguments);
const span = plugin._tracer
.startSpan(name, {
kind: SpanKind.CLIENT,
})
.setAttribute(GeneralAttribute.COMPONENT, GrpcPlugin.component);
const span = plugin._tracer.startSpan(name, {
kind: SpanKind.CLIENT,
});
return plugin._tracer.withSpan(span, () =>
plugin._makeGrpcClientRemoteCall(original, args, this, plugin)(span)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@

import { SpanKind } from '@opentelemetry/api';
import * as assert from 'assert';
import { GrpcPlugin } from '../../src/grpc';
import * as grpc from 'grpc';
import { ReadableSpan } from '@opentelemetry/tracing';
import {
hrTimeToMilliseconds,
hrTimeToMicroseconds,
} from '@opentelemetry/core';
import { GeneralAttribute } from '@opentelemetry/semantic-conventions';

export const assertSpan = (
span: ReadableSpan,
Expand All @@ -34,10 +32,6 @@ export const assertSpan = (
assert.strictEqual(span.spanContext.spanId.length, 16);
assert.strictEqual(span.kind, kind);

assert.strictEqual(
span.attributes[GeneralAttribute.COMPONENT],
GrpcPlugin.component
);
assert.ok(span.endTime);
assert.strictEqual(span.links.length, 0);
assert.strictEqual(span.events.length, 1);
Expand Down
5 changes: 1 addition & 4 deletions packages/opentelemetry-plugin-http/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
NoRecordingSpan,
getExtractedSpanContext,
} from '@opentelemetry/core';
import { GeneralAttribute } from '@opentelemetry/semantic-conventions';
import {
ClientRequest,
IncomingMessage,
Expand Down Expand Up @@ -461,9 +460,7 @@ export class HttpPlugin extends BasePlugin<Http> {
// https://github.com/open-telemetry/opentelemetry-specification/issues/530
span = new NoRecordingSpan(spanContext);
} else {
span = this._tracer
.startSpan(name, options)
.setAttribute(GeneralAttribute.COMPONENT, this.component);
span = this._tracer.startSpan(name, options);
}
this._spanNotEnded.add(span);
return span;
Expand Down
4 changes: 0 additions & 4 deletions packages/opentelemetry-plugin-http/test/utils/assertSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ export const assertSpan = (
span.name,
`${validations.httpMethod} ${validations.pathname}`
);
assert.strictEqual(
span.attributes[GeneralAttribute.COMPONENT],
validations.component
);
assert.strictEqual(
span.attributes[HttpAttribute.HTTP_ERROR_MESSAGE],
span.status.message
Expand Down
4 changes: 0 additions & 4 deletions packages/opentelemetry-plugin-https/test/utils/assertSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ export const assertSpan = (
span.name,
`${validations.httpMethod} ${validations.pathname}`
);
assert.strictEqual(
span.attributes[GeneralAttribute.COMPONENT],
validations.component
);
assert.strictEqual(
span.attributes[HttpAttribute.HTTP_ERROR_MESSAGE],
span.status.message
Expand Down
6 changes: 1 addition & 5 deletions packages/opentelemetry-plugin-xml-http-request/src/xhr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ import {
isWrapped,
otperformance,
} from '@opentelemetry/core';
import {
HttpAttribute,
GeneralAttribute,
} from '@opentelemetry/semantic-conventions';
import { HttpAttribute } from '@opentelemetry/semantic-conventions';
import {
addSpanNetworkEvents,
getResource,
Expand Down Expand Up @@ -279,7 +276,6 @@ export class XMLHttpRequestPlugin extends BasePlugin<XMLHttpRequest> {
const currentSpan = this._tracer.startSpan(url, {
kind: api.SpanKind.CLIENT,
attributes: {
[GeneralAttribute.COMPONENT]: this.component,
[HttpAttribute.HTTP_METHOD]: method,
[HttpAttribute.HTTP_URL]: url,
},
Expand Down
13 changes: 1 addition & 12 deletions packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ import {
} from '@opentelemetry/core';
import { ZoneContextManager } from '@opentelemetry/context-zone';
import * as tracing from '@opentelemetry/tracing';
import {
HttpAttribute,
GeneralAttribute,
} from '@opentelemetry/semantic-conventions';
import { HttpAttribute } from '@opentelemetry/semantic-conventions';
import {
PerformanceTimingNames as PTN,
WebTracerProvider,
Expand Down Expand Up @@ -239,10 +236,6 @@ describe('xhr', () => {
const attributes = span.attributes;
const keys = Object.keys(attributes);

assert.ok(
attributes[keys[0]] !== '',
`attributes ${GeneralAttribute.COMPONENT} is not defined`
);
assert.strictEqual(
attributes[keys[1]],
'GET',
Expand Down Expand Up @@ -509,10 +502,6 @@ describe('xhr', () => {
const attributes = span.attributes;
const keys = Object.keys(attributes);

assert.ok(
attributes[keys[0]] !== '',
`attributes ${GeneralAttribute.COMPONENT} is not defined`
);
assert.strictEqual(
attributes[keys[1]],
'GET',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const GeneralAttribute = {
// Not in spec
COMPONENT: 'component',

/**
* General purpose networking attributes defined by the OpenTelemetry Semantic Conventions Specification
* https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/span-general.md
*/
export const GeneralAttribute = {
NET_PEER_IP: 'net.peer.ip',
NET_PEER_ADDRESS: 'net.peer.address',
NET_PEER_HOSTNAME: 'net.peer.host',
Expand Down