Skip to content

Commit 1e39ed0

Browse files
committed
refactor(otel): remove botocore registration
1 parent 92faeef commit 1e39ed0

7 files changed

Lines changed: 48 additions & 86 deletions

File tree

packages/aws-durable-execution-sdk-python-otel/pyproject.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ dependencies = [
3232
otel-invocation = "aws_durable_execution_sdk_python_otel.plugin_provider:INVOCATION_OTEL_PLUGIN_PROVIDER"
3333
otel-execution = "aws_durable_execution_sdk_python_otel.plugin_provider:EXECUTION_OTEL_PLUGIN_PROVIDER"
3434

35-
[project.optional-dependencies]
36-
# Optional AWS SDK instrumentation for the global provider path. The
37-
# instrumentations module degrades gracefully when it is absent.
38-
instrumentation = [
39-
"opentelemetry-instrumentation-botocore",
40-
]
41-
4235
[project.urls]
4336
Documentation = "https://github.com/aws/aws-durable-execution-sdk-python#readme"
4437
Issues = "https://github.com/aws/aws-durable-execution-sdk-python/issues"

packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
from aws_durable_execution_sdk_python_otel.otel_plugin_config import (
1818
OtelPluginConfig,
1919
)
20-
from aws_durable_execution_sdk_python_otel.instrumentations import (
21-
register_standalone_instrumentations,
22-
)
2320
from aws_durable_execution_sdk_python_otel.log_filter import (
2421
OtelContextLogFilter,
2522
install_log_filter,
@@ -46,7 +43,6 @@
4643
"derive_workflow_span_id",
4744
"install_log_filter",
4845
"operation_id_to_span_id",
49-
"register_standalone_instrumentations",
5046
"w3c_client_context_extractor",
5147
"xray_context_extractor",
5248
]

packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel/execution_plugin.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@
6464
operation_id_to_span_id,
6565
)
6666
from aws_durable_execution_sdk_python_otel.otel_plugin_config import OtelPluginConfig
67-
from aws_durable_execution_sdk_python_otel.instrumentations import (
68-
register_standalone_instrumentations,
69-
)
7067
from aws_durable_execution_sdk_python_otel.log_filter import install_log_filter
7168
from aws_durable_execution_sdk_python_otel.provider import create_tracer_provider
7269

@@ -112,11 +109,6 @@ def __init__(self, config: OtelPluginConfig | None = None) -> None:
112109
self._id_generator = DeterministicIdGenerator()
113110
self._bind_sdk_tracer()
114111

115-
try:
116-
register_standalone_instrumentations(result)
117-
except Exception:
118-
logger.exception("Failed to register standalone instrumentations")
119-
120112
# Per-invocation state.
121113
self._execution_arn = ""
122114
self._execution_trace_id: int | None = None

packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel/instrumentations.py

Lines changed: 0 additions & 58 deletions
This file was deleted.

packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel/invocation_plugin.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@
4646
from aws_durable_execution_sdk_python_otel.log_filter import install_log_filter
4747
from aws_durable_execution_sdk_python_otel.otel_plugin_config import OtelPluginConfig
4848
from aws_durable_execution_sdk_python_otel.provider import create_tracer_provider
49-
from aws_durable_execution_sdk_python_otel.instrumentations import (
50-
register_standalone_instrumentations,
51-
)
5249

5350

5451
logger = logging.getLogger(__name__)
@@ -121,11 +118,6 @@ def __init__(self, config: OtelPluginConfig | None = None) -> None:
121118
self._id_generator = DeterministicIdGenerator()
122119
self._bind_sdk_tracer()
123120

124-
try:
125-
register_standalone_instrumentations(result)
126-
except Exception:
127-
logger.exception("Failed to register standalone instrumentations")
128-
129121
# per invocation status:
130122
self._execution_arn = ""
131123
self._execution_trace_id: int | None = None
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"""Tests for application ownership of OpenTelemetry instrumentation."""
2+
3+
from __future__ import annotations
4+
5+
import sys
6+
from types import ModuleType
7+
8+
import pytest
9+
from opentelemetry import trace
10+
from opentelemetry.sdk.trace import TracerProvider
11+
12+
from aws_durable_execution_sdk_python_otel.execution_plugin import ExecutionOtelPlugin
13+
from aws_durable_execution_sdk_python_otel.invocation_plugin import InvocationOtelPlugin
14+
from aws_durable_execution_sdk_python_otel.otel_plugin_config import OtelPluginConfig
15+
16+
17+
PluginType = type[ExecutionOtelPlugin] | type[InvocationOtelPlugin]
18+
19+
20+
@pytest.mark.parametrize(
21+
"plugin_type",
22+
[ExecutionOtelPlugin, InvocationOtelPlugin],
23+
)
24+
def test_plugin_does_not_register_botocore_instrumentation(
25+
plugin_type: PluginType,
26+
monkeypatch: pytest.MonkeyPatch,
27+
) -> None:
28+
provider = TracerProvider()
29+
monkeypatch.setattr(trace, "get_tracer_provider", lambda: provider)
30+
instrument_calls: list[dict[str, object]] = []
31+
32+
class BotocoreInstrumentor:
33+
is_instrumented_by_opentelemetry = False
34+
35+
def instrument(self, **kwargs: object) -> None:
36+
instrument_calls.append(kwargs)
37+
38+
botocore_module = ModuleType("opentelemetry.instrumentation.botocore")
39+
setattr(botocore_module, "BotocoreInstrumentor", BotocoreInstrumentor)
40+
monkeypatch.setitem(
41+
sys.modules,
42+
"opentelemetry.instrumentation.botocore",
43+
botocore_module,
44+
)
45+
46+
plugin_type(OtelPluginConfig(enrich_logger=False))
47+
48+
assert instrument_calls == []

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ extra-dependencies = [
4949
"pytest",
5050
"boto3-stubs[lambda]",
5151
"opentelemetry-sdk>=1.20.0",
52-
"opentelemetry-instrumentation-botocore",
5352
]
5453

5554
[tool.hatch.envs.types.scripts]

0 commit comments

Comments
 (0)