-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugin-document-load): new plugin for document load for web trac…
…er (#433) * feat(plugin-document-load): new plugin for document load for web tracer * chore: lint * chore: removing unused dependency * chore: adding prepare script * chore: cleanup of not used span processor * chore: merging exporter-console into tracing * chore: fixing timeOrigin when browser is using older version of performance (safari for example) * chore: removing @Private * chore: cleaning the docs * chore: using stubs on public instead of private * chore: added explanation when span can be undefined * chore: adding unit test for case when passed "performanceNow" is equal to 0 * chore: adding unit test for case when passed "performanceNow" is null or undefined * chore: fixing unit test with null * chore: bump version * chore: after changing enum keys to capitals I had to use values to align them with performance metric in type "PerformanceEntries" * chore: adding comments for interfaces * feat: adding possibility of setting start time for event * chore: refactoring document load to use events instead of new spans * chore: reformatting * chore: updating loop * chore: changing type for time * chore: refactoring loop, updating jsdoc * chore: splitting events into 2 spans * chore: adding possibility of calling addEvent with 2nd param as time * chore: updating the last event to be "load end" * chore: updating the name for attributes * chore: fixing test * chore: cleanups * chore: adding isTimeInput function with unit tests * chore: adding component name * chore: adding license and readme * chore: updating lint and docs jobs to use node12 image in circleci
- Loading branch information
1 parent
972faa2
commit b21ed97
Showing
33 changed files
with
1,530 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,11 @@ | ||
import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing'; | ||
import { WebTracer } from '@opentelemetry/web'; | ||
import { DocumentLoad } from '@opentelemetry/plugin-document-load'; | ||
|
||
import * as shimmer from 'shimmer'; | ||
|
||
class Tester { | ||
constructor() { | ||
} | ||
add(name) { | ||
console.log('calling add', name); | ||
} | ||
} | ||
|
||
const tester = new Tester(); | ||
|
||
const webTracer = new WebTracer(); | ||
const span = webTracer.startSpan('span1'); | ||
|
||
shimmer.wrap(Tester.prototype, 'add', (originalFunction) => { | ||
return function patchedFunction() { | ||
try { | ||
span.addEvent('start'); | ||
} catch (e) { | ||
console.log('error', e); | ||
} finally { | ||
const result = originalFunction.apply(this, arguments); | ||
span.addEvent('after call'); | ||
span.end(); | ||
return result; | ||
} | ||
}; | ||
}); | ||
|
||
webTracer.withSpan(span, function () { | ||
console.log(this === span); | ||
const webTracer = new WebTracer({ | ||
plugins: [ | ||
new DocumentLoad() | ||
] | ||
}); | ||
|
||
tester.add('foo'); | ||
console.log(span); | ||
webTracer.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.