Skip to content

Commit 4d8a171

Browse files
fix comments
1 parent 6ed8c1a commit 4d8a171

3 files changed

Lines changed: 24 additions & 28 deletions

File tree

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

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import json
88
import logging
9-
import os
109
import threading
1110
import time
1211
from collections.abc import Callable, Sequence
@@ -19,6 +18,7 @@
1918
from opentelemetry.trace import StatusCode
2019

2120
from .utils import (
21+
get_validated_domain_override,
2222
hex_span_id,
2323
hex_trace_id,
2424
kind_name,
@@ -62,7 +62,7 @@ def __init__(
6262
self._cluster_category = cluster_category
6363
self._use_s2s_endpoint = use_s2s_endpoint
6464
# Read domain override once at initialization
65-
self._domain_override = self._get_validated_domain_override()
65+
self._domain_override = get_validated_domain_override()
6666

6767
# ------------- SpanExporter API -----------------
6868

@@ -150,28 +150,6 @@ def force_flush(self, timeout_millis: int = 30000) -> bool:
150150

151151
# ------------- Helper methods -------------------
152152

153-
@staticmethod
154-
def _get_validated_domain_override() -> str | None:
155-
"""
156-
Get and validate the domain override from environment variable.
157-
158-
Returns:
159-
The validated domain override, or None if not set or invalid.
160-
"""
161-
domain_override = os.getenv("A365_OBSERVABILITY_DOMAIN_OVERRIDE", "").strip()
162-
if not domain_override:
163-
return None
164-
165-
# Basic validation: ensure domain doesn't contain protocol or path separators
166-
if "://" in domain_override or "/" in domain_override:
167-
logger.warning(
168-
f"Invalid domain override '{domain_override}': "
169-
"domain should not contain protocol (://) or path separators (/)"
170-
)
171-
return None
172-
173-
return domain_override
174-
175153
# ------------- HTTP helper ----------------------
176154

177155
@staticmethod

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,28 @@ def partition_by_identity(
142142
return groups
143143

144144

145+
def get_validated_domain_override() -> str | None:
146+
"""
147+
Get and validate the domain override from environment variable.
148+
149+
Returns:
150+
The validated domain override, or None if not set or invalid.
151+
"""
152+
domain_override = os.getenv("A365_OBSERVABILITY_DOMAIN_OVERRIDE", "").strip()
153+
if not domain_override:
154+
return None
155+
156+
# Basic validation: ensure domain doesn't contain protocol or path separators
157+
if "://" in domain_override or "/" in domain_override:
158+
logger.warning(
159+
f"Invalid domain override '{domain_override}': "
160+
"domain should not contain protocol (://) or path separators (/)"
161+
)
162+
return None
163+
164+
return domain_override
165+
166+
145167
def is_agent365_exporter_enabled() -> bool:
146168
"""Check if Agent 365 exporter is enabled."""
147169
# Check environment variable

libraries/microsoft-agents-a365-runtime/microsoft_agents_a365/runtime/environment_utils.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ def get_observability_authentication_scope() -> list[str]:
2424
The scope can be overridden via the A365_OBSERVABILITY_SCOPE_OVERRIDE environment variable
2525
to enable testing against pre-production environments.
2626
27-
Environment Variable:
28-
A365_OBSERVABILITY_SCOPE_OVERRIDE: Full authentication scope URL including the /.default suffix
29-
(e.g., "https://preprod.api.powerplatform.com/.default")
30-
3127
Returns:
3228
list[str]: The authentication scope for the current environment.
3329
"""

0 commit comments

Comments
 (0)