Skip to content

Commit

Permalink
refactor: deprecate attribute.component (#1220)
Browse files Browse the repository at this point in the history
* refactor: deprecate attribute.component

* fix(tests): shift test attribute indexes

Co-authored-by: Naseem <naseem@transit.app>
Co-authored-by: Mayur Kale <mayurkale@google.com>
  • Loading branch information
3 people authored Jun 24, 2020
1 parent 66f49a7 commit 806eabd
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 101 deletions.
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
Loading

0 comments on commit 806eabd

Please sign in to comment.