Skip to content

Commit

Permalink
fix(plugin-http): http.url attribute (#580)
Browse files Browse the repository at this point in the history
closes #579

Signed-off-by: Olivier Albertini <[email protected]>
  • Loading branch information
OlivierAlbertini authored and mayurkale22 committed Dec 2, 2019
1 parent 2e4136c commit 06d21e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-http/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion packages/opentelemetry-plugin-http/test/utils/assertSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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) {
Expand Down

0 comments on commit 06d21e3

Please sign in to comment.