Skip to content

Commit 29a4ab2

Browse files
committed
build(a2a): add a2a deps and mitigate otel conflict
1 parent 68740c5 commit 29a4ab2

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

pyproject.toml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ dependencies = [
3535
"watchdog>=6.0.0,<7.0.0",
3636
"opentelemetry-api>=1.30.0,<2.0.0",
3737
"opentelemetry-sdk>=1.30.0,<2.0.0",
38-
"opentelemetry-exporter-otlp-proto-http>=1.30.0,<2.0.0",
3938
]
4039

4140
[project.urls]
@@ -78,13 +77,23 @@ ollama = [
7877
openai = [
7978
"openai>=1.68.0,<2.0.0",
8079
]
80+
otel = [
81+
"opentelemetry-exporter-otlp-proto-http>=1.30.0,<2.0.0",
82+
]
83+
a2a = [
84+
"a2a-sdk>=0.2.6",
85+
"uvicorn>=0.34.2",
86+
"httpx>=0.28.1",
87+
"fastapi>=0.115.12",
88+
"starlette>=0.46.2",
89+
]
8190

8291
[tool.hatch.version]
8392
# Tells Hatch to use your version control system (git) to determine the version.
8493
source = "vcs"
8594

8695
[tool.hatch.envs.hatch-static-analysis]
87-
features = ["anthropic", "litellm", "llamaapi", "ollama", "openai"]
96+
features = ["anthropic", "litellm", "llamaapi", "ollama", "openai", "otel"]
8897
dependencies = [
8998
"mypy>=1.15.0,<2.0.0",
9099
"ruff>=0.11.6,<0.12.0",
@@ -107,7 +116,7 @@ lint-fix = [
107116
]
108117

109118
[tool.hatch.envs.hatch-test]
110-
features = ["anthropic", "litellm", "llamaapi", "ollama", "openai"]
119+
features = ["anthropic", "litellm", "llamaapi", "ollama", "openai", "otel"]
111120
extra-dependencies = [
112121
"moto>=5.1.0,<6.0.0",
113122
"pytest>=8.0.0,<9.0.0",
@@ -123,8 +132,11 @@ extra-args = [
123132

124133
[tool.hatch.envs.dev]
125134
dev-mode = true
126-
features = ["dev", "docs", "anthropic", "litellm", "llamaapi", "ollama"]
135+
features = ["dev", "docs", "anthropic", "litellm", "llamaapi", "ollama", "otel"]
127136

137+
[tool.hatch.envs.a2a]
138+
dev-mode = true
139+
features = ["dev", "docs", "anthropic", "litellm", "llamaapi", "ollama", "a2a"]
128140

129141

130142
[[tool.hatch.envs.hatch-test.matrix]]

src/strands/telemetry/tracer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import opentelemetry.trace as trace_api
1515
from opentelemetry import propagate
1616
from opentelemetry.baggage.propagation import W3CBaggagePropagator
17-
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
1817
from opentelemetry.propagators.composite import CompositePropagator
1918
from opentelemetry.sdk.resources import Resource
2019
from opentelemetry.sdk.trace import TracerProvider as SDKTracerProvider
@@ -183,6 +182,8 @@ def _initialize_tracer(self) -> None:
183182
# Add OTLP exporter if endpoint is provided
184183
if self.otlp_endpoint and self.tracer_provider:
185184
try:
185+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
186+
186187
# Ensure endpoint has the right format
187188
endpoint = self.otlp_endpoint
188189
if not endpoint.endswith("/v1/traces") and not endpoint.endswith("/traces"):
@@ -294,7 +295,7 @@ def _end_span(
294295
finally:
295296
span.end()
296297
# Force flush to ensure spans are exported
297-
if self.tracer_provider and hasattr(self.tracer_provider, 'force_flush'):
298+
if self.tracer_provider and hasattr(self.tracer_provider, "force_flush"):
298299
try:
299300
self.tracer_provider.force_flush()
300301
except Exception as e:

tests-integ/test_mcp_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def test_can_reuse_mcp_client():
104104

105105

106106
@pytest.mark.skipif(
107-
condition=os.environ.get("GITHUB_ACTIONS") == 'true',
108-
reason="streamable transport is failing in GitHub actions, debugging if linux compatibility issue"
107+
condition=os.environ.get("GITHUB_ACTIONS") == "true",
108+
reason="streamable transport is failing in GitHub actions, debugging if linux compatibility issue",
109109
)
110110
def test_streamable_http_mcp_client():
111111
server_thread = threading.Thread(

tests/strands/telemetry/test_tracer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def mock_set_tracer_provider():
5858

5959
@pytest.fixture
6060
def mock_otlp_exporter():
61-
with mock.patch("strands.telemetry.tracer.OTLPSpanExporter") as mock_exporter:
61+
with mock.patch("opentelemetry.exporter.otlp.proto.http.trace_exporter.OTLPSpanExporter") as mock_exporter:
6262
yield mock_exporter
6363

6464

0 commit comments

Comments
 (0)