-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[instrumentation] - Add integration tests #20462
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
Merged
maorleger
merged 9 commits into
Azure:main
from
maorleger:integration-test-opentelemetry
Feb 28, 2022
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
49687a5
wip
maorleger eca515d
wip; working integration tests
maorleger fe57baa
finish up
maorleger 9257ed2
sort package.json
maorleger e580eb7
remove unnecessary packages
maorleger a567fa6
move some files around
maorleger ff38eda
Remove console.log
maorleger e7c987c
add tracking item, only replace provider in browser
maorleger 599cbcd
rename per feedback
maorleger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
53 changes: 53 additions & 0 deletions
53
...tation/opentelemetry-instrumentation-azure-sdk/test/internal/node/instrumentation.spec.ts
This file contains hidden or 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,53 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { SpanKind, SpanStatusCode } from "@opentelemetry/api"; | ||
| import { TestClient, tracingClientAttributes } from "../../public/util/testClient"; | ||
|
|
||
| import { assert } from "chai"; | ||
| import { inMemoryExporter } from "../../public/util/setup"; | ||
|
|
||
| describe("instrumentation end-to-end tests", () => { | ||
| beforeEach(() => { | ||
| inMemoryExporter.reset(); | ||
| }); | ||
|
|
||
| // This is node-only since we use the BasicTracerProvider in the browser | ||
| // which does not set up a context manager. Altenatively we can always pull in | ||
| // @opentelemetry/sdk-trace-web but it did not feel necessary at this time. | ||
| describe("with a configured client", () => { | ||
| it("works when using withSpan", async () => { | ||
| await new TestClient().exampleOperation(); | ||
| const spans = inMemoryExporter.getFinishedSpans(); | ||
| assert.lengthOf(spans, 3); | ||
| const [coreRestPipeline, inner, outer] = spans; | ||
|
|
||
| // Check parenting chain | ||
| assert.equal(coreRestPipeline.parentSpanId, inner.spanContext().spanId); | ||
| assert.equal(inner.parentSpanId, outer.spanContext().spanId); | ||
| assert.notExists(outer.parentSpanId); | ||
|
|
||
| // Check default span kind | ||
| assert.equal(outer.kind, SpanKind.INTERNAL); | ||
|
|
||
| // Check specified span kind | ||
| assert.equal(inner.kind, SpanKind.CLIENT); | ||
|
|
||
| // Check status | ||
| assert.deepEqual(coreRestPipeline.status, { code: SpanStatusCode.OK }); | ||
| assert.deepEqual(inner.status, { code: SpanStatusCode.OK }); | ||
| assert.deepEqual(outer.status, { code: SpanStatusCode.OK }); | ||
|
|
||
| // Check instrumentationLibrary | ||
| assert.deepEqual(outer.instrumentationLibrary, { | ||
| name: tracingClientAttributes.packageName, | ||
| version: tracingClientAttributes.packageVersion, | ||
| }); | ||
|
|
||
| // Check attributes on all spans | ||
| assert.equal(coreRestPipeline.attributes["az.namespace"], tracingClientAttributes.namespace); | ||
| assert.equal(inner.attributes["az.namespace"], tracingClientAttributes.namespace); | ||
| assert.equal(outer.attributes["az.namespace"], tracingClientAttributes.namespace); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.