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): http.url attribute #580

Merged
Show file tree
Hide file tree
Changes from all 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
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