-
Notifications
You must be signed in to change notification settings - Fork 807
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: introduces ability to suppress tracing via context #1344
Merged
dyladan
merged 19 commits into
open-telemetry:master
from
michaelgoin:suppress-instrumentation
Aug 25, 2020
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
207dfdc
feat: introduces ability to suppress tracing via context
michaelgoin f5d351c
feat: span processors prevent exporter span generation
michaelgoin 98acb74
style: lint auto-fix
michaelgoin c2ac8b4
Merge branch 'master' into suppress-instrumentation
michaelgoin 4d7e5ea
chore: suppressInstrumentation helper updates and cleanup
michaelgoin 9a351ed
chore: resolve zalgo for InMemory/TracingTest span exporters
michaelgoin df7e85d
Merge branch 'master' into suppress-instrumentation
michaelgoin d588d4f
style: lint auto-fix
michaelgoin 91d1add
Merge branch 'master' into suppress-instrumentation
michaelgoin 9eb2d5e
Merge branch 'master' into suppress-instrumentation
vmarchaud d183bd8
Merge branch 'master' into suppress-instrumentation
vmarchaud 4ff9591
Merge branch 'master' into suppress-instrumentation
michaelgoin 6bb2eb6
refactor: resolves PR feedback
michaelgoin 49f53e4
Merge branch 'suppress-instrumentation' of github.com:michaelgoin/ope…
michaelgoin 74a4000
Merge branch 'master' into suppress-instrumentation
michaelgoin 2866f51
refactor: splits setting of supress instrumentation into two function
michaelgoin 6c81a98
Merge branch 'master' into suppress-instrumentation
michaelgoin cc0249b
refactor: simplifies isInstrumentationSuppressed boolean handling
michaelgoin f125085
style: lint:fix
michaelgoin 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 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,91 @@ | ||
/* | ||
* 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 { | ||
SUPPRESS_INSTRUMENTATION_KEY, | ||
suppressInstrumentation, | ||
unsuppressInstrumentation, | ||
isInstrumentationSuppressed, | ||
} from '../../src/context/context'; | ||
import { Context } from '@opentelemetry/api'; | ||
|
||
describe('Context Helpers', () => { | ||
describe('suppressInstrumentation', () => { | ||
it('should set suppress to true', () => { | ||
const expectedValue = true; | ||
const context = suppressInstrumentation(Context.ROOT_CONTEXT); | ||
|
||
const value = context.getValue(SUPPRESS_INSTRUMENTATION_KEY); | ||
const boolValue = value as boolean; | ||
|
||
assert.equal(boolValue, expectedValue); | ||
}); | ||
}); | ||
|
||
describe('unsuppressInstrumentation', () => { | ||
it('should set suppress to false', () => { | ||
const expectedValue = false; | ||
const context = unsuppressInstrumentation(Context.ROOT_CONTEXT); | ||
|
||
const value = context.getValue(SUPPRESS_INSTRUMENTATION_KEY); | ||
const boolValue = value as boolean; | ||
|
||
assert.equal(boolValue, expectedValue); | ||
}); | ||
}); | ||
|
||
describe('isInstrumentationSuppressed', () => { | ||
it('should get value as bool', () => { | ||
const expectedValue = true; | ||
const context = Context.ROOT_CONTEXT.setValue( | ||
SUPPRESS_INSTRUMENTATION_KEY, | ||
expectedValue | ||
); | ||
|
||
const value = isInstrumentationSuppressed(context); | ||
|
||
assert.equal(value, expectedValue); | ||
}); | ||
|
||
describe('when suppress instrumentation set to null', () => { | ||
const context = Context.ROOT_CONTEXT.setValue( | ||
SUPPRESS_INSTRUMENTATION_KEY, | ||
null | ||
); | ||
|
||
it('should return false', () => { | ||
const value = isInstrumentationSuppressed(context); | ||
|
||
assert.equal(value, false); | ||
}); | ||
}); | ||
|
||
describe('when suppress instrumentation set to undefined', () => { | ||
const context = Context.ROOT_CONTEXT.setValue( | ||
SUPPRESS_INSTRUMENTATION_KEY, | ||
undefined | ||
); | ||
|
||
it('should return false', () => { | ||
const value = isInstrumentationSuppressed(context); | ||
|
||
assert.equal(value, false); | ||
}); | ||
}); | ||
}); | ||
}); |
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
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.
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.
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.
please add some doc
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.
@obecny what sort of doc are you looking for?
do you want a comment on why this is protected? that seems like something that would quickly get out of date with future usages, outside of the obvious fact it is now available to classes extending the InMemorySpanExporter.
or are you looking for something else?
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.
If something is protected its meaning should be documented so that when someone subclasses this they know what the property represents. It could be argued it is obvious in this case, but it is good practice in general.
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.
OK. i don't see that done for any other protected members (non-function) in the code base and somewhat debate the value here but am happy to go along with the standards y'all are looking for.
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.
@michaelgoin I agree we haven't been great at being consistent about this, and in many cases the value is questionable anyways.