-
Notifications
You must be signed in to change notification settings - Fork 983
Add tracing suppresing for Metrics Export #3332
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
legendecas
merged 20 commits into
open-telemetry:main
from
hectorhdzg:hectorjavierhdzg/suppress
Oct 21, 2022
Merged
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b1f6992
Add tracing suppresing for Metrics Export
hectorhdzg c948fa9
Add changelog
hectorhdzg 555ff46
Merge branch 'main' into hectorjavierhdzg/suppress
hectorhdzg 99c2c78
Addressing comments
hectorhdzg c0a81d0
Lint
hectorhdzg f8661d5
Merge branch 'main' into hectorjavierhdzg/suppress
hectorhdzg 86a9c20
Adding internal tsdoc
hectorhdzg 3b9b20b
Update
hectorhdzg a5d1291
Moved to internal folder
hectorhdzg 7cf89d5
Add internal namespace
hectorhdzg aeb33e2
Lint
hectorhdzg 799add6
Return promise in _export
hectorhdzg fa08664
Merge branch 'main' into hectorjavierhdzg/suppress
hectorhdzg 9a55db5
lint
hectorhdzg b5427ce
Addressing comments
hectorhdzg be123f1
Adding internal tag back
hectorhdzg 17948ba
Lint
hectorhdzg 9d92bb1
lint
hectorhdzg 00614a1
Merge branch 'main' into hectorjavierhdzg/suppress
legendecas 30a1dca
Merge branch 'main' into hectorjavierhdzg/suppress
hectorhdzg 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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { context } from '@opentelemetry/api'; | ||
| import { ExportResult } from '../ExportResult'; | ||
| import { suppressTracing } from '../trace/suppress-tracing'; | ||
|
|
||
| export interface Exporter<T> { | ||
| export(arg: T, resultCallback: (result: ExportResult) => void): void; | ||
| } | ||
|
|
||
| /** | ||
| * Internal shared functionality used by Exporters while exporting data, including suppresion of Traces. | ||
| */ | ||
| export function _export<T>(exporter: Exporter<T>, arg: T, resultCallback: (result: ExportResult) => void): void { | ||
hectorhdzg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // prevent downstream exporter calls from generating spans | ||
| context.with(suppressTracing(context.active()), () => { | ||
| exporter.export(arg, resultCallback); | ||
| }); | ||
| } | ||
44 changes: 44 additions & 0 deletions
44
packages/opentelemetry-core/test/internal/exporter.test.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,44 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import * as assert from 'assert'; | ||
| import * as sinon from 'sinon'; | ||
| import { ExportResult, ExportResultCode } from '../../src'; | ||
| import * as suppress from '../../src/trace/suppress-tracing'; | ||
| import { _export } from '../../src/internal/exporter'; | ||
|
|
||
| describe('exporter', () => { | ||
| const sandbox = sinon.createSandbox(); | ||
|
|
||
| afterEach(() => { | ||
| sandbox.restore(); | ||
| }); | ||
|
|
||
| class TestExporter { | ||
| export(arg: any, resultCallback: (result: ExportResult) => void) { | ||
| resultCallback({ code: ExportResultCode.SUCCESS }); | ||
| } | ||
| } | ||
|
|
||
| it('_export should suppress tracing', done => { | ||
| const suppressSpy = sandbox.spy(suppress, 'suppressTracing'); | ||
| const exporter = new TestExporter(); | ||
| _export(exporter, ['Test1'], (result: ExportResult) => { | ||
| assert.ok(suppressSpy.calledOnce); | ||
| done(); | ||
| }); | ||
| }); | ||
| }); |
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
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.