Skip to content

Commit d93e8d0

Browse files
remove island tenant reference
1 parent 261d336 commit d93e8d0

File tree

3 files changed

+139
-218
lines changed

3 files changed

+139
-218
lines changed

libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/exporters/agent365_exporter.py

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
import time
1212
from collections.abc import Callable, Sequence
1313
from typing import Any, final
14-
from urllib.parse import urlparse
1514

1615
import requests
17-
from microsoft_agents_a365.runtime.power_platform_api_discovery import PowerPlatformApiDiscovery
1816
from opentelemetry.sdk.trace import ReadableSpan
1917
from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult
2018
from opentelemetry.trace import StatusCode
@@ -25,6 +23,7 @@
2523
INVOKE_AGENT_OPERATION_NAME,
2624
)
2725
from .utils import (
26+
build_export_url,
2827
get_validated_domain_override,
2928
hex_span_id,
3029
hex_trace_id,
@@ -104,7 +103,7 @@ def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
104103
else:
105104
endpoint = DEFAULT_ENDPOINT_URL
106105

107-
url = self._build_url(endpoint, agent_id)
106+
url = build_export_url(endpoint, agent_id, tenant_id, self._use_s2s_endpoint)
108107

109108
# Debug: Log endpoint being used
110109
logger.info(
@@ -131,18 +130,6 @@ def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
131130
# Basic retry loop
132131
ok = self._post_with_retries(url, body, headers)
133132

134-
# Fallback to IL tenant endpoint if default endpoint failed
135-
# and no domain override was set
136-
if not ok and not self._domain_override:
137-
discovery = PowerPlatformApiDiscovery(self._cluster_category)
138-
fallback_endpoint = discovery.get_tenant_island_cluster_endpoint(tenant_id)
139-
fallback_url = self._build_url(fallback_endpoint, agent_id)
140-
logger.info(
141-
f"Falling back to IL tenant endpoint: {fallback_url} "
142-
f"(tenant: {tenant_id}, agent: {agent_id})"
143-
)
144-
ok = self._post_with_retries(fallback_url, body, headers)
145-
146133
if not ok:
147134
any_failure = True
148135

@@ -166,32 +153,6 @@ def shutdown(self) -> None:
166153
def force_flush(self, timeout_millis: int = 30000) -> bool:
167154
return True
168155

169-
# ------------- Helper methods -------------------
170-
171-
def _build_url(self, endpoint: str, agent_id: str) -> str:
172-
"""Construct the full export URL from endpoint and agent ID.
173-
174-
If the endpoint has a scheme (http:// or https://), use it as-is.
175-
Otherwise, prepend https://.
176-
177-
Args:
178-
endpoint: Base endpoint URL or domain.
179-
agent_id: The agent identifier to include in the URL path.
180-
181-
Returns:
182-
The fully constructed export URL with path and query parameters.
183-
"""
184-
endpoint_path = (
185-
f"/maven/agent365/service/agents/{agent_id}/traces"
186-
if self._use_s2s_endpoint
187-
else f"/maven/agent365/agents/{agent_id}/traces"
188-
)
189-
190-
parsed = urlparse(endpoint)
191-
if parsed.scheme and "://" in endpoint:
192-
return f"{endpoint}{endpoint_path}?api-version=1"
193-
return f"https://{endpoint}{endpoint_path}?api-version=1"
194-
195156
# ------------- HTTP helper ----------------------
196157

197158
@staticmethod

libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/exporters/utils.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,32 @@ def get_validated_domain_override() -> str | None:
197197
return domain_override
198198

199199

200+
def build_export_url(
201+
endpoint: str, agent_id: str, tenant_id: str, use_s2s_endpoint: bool = False
202+
) -> str:
203+
"""Construct the full export URL from endpoint and agent ID.
204+
205+
Args:
206+
endpoint: Base endpoint URL or domain.
207+
agent_id: The agent identifier to include in the URL path.
208+
tenant_id: The tenant identifier to include in the URL path.
209+
use_s2s_endpoint: Whether to use the S2S endpoint path format.
210+
211+
Returns:
212+
The fully constructed export URL with path and query parameters.
213+
"""
214+
endpoint_path = (
215+
f"/observabilityService/tenants/{tenant_id}/agents/{agent_id}/traces"
216+
if use_s2s_endpoint
217+
else f"/observability/tenants/{tenant_id}/agents/{agent_id}/traces"
218+
)
219+
220+
parsed = urlparse(endpoint)
221+
if parsed.scheme and "://" in endpoint:
222+
return f"{endpoint}{endpoint_path}?api-version=1"
223+
return f"https://{endpoint}{endpoint_path}?api-version=1"
224+
225+
200226
def is_agent365_exporter_enabled() -> bool:
201227
"""Check if Agent 365 exporter is enabled."""
202228
# Check environment variable

0 commit comments

Comments
 (0)