mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-29 05:04:05 +08:00
Add create context key to contrib (#502)
This commit is contained in:
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -6,7 +6,7 @@ on:
|
|||||||
- 'release/*'
|
- 'release/*'
|
||||||
pull_request:
|
pull_request:
|
||||||
env:
|
env:
|
||||||
CORE_REPO_SHA: 3b236f5309c36d089c0d9dc6dc6c985bb1668776
|
CORE_REPO_SHA: c4cdffd0c8bd47b2e5c4f4a823722ca514f10db3
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
@ -43,6 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- `opentelemetry-instrumentation-botocore` now supports
|
- `opentelemetry-instrumentation-botocore` now supports
|
||||||
context propagation for lambda invoke via Payload embedded headers.
|
context propagation for lambda invoke via Payload embedded headers.
|
||||||
([#458](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/458))
|
([#458](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/458))
|
||||||
|
- Added support for CreateKey functionality.
|
||||||
|
([#502](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/502))
|
||||||
|
|
||||||
## [0.21b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.2.0-0.21b0) - 2021-05-11
|
## [0.21b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.2.0-0.21b0) - 2021-05-11
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import threading
|
|||||||
import typing
|
import typing
|
||||||
|
|
||||||
from opentelemetry.context import Context, attach, detach, set_value
|
from opentelemetry.context import Context, attach, detach, set_value
|
||||||
|
from opentelemetry.instrumentation.utils import _SUPPRESS_INSTRUMENTATION_KEY
|
||||||
from opentelemetry.sdk.trace import Span, SpanProcessor
|
from opentelemetry.sdk.trace import Span, SpanProcessor
|
||||||
from opentelemetry.sdk.trace.export import SpanExporter
|
from opentelemetry.sdk.trace.export import SpanExporter
|
||||||
from opentelemetry.trace import INVALID_TRACE_ID
|
from opentelemetry.trace import INVALID_TRACE_ID
|
||||||
@ -163,7 +164,7 @@ class DatadogExportSpanProcessor(SpanProcessor):
|
|||||||
del self.traces_spans_ended_count[trace_id]
|
del self.traces_spans_ended_count[trace_id]
|
||||||
|
|
||||||
if len(export_trace_ids) > 0:
|
if len(export_trace_ids) > 0:
|
||||||
token = attach(set_value("suppress_instrumentation", True))
|
token = attach(set_value(_SUPPRESS_INSTRUMENTATION_KEY, True))
|
||||||
|
|
||||||
for trace_id in export_trace_ids:
|
for trace_id in export_trace_ids:
|
||||||
with self.traces_lock:
|
with self.traces_lock:
|
||||||
|
@ -75,6 +75,7 @@ from opentelemetry.instrumentation.aiohttp_client.package import _instruments
|
|||||||
from opentelemetry.instrumentation.aiohttp_client.version import __version__
|
from opentelemetry.instrumentation.aiohttp_client.version import __version__
|
||||||
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
||||||
from opentelemetry.instrumentation.utils import (
|
from opentelemetry.instrumentation.utils import (
|
||||||
|
_SUPPRESS_INSTRUMENTATION_KEY,
|
||||||
http_status_to_status_code,
|
http_status_to_status_code,
|
||||||
unwrap,
|
unwrap,
|
||||||
)
|
)
|
||||||
@ -155,7 +156,7 @@ def create_trace_config(
|
|||||||
trace_config_ctx: types.SimpleNamespace,
|
trace_config_ctx: types.SimpleNamespace,
|
||||||
params: aiohttp.TraceRequestStartParams,
|
params: aiohttp.TraceRequestStartParams,
|
||||||
):
|
):
|
||||||
if context_api.get_value("suppress_instrumentation"):
|
if context_api.get_value(_SUPPRESS_INSTRUMENTATION_KEY):
|
||||||
trace_config_ctx.span = None
|
trace_config_ctx.span = None
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -248,7 +249,7 @@ def _instrument(
|
|||||||
"""
|
"""
|
||||||
# pylint:disable=unused-argument
|
# pylint:disable=unused-argument
|
||||||
def instrumented_init(wrapped, instance, args, kwargs):
|
def instrumented_init(wrapped, instance, args, kwargs):
|
||||||
if context_api.get_value("suppress_instrumentation"):
|
if context_api.get_value(_SUPPRESS_INSTRUMENTATION_KEY):
|
||||||
return wrapped(*args, **kwargs)
|
return wrapped(*args, **kwargs)
|
||||||
|
|
||||||
trace_configs = list(kwargs.get("trace_configs") or ())
|
trace_configs = list(kwargs.get("trace_configs") or ())
|
||||||
|
@ -30,6 +30,7 @@ from opentelemetry.instrumentation import aiohttp_client
|
|||||||
from opentelemetry.instrumentation.aiohttp_client import (
|
from opentelemetry.instrumentation.aiohttp_client import (
|
||||||
AioHttpClientInstrumentor,
|
AioHttpClientInstrumentor,
|
||||||
)
|
)
|
||||||
|
from opentelemetry.instrumentation.utils import _SUPPRESS_INSTRUMENTATION_KEY
|
||||||
from opentelemetry.semconv.trace import SpanAttributes
|
from opentelemetry.semconv.trace import SpanAttributes
|
||||||
from opentelemetry.test.test_base import TestBase
|
from opentelemetry.test.test_base import TestBase
|
||||||
from opentelemetry.trace import StatusCode
|
from opentelemetry.trace import StatusCode
|
||||||
@ -448,7 +449,7 @@ class TestAioHttpClientInstrumentor(TestBase):
|
|||||||
|
|
||||||
def test_suppress_instrumentation(self):
|
def test_suppress_instrumentation(self):
|
||||||
token = context.attach(
|
token = context.attach(
|
||||||
context.set_value("suppress_instrumentation", True)
|
context.set_value(_SUPPRESS_INSTRUMENTATION_KEY, True)
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
run_with_test_server(
|
run_with_test_server(
|
||||||
@ -462,7 +463,7 @@ class TestAioHttpClientInstrumentor(TestBase):
|
|||||||
async def suppressed_request(server: aiohttp.test_utils.TestServer):
|
async def suppressed_request(server: aiohttp.test_utils.TestServer):
|
||||||
async with aiohttp.test_utils.TestClient(server) as client:
|
async with aiohttp.test_utils.TestClient(server) as client:
|
||||||
token = context.attach(
|
token = context.attach(
|
||||||
context.set_value("suppress_instrumentation", True)
|
context.set_value(_SUPPRESS_INSTRUMENTATION_KEY, True)
|
||||||
)
|
)
|
||||||
await client.get(TestAioHttpClientInstrumentor.URL)
|
await client.get(TestAioHttpClientInstrumentor.URL)
|
||||||
context.detach(token)
|
context.detach(token)
|
||||||
|
@ -58,7 +58,10 @@ from opentelemetry import context as context_api
|
|||||||
from opentelemetry.instrumentation.botocore.package import _instruments
|
from opentelemetry.instrumentation.botocore.package import _instruments
|
||||||
from opentelemetry.instrumentation.botocore.version import __version__
|
from opentelemetry.instrumentation.botocore.version import __version__
|
||||||
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
||||||
from opentelemetry.instrumentation.utils import unwrap
|
from opentelemetry.instrumentation.utils import (
|
||||||
|
_SUPPRESS_INSTRUMENTATION_KEY,
|
||||||
|
unwrap,
|
||||||
|
)
|
||||||
from opentelemetry.propagate import inject
|
from opentelemetry.propagate import inject
|
||||||
from opentelemetry.semconv.trace import SpanAttributes
|
from opentelemetry.semconv.trace import SpanAttributes
|
||||||
from opentelemetry.trace import SpanKind, get_tracer
|
from opentelemetry.trace import SpanKind, get_tracer
|
||||||
@ -128,7 +131,7 @@ class BotocoreInstrumentor(BaseInstrumentor):
|
|||||||
|
|
||||||
# pylint: disable=too-many-branches
|
# pylint: disable=too-many-branches
|
||||||
def _patched_api_call(self, original_func, instance, args, kwargs):
|
def _patched_api_call(self, original_func, instance, args, kwargs):
|
||||||
if context_api.get_value("suppress_instrumentation"):
|
if context_api.get_value(_SUPPRESS_INSTRUMENTATION_KEY):
|
||||||
return original_func(*args, **kwargs)
|
return original_func(*args, **kwargs)
|
||||||
|
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
|
@ -34,6 +34,7 @@ from moto import ( # pylint: disable=import-error
|
|||||||
from opentelemetry import trace as trace_api
|
from opentelemetry import trace as trace_api
|
||||||
from opentelemetry.context import attach, detach, set_value
|
from opentelemetry.context import attach, detach, set_value
|
||||||
from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
|
from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
|
||||||
|
from opentelemetry.instrumentation.utils import _SUPPRESS_INSTRUMENTATION_KEY
|
||||||
from opentelemetry.propagate import get_global_textmap, set_global_textmap
|
from opentelemetry.propagate import get_global_textmap, set_global_textmap
|
||||||
from opentelemetry.semconv.trace import SpanAttributes
|
from opentelemetry.semconv.trace import SpanAttributes
|
||||||
from opentelemetry.test.mock_textmap import MockTextMapPropagator
|
from opentelemetry.test.mock_textmap import MockTextMapPropagator
|
||||||
@ -509,7 +510,7 @@ class TestBotocoreInstrumentor(TestBase):
|
|||||||
xray_client = self.session.create_client(
|
xray_client = self.session.create_client(
|
||||||
"xray", region_name="us-east-1"
|
"xray", region_name="us-east-1"
|
||||||
)
|
)
|
||||||
token = attach(set_value("suppress_instrumentation", True))
|
token = attach(set_value(_SUPPRESS_INSTRUMENTATION_KEY, True))
|
||||||
xray_client.put_trace_segments(TraceSegmentDocuments=["str1"])
|
xray_client.put_trace_segments(TraceSegmentDocuments=["str1"])
|
||||||
xray_client.put_trace_segments(TraceSegmentDocuments=["str2"])
|
xray_client.put_trace_segments(TraceSegmentDocuments=["str2"])
|
||||||
detach(token)
|
detach(token)
|
||||||
|
@ -45,7 +45,10 @@ from opentelemetry import context
|
|||||||
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
||||||
from opentelemetry.instrumentation.requests.package import _instruments
|
from opentelemetry.instrumentation.requests.package import _instruments
|
||||||
from opentelemetry.instrumentation.requests.version import __version__
|
from opentelemetry.instrumentation.requests.version import __version__
|
||||||
from opentelemetry.instrumentation.utils import http_status_to_status_code
|
from opentelemetry.instrumentation.utils import (
|
||||||
|
_SUPPRESS_INSTRUMENTATION_KEY,
|
||||||
|
http_status_to_status_code,
|
||||||
|
)
|
||||||
from opentelemetry.propagate import inject
|
from opentelemetry.propagate import inject
|
||||||
from opentelemetry.semconv.trace import SpanAttributes
|
from opentelemetry.semconv.trace import SpanAttributes
|
||||||
from opentelemetry.trace import SpanKind, get_tracer
|
from opentelemetry.trace import SpanKind, get_tracer
|
||||||
@ -54,7 +57,9 @@ from opentelemetry.util.http import remove_url_credentials
|
|||||||
|
|
||||||
# A key to a context variable to avoid creating duplicate spans when instrumenting
|
# A key to a context variable to avoid creating duplicate spans when instrumenting
|
||||||
# both, Session.request and Session.send, since Session.request calls into Session.send
|
# both, Session.request and Session.send, since Session.request calls into Session.send
|
||||||
_SUPPRESS_HTTP_INSTRUMENTATION_KEY = "suppress_http_instrumentation"
|
_SUPPRESS_HTTP_INSTRUMENTATION_KEY = context.create_key(
|
||||||
|
"suppress_http_instrumentation"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
@ -111,9 +116,9 @@ def _instrument(tracer, span_callback=None, name_callback=None):
|
|||||||
def _instrumented_requests_call(
|
def _instrumented_requests_call(
|
||||||
method: str, url: str, call_wrapped, get_or_create_headers
|
method: str, url: str, call_wrapped, get_or_create_headers
|
||||||
):
|
):
|
||||||
if context.get_value("suppress_instrumentation") or context.get_value(
|
if context.get_value(
|
||||||
_SUPPRESS_HTTP_INSTRUMENTATION_KEY
|
_SUPPRESS_INSTRUMENTATION_KEY
|
||||||
):
|
) or context.get_value(_SUPPRESS_HTTP_INSTRUMENTATION_KEY):
|
||||||
return call_wrapped()
|
return call_wrapped()
|
||||||
|
|
||||||
# See
|
# See
|
||||||
|
@ -21,6 +21,7 @@ import requests
|
|||||||
import opentelemetry.instrumentation.requests
|
import opentelemetry.instrumentation.requests
|
||||||
from opentelemetry import context, trace
|
from opentelemetry import context, trace
|
||||||
from opentelemetry.instrumentation.requests import RequestsInstrumentor
|
from opentelemetry.instrumentation.requests import RequestsInstrumentor
|
||||||
|
from opentelemetry.instrumentation.utils import _SUPPRESS_INSTRUMENTATION_KEY
|
||||||
from opentelemetry.propagate import get_global_textmap, set_global_textmap
|
from opentelemetry.propagate import get_global_textmap, set_global_textmap
|
||||||
from opentelemetry.sdk import resources
|
from opentelemetry.sdk import resources
|
||||||
from opentelemetry.semconv.trace import SpanAttributes
|
from opentelemetry.semconv.trace import SpanAttributes
|
||||||
@ -165,7 +166,7 @@ class RequestsIntegrationTestBase(abc.ABC):
|
|||||||
|
|
||||||
def test_suppress_instrumentation(self):
|
def test_suppress_instrumentation(self):
|
||||||
token = context.attach(
|
token = context.attach(
|
||||||
context.set_value("suppress_instrumentation", True)
|
context.set_value(_SUPPRESS_INSTRUMENTATION_KEY, True)
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
result = self.perform_request(self.URL)
|
result = self.perform_request(self.URL)
|
||||||
|
@ -48,7 +48,10 @@ from opentelemetry import context
|
|||||||
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
||||||
from opentelemetry.instrumentation.urllib.package import _instruments
|
from opentelemetry.instrumentation.urllib.package import _instruments
|
||||||
from opentelemetry.instrumentation.urllib.version import __version__
|
from opentelemetry.instrumentation.urllib.version import __version__
|
||||||
from opentelemetry.instrumentation.utils import http_status_to_status_code
|
from opentelemetry.instrumentation.utils import (
|
||||||
|
_SUPPRESS_INSTRUMENTATION_KEY,
|
||||||
|
http_status_to_status_code,
|
||||||
|
)
|
||||||
from opentelemetry.propagate import inject
|
from opentelemetry.propagate import inject
|
||||||
from opentelemetry.semconv.trace import SpanAttributes
|
from opentelemetry.semconv.trace import SpanAttributes
|
||||||
from opentelemetry.trace import SpanKind, get_tracer
|
from opentelemetry.trace import SpanKind, get_tracer
|
||||||
@ -56,7 +59,10 @@ from opentelemetry.trace.status import Status
|
|||||||
from opentelemetry.util.http import remove_url_credentials
|
from opentelemetry.util.http import remove_url_credentials
|
||||||
|
|
||||||
# A key to a context variable to avoid creating duplicate spans when instrumenting
|
# A key to a context variable to avoid creating duplicate spans when instrumenting
|
||||||
_SUPPRESS_HTTP_INSTRUMENTATION_KEY = "suppress_http_instrumentation"
|
# both, Session.request and Session.send, since Session.request calls into Session.send
|
||||||
|
_SUPPRESS_HTTP_INSTRUMENTATION_KEY = context.create_key(
|
||||||
|
"suppress_http_instrumentation"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class URLLibInstrumentor(BaseInstrumentor):
|
class URLLibInstrumentor(BaseInstrumentor):
|
||||||
@ -129,9 +135,9 @@ def _instrument(tracer, span_callback=None, name_callback=None):
|
|||||||
def _instrumented_open_call(
|
def _instrumented_open_call(
|
||||||
_, request, call_wrapped, get_or_create_headers
|
_, request, call_wrapped, get_or_create_headers
|
||||||
): # pylint: disable=too-many-locals
|
): # pylint: disable=too-many-locals
|
||||||
if context.get_value("suppress_instrumentation") or context.get_value(
|
if context.get_value(
|
||||||
_SUPPRESS_HTTP_INSTRUMENTATION_KEY
|
_SUPPRESS_INSTRUMENTATION_KEY
|
||||||
):
|
) or context.get_value(_SUPPRESS_HTTP_INSTRUMENTATION_KEY):
|
||||||
return call_wrapped()
|
return call_wrapped()
|
||||||
|
|
||||||
method = request.get_method().upper()
|
method = request.get_method().upper()
|
||||||
|
@ -28,6 +28,7 @@ from opentelemetry import context, trace
|
|||||||
from opentelemetry.instrumentation.urllib import ( # pylint: disable=no-name-in-module,import-error
|
from opentelemetry.instrumentation.urllib import ( # pylint: disable=no-name-in-module,import-error
|
||||||
URLLibInstrumentor,
|
URLLibInstrumentor,
|
||||||
)
|
)
|
||||||
|
from opentelemetry.instrumentation.utils import _SUPPRESS_INSTRUMENTATION_KEY
|
||||||
from opentelemetry.propagate import get_global_textmap, set_global_textmap
|
from opentelemetry.propagate import get_global_textmap, set_global_textmap
|
||||||
from opentelemetry.sdk import resources
|
from opentelemetry.sdk import resources
|
||||||
from opentelemetry.semconv.trace import SpanAttributes
|
from opentelemetry.semconv.trace import SpanAttributes
|
||||||
@ -198,7 +199,7 @@ class RequestsIntegrationTestBase(abc.ABC):
|
|||||||
|
|
||||||
def test_suppress_instrumentation(self):
|
def test_suppress_instrumentation(self):
|
||||||
token = context.attach(
|
token = context.attach(
|
||||||
context.set_value("suppress_instrumentation", True)
|
context.set_value(_SUPPRESS_INSTRUMENTATION_KEY, True)
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
result = self.perform_request(self.URL)
|
result = self.perform_request(self.URL)
|
||||||
|
@ -56,6 +56,7 @@ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|||||||
from opentelemetry.instrumentation.urllib3.package import _instruments
|
from opentelemetry.instrumentation.urllib3.package import _instruments
|
||||||
from opentelemetry.instrumentation.urllib3.version import __version__
|
from opentelemetry.instrumentation.urllib3.version import __version__
|
||||||
from opentelemetry.instrumentation.utils import (
|
from opentelemetry.instrumentation.utils import (
|
||||||
|
_SUPPRESS_INSTRUMENTATION_KEY,
|
||||||
http_status_to_status_code,
|
http_status_to_status_code,
|
||||||
unwrap,
|
unwrap,
|
||||||
)
|
)
|
||||||
@ -64,7 +65,11 @@ from opentelemetry.semconv.trace import SpanAttributes
|
|||||||
from opentelemetry.trace import Span, SpanKind, get_tracer
|
from opentelemetry.trace import Span, SpanKind, get_tracer
|
||||||
from opentelemetry.trace.status import Status
|
from opentelemetry.trace.status import Status
|
||||||
|
|
||||||
_SUPPRESS_HTTP_INSTRUMENTATION_KEY = "suppress_http_instrumentation"
|
# A key to a context variable to avoid creating duplicate spans when instrumenting
|
||||||
|
# both, Session.request and Session.send, since Session.request calls into Session.send
|
||||||
|
_SUPPRESS_HTTP_INSTRUMENTATION_KEY = context.create_key(
|
||||||
|
"suppress_http_instrumentation"
|
||||||
|
)
|
||||||
|
|
||||||
_UrlFilterT = typing.Optional[typing.Callable[[str], str]]
|
_UrlFilterT = typing.Optional[typing.Callable[[str], str]]
|
||||||
_SpanNameT = typing.Optional[
|
_SpanNameT = typing.Optional[
|
||||||
@ -214,7 +219,7 @@ def _apply_response(span: Span, response: urllib3.response.HTTPResponse):
|
|||||||
|
|
||||||
def _is_instrumentation_suppressed() -> bool:
|
def _is_instrumentation_suppressed() -> bool:
|
||||||
return bool(
|
return bool(
|
||||||
context.get_value("suppress_instrumentation")
|
context.get_value(_SUPPRESS_INSTRUMENTATION_KEY)
|
||||||
or context.get_value(_SUPPRESS_HTTP_INSTRUMENTATION_KEY)
|
or context.get_value(_SUPPRESS_HTTP_INSTRUMENTATION_KEY)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,7 +20,11 @@ import urllib3
|
|||||||
import urllib3.exceptions
|
import urllib3.exceptions
|
||||||
|
|
||||||
from opentelemetry import context, trace
|
from opentelemetry import context, trace
|
||||||
from opentelemetry.instrumentation.urllib3 import URLLib3Instrumentor
|
from opentelemetry.instrumentation.urllib3 import (
|
||||||
|
_SUPPRESS_HTTP_INSTRUMENTATION_KEY,
|
||||||
|
URLLib3Instrumentor,
|
||||||
|
)
|
||||||
|
from opentelemetry.instrumentation.utils import _SUPPRESS_INSTRUMENTATION_KEY
|
||||||
from opentelemetry.propagate import get_global_textmap, set_global_textmap
|
from opentelemetry.propagate import get_global_textmap, set_global_textmap
|
||||||
from opentelemetry.semconv.trace import SpanAttributes
|
from opentelemetry.semconv.trace import SpanAttributes
|
||||||
from opentelemetry.test.mock_textmap import MockTextMapPropagator
|
from opentelemetry.test.mock_textmap import MockTextMapPropagator
|
||||||
@ -165,8 +169,8 @@ class TestURLLib3Instrumentor(TestBase):
|
|||||||
|
|
||||||
def test_suppress_instrumntation(self):
|
def test_suppress_instrumntation(self):
|
||||||
suppression_keys = (
|
suppression_keys = (
|
||||||
"suppress_instrumentation",
|
_SUPPRESS_HTTP_INSTRUMENTATION_KEY,
|
||||||
"suppress_http_instrumentation",
|
_SUPPRESS_INSTRUMENTATION_KEY,
|
||||||
)
|
)
|
||||||
for key in suppression_keys:
|
for key in suppression_keys:
|
||||||
self.memory_exporter.clear()
|
self.memory_exporter.clear()
|
||||||
|
@ -16,8 +16,14 @@ from typing import Dict, Sequence
|
|||||||
|
|
||||||
from wrapt import ObjectProxy
|
from wrapt import ObjectProxy
|
||||||
|
|
||||||
|
from opentelemetry.context import create_key
|
||||||
from opentelemetry.trace import StatusCode
|
from opentelemetry.trace import StatusCode
|
||||||
|
|
||||||
|
# FIXME This is a temporary location for the suppress instrumentation key.
|
||||||
|
# Once the decision around how to suppress instrumentation is made in the
|
||||||
|
# spec, this key should be moved accordingly.
|
||||||
|
_SUPPRESS_INSTRUMENTATION_KEY = create_key("suppress_instrumentation")
|
||||||
|
|
||||||
|
|
||||||
def extract_attributes_from_object(
|
def extract_attributes_from_object(
|
||||||
obj: any, attributes: Sequence[str], existing: Dict[str, str] = None
|
obj: any, attributes: Sequence[str], existing: Dict[str, str] = None
|
||||||
|
9
tox.ini
9
tox.ini
@ -228,11 +228,10 @@ commands_pre =
|
|||||||
; cases but it saves a lot of boilerplate in this file.
|
; cases but it saves a lot of boilerplate in this file.
|
||||||
test: pip install {toxinidir}/opentelemetry-python-core/opentelemetry-api[test]
|
test: pip install {toxinidir}/opentelemetry-python-core/opentelemetry-api[test]
|
||||||
test: pip install {toxinidir}/opentelemetry-python-core/opentelemetry-semantic-conventions[test]
|
test: pip install {toxinidir}/opentelemetry-python-core/opentelemetry-semantic-conventions[test]
|
||||||
|
test: pip install {toxinidir}/opentelemetry-instrumentation[test]
|
||||||
test: pip install {toxinidir}/opentelemetry-python-core/opentelemetry-sdk[test]
|
test: pip install {toxinidir}/opentelemetry-python-core/opentelemetry-sdk[test]
|
||||||
test: pip install {toxinidir}/opentelemetry-python-core/tests/util[test]
|
test: pip install {toxinidir}/opentelemetry-python-core/tests/util[test]
|
||||||
|
|
||||||
test: pip install {toxinidir}/opentelemetry-instrumentation[test]
|
|
||||||
|
|
||||||
celery: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-celery[test]
|
celery: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-celery[test]
|
||||||
|
|
||||||
grpc: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-grpc[test]
|
grpc: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-grpc[test]
|
||||||
@ -325,8 +324,8 @@ deps =
|
|||||||
commands_pre =
|
commands_pre =
|
||||||
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-api
|
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-api
|
||||||
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-semantic-conventions
|
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-semantic-conventions
|
||||||
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-sdk
|
|
||||||
python -m pip install {toxinidir}/opentelemetry-instrumentation
|
python -m pip install {toxinidir}/opentelemetry-instrumentation
|
||||||
|
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-sdk
|
||||||
python -m pip install {toxinidir}/util/opentelemetry-util-http
|
python -m pip install {toxinidir}/util/opentelemetry-util-http
|
||||||
|
|
||||||
changedir = docs
|
changedir = docs
|
||||||
@ -352,9 +351,9 @@ commands_pre =
|
|||||||
sudo apt-get install libsnappy-dev
|
sudo apt-get install libsnappy-dev
|
||||||
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-api
|
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-api
|
||||||
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-semantic-conventions
|
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-semantic-conventions
|
||||||
|
python -m pip install -e {toxinidir}/opentelemetry-instrumentation[test]
|
||||||
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-sdk
|
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-sdk
|
||||||
python -m pip install {toxinidir}/opentelemetry-python-core/tests/util
|
python -m pip install {toxinidir}/opentelemetry-python-core/tests/util
|
||||||
python -m pip install -e {toxinidir}/opentelemetry-instrumentation[test]
|
|
||||||
python -m pip install -e {toxinidir}/util/opentelemetry-util-http[test]
|
python -m pip install -e {toxinidir}/util/opentelemetry-util-http[test]
|
||||||
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-wsgi[test]
|
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-wsgi[test]
|
||||||
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-dbapi[test]
|
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-dbapi[test]
|
||||||
@ -420,9 +419,9 @@ changedir =
|
|||||||
commands_pre =
|
commands_pre =
|
||||||
pip install -e {toxinidir}/opentelemetry-python-core/opentelemetry-api \
|
pip install -e {toxinidir}/opentelemetry-python-core/opentelemetry-api \
|
||||||
-e {toxinidir}/opentelemetry-python-core/opentelemetry-semantic-conventions \
|
-e {toxinidir}/opentelemetry-python-core/opentelemetry-semantic-conventions \
|
||||||
|
-e {toxinidir}/opentelemetry-instrumentation \
|
||||||
-e {toxinidir}/opentelemetry-python-core/opentelemetry-sdk \
|
-e {toxinidir}/opentelemetry-python-core/opentelemetry-sdk \
|
||||||
-e {toxinidir}/opentelemetry-python-core/tests/util \
|
-e {toxinidir}/opentelemetry-python-core/tests/util \
|
||||||
-e {toxinidir}/opentelemetry-instrumentation \
|
|
||||||
-e {toxinidir}/instrumentation/opentelemetry-instrumentation-asyncpg \
|
-e {toxinidir}/instrumentation/opentelemetry-instrumentation-asyncpg \
|
||||||
-e {toxinidir}/instrumentation/opentelemetry-instrumentation-celery \
|
-e {toxinidir}/instrumentation/opentelemetry-instrumentation-celery \
|
||||||
-e {toxinidir}/instrumentation/opentelemetry-instrumentation-dbapi \
|
-e {toxinidir}/instrumentation/opentelemetry-instrumentation-dbapi \
|
||||||
|
Reference in New Issue
Block a user