diff --git a/packages/opentelemetry-plugin-http/src/utils.ts b/packages/opentelemetry-plugin-http/src/utils.ts index fbada00b1f..b09d637ec5 100644 --- a/packages/opentelemetry-plugin-http/src/utils.ts +++ b/packages/opentelemetry-plugin-http/src/utils.ts @@ -40,7 +40,7 @@ export const getAbsoluteUrl = ( const port = (reqUrlObject.port || '').toString(); const path = reqUrlObject.path || '/'; let host = - headers.host || reqUrlObject.hostname || headers.host || 'localhost'; + reqUrlObject.host || reqUrlObject.hostname || headers.host || 'localhost'; // if there is no port in host and there is a port // it should be displayed if it's not 80 and 443 (default ports) diff --git a/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts b/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts index eccf35bc7a..7dd1537f69 100644 --- a/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts +++ b/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts @@ -69,7 +69,7 @@ export const assertSpan = ( span.attributes[AttributeNames.HTTP_STATUS_CODE], validations.httpStatusCode ); - assert.ok(span.endTime); + assert.strictEqual(span.links.length, 0); assert.strictEqual(span.events.length, 0); @@ -79,6 +79,13 @@ export const assertSpan = ( utils.parseResponseStatus(validations.httpStatusCode) ); + assert.ok( + (span.attributes[AttributeNames.HTTP_URL] as string).indexOf( + span.attributes[AttributeNames.HTTP_HOSTNAME] as string + ) > -1, + 'should be consistent' + ); + assert.ok(span.endTime, 'must be finished'); assert.ok(hrTimeToNanoseconds(span.duration), 'must have positive duration'); if (validations.reqHeaders) {