From 4f3c67178ff41c080e78c780fe989b71f9b08d22 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Tue, 27 Apr 2021 12:36:47 -0400 Subject: [PATCH] Add Suppress Instrumentation context key --- CHANGELOG.md | 1 + specification/context/context.md | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa2059a6381..6346fb63b2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ release. - Added `OTEL_EXPORTER_JAEGER_TIMEOUT` environment variable. ([#1612](https://github.com/open-telemetry/opentelemetry-specification/pull/1612)) - Added `OTEL_EXPORTER_ZIPKIN_TIMEOUT` environment variable. ([#1636](https://github.com/open-telemetry/opentelemetry-specification/pull/1636)) +- Added Suppress Instrumentation context key. ([#1653](https://github.com/open-telemetry/opentelemetry-specification/pull/1653)) ### Traces diff --git a/specification/context/context.md b/specification/context/context.md index 91c76b51c8c..844b67dbb99 100644 --- a/specification/context/context.md +++ b/specification/context/context.md @@ -15,6 +15,8 @@ Table of Contents - [Get current Context](#get-current-context) - [Attach Context](#attach-context) - [Detach Context](#detach-context) +- [Predefined Keys](#predefined-keys) + - [Suppress Instrumentation](#suppress-instrumentation) @@ -125,3 +127,26 @@ The API MUST accept the following parameters: The API MAY return a value used to check whether the operation was successful or not. + +## Predefined Keys + +The following are predefined keys that may modify the behavior of multiple signals. +For each key, there MUST be corresponding methods to set and get its value. +The key itself MUST NOT be exposed publicly. + +### Suppress Instrumentation + +In some cases it may be useful to temporarily disable instrumentation. +For example, this may be used to prevent span exports from being traced and exported, +or by an instrumentation which wraps a lower-level package which may also be +instrumented in order to prevent duplicate spans. + +If this key is set to `true`, the following behavior is changed: + +- Any `Span` created by `StartSpan` MUST be a non-recording `Span`. +- `Propagator#Inject` MUST NOT modify the carrier. +- `Propagator#Extract` MUST return the `Context` passed to it as an argument unchanged. +- `Metrics` MUST NOT be recorded. + +If this key is not set it is assumed to be `false`. +The `get` method for this key MAY return `false` if the key is unset.