Skip to content

Commit

Permalink
chore: add url to documentFetch span (open-telemetry#1129)
Browse files Browse the repository at this point in the history
* chore: add url and HTTP_USER_AGENT to documentFetch span

* chore: add unit test

* chore: remove user agent from documentFetch span

Co-authored-by: Nev <54870357+MSNev@users.noreply.github.com>
  • Loading branch information
tchoi1131 and MSNev authored Sep 22, 2022
1 parent d463695 commit 01d6e95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export class DocumentLoadInstrumentation extends InstrumentationBase<unknown> {
entries
);
if (fetchSpan) {
fetchSpan.setAttribute(SemanticAttributes.HTTP_URL, location.href);
context.with(trace.setSpan(context.active(), fetchSpan), () => {
addSpanNetworkEvents(fetchSpan, entries);
this._endSpan(fetchSpan, PTN.RESPONSE_END, entries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,11 @@ describe('DocumentLoad Instrumentation', () => {
assert.strictEqual(fetchSpan.name, 'documentFetch');
assert.strictEqual(rootSpan.name, 'documentLoad');

assert.strictEqual(
fetchSpan.attributes['http.url'],
'http://localhost:9876/context.html'
);

assert.strictEqual(
rootSpan.attributes['http.url'],
'http://localhost:9876/context.html'
Expand Down

0 comments on commit 01d6e95

Please sign in to comment.