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

fix(plugin-http): remove path from span name #1466

Merged
merged 5 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions packages/opentelemetry-plugin-http/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,7 @@ export class HttpPlugin extends BasePlugin<Http> {
};

return context.with(propagation.extract(headers), () => {
const span = plugin._startHttpSpan(
`${method} ${pathname}`,
spanOptions
);
const span = plugin._startHttpSpan(`HTTP ${method}`, spanOptions);
dyladan marked this conversation as resolved.
Show resolved Hide resolved

return plugin._tracer.withSpan(span, () => {
context.bind(request);
Expand Down Expand Up @@ -420,7 +417,7 @@ export class HttpPlugin extends BasePlugin<Http> {
return original.apply(this, [optionsParsed, ...args]);
}

const operationName = `${method} ${pathname}`;
const operationName = `HTTP ${method}`;
const spanOptions: SpanOptions = {
kind: SpanKind.CLIENT,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ describe('HttpPlugin', () => {

assert.ok(localSpan.name.indexOf('TestRootSpan') >= 0);
assert.strictEqual(spans.length, 2);
assert.ok(reqSpan.name.indexOf(testPath) >= 0);
assert.strictEqual(reqSpan.name, 'HTTP GET');
assert.strictEqual(
localSpan.spanContext.traceId,
reqSpan.spanContext.traceId
Expand Down Expand Up @@ -441,7 +441,7 @@ describe('HttpPlugin', () => {

assert.ok(localSpan.name.indexOf('TestRootSpan') >= 0);
assert.strictEqual(spans.length, 2);
assert.ok(reqSpan.name.indexOf(testPath) >= 0);
assert.strictEqual(reqSpan.name, 'HTTP GET');
assert.strictEqual(
localSpan.spanContext.traceId,
reqSpan.spanContext.traceId
Expand All @@ -465,7 +465,7 @@ describe('HttpPlugin', () => {
for (let i = 0; i < num; i++) {
await httpRequest.get(`${protocol}://${hostname}${testPath}`);
const spans = memoryExporter.getFinishedSpans();
assert.ok(spans[i].name.indexOf(testPath) >= 0);
assert.strictEqual(spans[i].name, 'HTTP GET');
assert.strictEqual(
span.context().traceId,
spans[i].spanContext.traceId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('Packages', () => {
};

assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf(`GET ${urlparsed.pathname}`) >= 0);
assert.strictEqual(span.name, 'HTTP GET');

switch (name) {
case 'axios':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('HttpPlugin Integration tests', () => {
};

assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf('GET /') >= 0);
assert.strictEqual(span.name, 'HTTP GET');
assertSpan(span, SpanKind.CLIENT, validations);
});

Expand All @@ -148,7 +148,7 @@ describe('HttpPlugin Integration tests', () => {
};

assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf('GET /') >= 0);
assert.strictEqual(span.name, 'HTTP GET');
assertSpan(span, SpanKind.CLIENT, validations);
});

Expand Down Expand Up @@ -177,7 +177,7 @@ describe('HttpPlugin Integration tests', () => {
};

assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf('GET /') >= 0);
assert.strictEqual(span.name, 'HTTP GET');
assert.strictEqual(result.reqHeaders['x-foo'], 'foo');
assert.strictEqual(span.attributes[HttpAttribute.HTTP_FLAVOR], '1.1');
assert.strictEqual(
Expand All @@ -202,7 +202,7 @@ describe('HttpPlugin Integration tests', () => {
};

assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf('GET /') >= 0);
assert.strictEqual(span.name, 'HTTP GET');
assert.strictEqual(span.attributes['span kind'], SpanKind.CLIENT);
assertSpan(span, SpanKind.CLIENT, validations);
});
Expand All @@ -229,7 +229,7 @@ describe('HttpPlugin Integration tests', () => {
};

assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf('GET /') >= 0);
assert.strictEqual(span.name, 'HTTP GET');

try {
assertSpan(span, SpanKind.CLIENT, validations);
Expand Down Expand Up @@ -289,7 +289,7 @@ describe('HttpPlugin Integration tests', () => {
req.on('close', () => {
const spans = memoryExporter.getFinishedSpans();
assert.strictEqual(spans.length, 1);
assert.ok(spans[0].name.indexOf('GET /') >= 0);
assert.strictEqual(spans[0].name, 'HTTP GET');
assert.ok(data);
assert.ok(validations.reqHeaders[DummyPropagation.TRACE_CONTEXT_KEY]);
assert.ok(validations.reqHeaders[DummyPropagation.SPAN_CONTEXT_KEY]);
Expand Down
5 changes: 1 addition & 4 deletions packages/opentelemetry-plugin-http/test/utils/assertSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ export const assertSpan = (
assert.strictEqual(span.spanContext.traceId.length, 32);
assert.strictEqual(span.spanContext.spanId.length, 16);
assert.strictEqual(span.kind, kind);
assert.strictEqual(
span.name,
`${validations.httpMethod} ${validations.pathname}`
);
assert.strictEqual(span.name, `HTTP ${validations.httpMethod}`);
assert.strictEqual(
span.attributes[HttpAttribute.HTTP_ERROR_MESSAGE],
span.status.message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ describe('HttpsPlugin', () => {

assert.ok(localSpan.name.indexOf('TestRootSpan') >= 0);
assert.strictEqual(spans.length, 2);
assert.ok(reqSpan.name.indexOf(testPath) >= 0);
assert.strictEqual(reqSpan.name, 'HTTP GET');
assert.strictEqual(
localSpan.spanContext.traceId,
reqSpan.spanContext.traceId
Expand Down Expand Up @@ -433,7 +433,7 @@ describe('HttpsPlugin', () => {

assert.ok(localSpan.name.indexOf('TestRootSpan') >= 0);
assert.strictEqual(spans.length, 2);
assert.ok(reqSpan.name.indexOf(testPath) >= 0);
assert.strictEqual(reqSpan.name, 'HTTP GET');
assert.strictEqual(
localSpan.spanContext.traceId,
reqSpan.spanContext.traceId
Expand All @@ -457,7 +457,7 @@ describe('HttpsPlugin', () => {
for (let i = 0; i < num; i++) {
await httpsRequest.get(`${protocol}://${hostname}${testPath}`);
const spans = memoryExporter.getFinishedSpans();
assert.ok(spans[i].name.indexOf(testPath) >= 0);
assert.strictEqual(spans[i].name, 'HTTP GET');
assert.strictEqual(
span.context().traceId,
spans[i].spanContext.traceId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('Packages', () => {
};

assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf(`GET ${urlparsed.pathname}`) >= 0);
assert.strictEqual(span.name, 'HTTP GET');

switch (name) {
case 'axios':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('HttpsPlugin Integration tests', () => {
};

assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf('GET /') >= 0);
assert.strictEqual(span.name, 'HTTP GET');
assertSpan(span, SpanKind.CLIENT, validations);
});

Expand All @@ -155,7 +155,7 @@ describe('HttpsPlugin Integration tests', () => {
};

assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf('GET /') >= 0);
assert.strictEqual(span.name, 'HTTP GET');
assertSpan(span, SpanKind.CLIENT, validations);
});

Expand All @@ -182,7 +182,7 @@ describe('HttpsPlugin Integration tests', () => {
};

assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf('GET /') >= 0);
assert.strictEqual(span.name, 'HTTP GET');
assert.strictEqual(result.reqHeaders['x-foo'], 'foo');
assert.strictEqual(span.attributes[HttpAttribute.HTTP_FLAVOR], '1.1');
assert.strictEqual(
Expand All @@ -207,7 +207,7 @@ describe('HttpsPlugin Integration tests', () => {
};

assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf('GET /') >= 0);
assert.strictEqual(span.name, 'HTTP GET');
assert.strictEqual(span.attributes['span kind'], SpanKind.CLIENT);
assertSpan(span, SpanKind.CLIENT, validations);
});
Expand All @@ -234,7 +234,7 @@ describe('HttpsPlugin Integration tests', () => {
};

assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf('GET /') >= 0);
assert.strictEqual(span.name, 'HTTP GET');

try {
assertSpan(span, SpanKind.CLIENT, validations);
Expand Down Expand Up @@ -294,7 +294,7 @@ describe('HttpsPlugin Integration tests', () => {
req.on('close', () => {
const spans = memoryExporter.getFinishedSpans();
assert.strictEqual(spans.length, 1);
assert.ok(spans[0].name.indexOf('GET /') >= 0);
assert.strictEqual(spans[0].name, 'HTTP GET');
assert.ok(data);
assert.ok(validations.reqHeaders[DummyPropagation.TRACE_CONTEXT_KEY]);
assert.ok(validations.reqHeaders[DummyPropagation.SPAN_CONTEXT_KEY]);
Expand Down
5 changes: 1 addition & 4 deletions packages/opentelemetry-plugin-https/test/utils/assertSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ export const assertSpan = (
assert.strictEqual(span.spanContext.traceId.length, 32);
assert.strictEqual(span.spanContext.spanId.length, 16);
assert.strictEqual(span.kind, kind);
assert.strictEqual(
span.name,
`${validations.httpMethod} ${validations.pathname}`
);
assert.strictEqual(span.name, `HTTP ${validations.httpMethod}`);
assert.strictEqual(
span.attributes[HttpAttribute.HTTP_ERROR_MESSAGE],
span.status.message
Expand Down