diff --git a/packages/opentelemetry-plugin-http/src/http.ts b/packages/opentelemetry-plugin-http/src/http.ts index 435de21195b..7f5e45b2583 100644 --- a/packages/opentelemetry-plugin-http/src/http.ts +++ b/packages/opentelemetry-plugin-http/src/http.ts @@ -311,10 +311,7 @@ export class HttpPlugin extends BasePlugin { }; return context.with(propagation.extract(headers), () => { - const span = plugin._startHttpSpan( - `${method} ${pathname}`, - spanOptions - ); + const span = plugin._startHttpSpan(`HTTP ${method}`, spanOptions); return plugin._tracer.withSpan(span, () => { context.bind(request); @@ -420,7 +417,7 @@ export class HttpPlugin extends BasePlugin { return original.apply(this, [optionsParsed, ...args]); } - const operationName = `${method} ${pathname}`; + const operationName = `HTTP ${method}`; const spanOptions: SpanOptions = { kind: SpanKind.CLIENT, }; diff --git a/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts b/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts index 1cb350bf953..60d34fa45ce 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts @@ -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 @@ -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 @@ -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 diff --git a/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts b/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts index bb98825b39a..4a775482a52 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts @@ -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': diff --git a/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts b/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts index 9fd14f6ff06..8ea38fea17b 100644 --- a/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts +++ b/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts @@ -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); }); @@ -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); }); @@ -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( @@ -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); }); @@ -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); @@ -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]); diff --git a/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts b/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts index 0b02fc702de..f9bda54dd02 100644 --- a/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts +++ b/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts @@ -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 diff --git a/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts b/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts index 39aa2e54931..22c459d6b12 100644 --- a/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts +++ b/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts @@ -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 @@ -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 @@ -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 diff --git a/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts b/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts index a4463a4754d..ff7430afb3e 100644 --- a/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts +++ b/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts @@ -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': diff --git a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts index a0a128bb0d0..ef291281f5e 100644 --- a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts +++ b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts @@ -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); }); @@ -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); }); @@ -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( @@ -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); }); @@ -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); @@ -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]); diff --git a/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts b/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts index d96db011c58..5921f47eb63 100644 --- a/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts +++ b/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts @@ -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