Skip to content

Commit

Permalink
Merge f7365e2 into 74ca04f
Browse files Browse the repository at this point in the history
  • Loading branch information
kobi-co authored Mar 1, 2023
2 parents 74ca04f + f7365e2 commit 89d3aa1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
### :bug: (Bug Fix)

* fix(core): added falsy check to make otel core work with browser where webpack config had process as false or null [#3613](https://github.com/open-telemetry/opentelemetry-js/issues/3613) @ravindra-dyte
* fix(instrumentation-http): include query params in http.target [#3646](https://github.com/open-telemetry/opentelemetry-js/pull/3646) @kobi-co

### :books: (Refine Doc)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ export const getIncomingRequestAttributes = (
}

if (requestUrl) {
attributes[SemanticAttributes.HTTP_TARGET] = requestUrl.pathname || '/';
attributes[SemanticAttributes.HTTP_TARGET] = requestUrl.path || '/';
}

if (userAgent !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,23 @@ describe('Utility', () => {
});
assert.strictEqual(attributes[SemanticAttributes.HTTP_ROUTE], undefined);
});

it('should set http.target as path in http span attributes', () => {
const request = {
url: 'http://hostname/user/?q=val',
method: 'GET',
} as IncomingMessage;
request.headers = {
'user-agent': 'chrome',
};
const attributes = utils.getIncomingRequestAttributes(request, {
component: 'http',
});
assert.strictEqual(
attributes[SemanticAttributes.HTTP_TARGET],
'/user/?q=val'
);
});
});

describe('headers to span attributes capture', () => {
Expand Down

0 comments on commit 89d3aa1

Please sign in to comment.