-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d97167
commit 1c4eabf
Showing
4 changed files
with
70 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { setCurrentClient, spanToJSON, startSpan } from '@sentry/core'; | ||
|
||
import { getDefaultTestClientOptions, TestClient } from './mocks/client'; | ||
|
||
describe('parentSpanIsAlwaysRootSpan', () => { | ||
let client: TestClient; | ||
|
||
it('creates a span as child of root span if parentSpanIsAlwaysRootSpan=true', () => { | ||
const options = getDefaultTestClientOptions({ | ||
tracesSampleRate: 1, | ||
parentSpanIsAlwaysRootSpan: true, | ||
}); | ||
client = new TestClient(options); | ||
setCurrentClient(client); | ||
client.init(); | ||
|
||
startSpan({ name: 'parent span' }, span => { | ||
expect(spanToJSON(span).parent_span_id).toBe(undefined); | ||
startSpan({ name: 'child span' }, childSpan => { | ||
expect(spanToJSON(childSpan).parent_span_id).toBe(span.spanContext().spanId); | ||
startSpan({ name: 'grand child span' }, grandChildSpan => { | ||
expect(spanToJSON(grandChildSpan).parent_span_id).toBe(span.spanContext().spanId); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
it('does not creates a span as child of root span if parentSpanIsAlwaysRootSpan=false', () => { | ||
const options = getDefaultTestClientOptions({ | ||
tracesSampleRate: 1, | ||
parentSpanIsAlwaysRootSpan: false, | ||
}); | ||
client = new TestClient(options); | ||
setCurrentClient(client); | ||
client.init(); | ||
|
||
startSpan({ name: 'parent span' }, span => { | ||
expect(spanToJSON(span).parent_span_id).toBe(undefined); | ||
startSpan({ name: 'child span' }, childSpan => { | ||
expect(spanToJSON(childSpan).parent_span_id).toBe(span.spanContext().spanId); | ||
startSpan({ name: 'grand child span' }, grandChildSpan => { | ||
expect(spanToJSON(grandChildSpan).parent_span_id).toBe(childSpan.spanContext().spanId); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |