-
Notifications
You must be signed in to change notification settings - Fork 842
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
feat(traceparent): setting parent span from server #477
Changes from 6 commits
d028135
20735e2
d7c3194
865c50a
5393ac7
16bd3a6
042d1d9
f6bfdc5
f8dc8e1
5425430
feb4498
0a19860
53e7b1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -14,11 +14,19 @@ | |||
* limitations under the License. | ||||
*/ | ||||
|
||||
import { BasePlugin, otperformance } from '@opentelemetry/core'; | ||||
import { | ||||
BasePlugin, | ||||
otperformance, | ||||
parseTraceParent, | ||||
} from '@opentelemetry/core'; | ||||
import { PluginConfig, Span, SpanOptions } from '@opentelemetry/types'; | ||||
import { AttributeNames } from './enums/AttributeNames'; | ||||
import { PerformanceTimingNames as PTN } from './enums/PerformanceTimingNames'; | ||||
import { PerformanceEntries, PerformanceLegacy } from './types'; | ||||
import { | ||||
PerformanceEntries, | ||||
PerformanceLegacy, | ||||
WindowWithTrace, | ||||
} from './types'; | ||||
import { hasKey } from './utils'; | ||||
|
||||
/** | ||||
|
@@ -76,12 +84,17 @@ export class DocumentLoad extends BasePlugin<unknown> { | |||
* Collects information about performance and creates appropriate spans | ||||
*/ | ||||
private _collectPerformance() { | ||||
const windowWithTrace: WindowWithTrace = (window as unknown) as WindowWithTrace; | ||||
const serverContext = | ||||
parseTraceParent(windowWithTrace.traceparent || '') || undefined; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the
|
||||
|
||||
const entries = this._getEntries(); | ||||
|
||||
const rootSpan = this._startSpan( | ||||
AttributeNames.DOCUMENT_LOAD, | ||||
PTN.FETCH_START, | ||||
entries | ||||
entries, | ||||
{ parent: serverContext } | ||||
); | ||||
if (!rootSpan) { | ||||
return; | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.