Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
groups = partition_by_identity(spans)
if not groups:
# No spans with identity; treat as success
logger.debug("No spans with tenant/agent identity found; nothing exported.")
logger.info("No spans with tenant/agent identity found; nothing exported.")
return SpanExportResult.SUCCESS

# Debug: Log number of groups and total span count
total_spans = sum(len(activities) for activities in groups.values())
logger.debug(
logger.info(
f"Found {len(groups)} identity groups with {total_spans} total spans to export"
)

Expand All @@ -94,7 +94,7 @@ def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
url = f"https://{endpoint}{endpoint_path}?api-version=1"

# Debug: Log endpoint being used
logger.debug(
logger.info(
f"Exporting {len(activities)} spans to endpoint: {url} "
f"(tenant: {tenant_id}, agent: {agent_id})"
)
Expand All @@ -104,9 +104,9 @@ def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
token = self._token_resolver(agent_id, tenant_id)
if token:
headers["authorization"] = f"Bearer {token}"
logger.debug(f"Token resolved successfully for agent {agent_id}")
logger.info(f"Token resolved successfully for agent {agent_id}")
else:
logger.debug(f"No token returned for agent {agent_id}")
logger.info(f"No token returned for agent {agent_id}")
except Exception as e:
# If token resolution fails, treat as failure for this group
logger.error(
Expand Down Expand Up @@ -168,7 +168,7 @@ def _post_with_retries(self, url: str, body: str, headers: dict[str, str]) -> bo

# 2xx => success
if 200 <= resp.status_code < 300:
logger.debug(
logger.info(
f"HTTP {resp.status_code} success on attempt {attempt + 1}. "
f"Correlation ID: {correlation_id}. "
f"Response: {self._truncate_text(resp.text, 200)}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def __init__(
# Log span creation
if self._span:
span_id = f"{self._span.context.span_id:016x}" if self._span.context else "unknown"
logger.debug(f"Span started: '{activity_name}' ({span_id})")
logger.info(f"Span started: '{activity_name}' ({span_id})")
else:
logger.error(f"Failed to create span: '{activity_name}' - tracer returned None")

Expand Down Expand Up @@ -222,7 +222,7 @@ def _end(self) -> None:
if self._span and self._is_telemetry_enabled() and not self._has_ended:
self._has_ended = True
span_id = f"{self._span.context.span_id:016x}" if self._span.context else "unknown"
logger.debug(f"Span ended: '{self._span.name}' ({span_id})")
logger.info(f"Span ended: '{self._span.name}' ({span_id})")

self._span.end()

Expand Down
16 changes: 8 additions & 8 deletions tests/observability/core/test_agent365_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,23 +335,23 @@ def test_export_logging(self, mock_discovery, mock_logger):
# Verify logging calls
expected_log_calls = [
# Should log groups found
unittest.mock.call.debug("Found 1 identity groups with 2 total spans to export"),
unittest.mock.call.info("Found 1 identity groups with 2 total spans to export"),
# Should log endpoint being used
unittest.mock.call.debug(
unittest.mock.call.info(
"Exporting 2 spans to endpoint: https://test-endpoint.com/maven/agent365/agents/test-agent-456/traces?api-version=1 "
"(tenant: test-tenant-123, agent: test-agent-456)"
),
# Should log token resolution success
unittest.mock.call.debug("Token resolved successfully for agent test-agent-456"),
unittest.mock.call.info("Token resolved successfully for agent test-agent-456"),
# Should log HTTP success
unittest.mock.call.debug(
unittest.mock.call.info(
"HTTP 200 success on attempt 1. Correlation ID: test-correlation-123. Response: success"
),
]

# Check that all expected debug calls were made
# Check that all expected info calls were made
for expected_call in expected_log_calls:
self.assertIn(expected_call, mock_logger.debug.call_args_list)
self.assertIn(expected_call, mock_logger.info.call_args_list)

@patch("microsoft_agents_a365.observability.core.exporters.agent365_exporter.logger")
def test_export_error_logging(self, mock_logger):
Expand All @@ -367,8 +367,8 @@ def test_export_error_logging(self, mock_logger):
# Verify export succeeded (no identity spans are treated as success)
self.assertEqual(result, SpanExportResult.SUCCESS)

# Verify debug log for no identity
mock_logger.debug.assert_called_with(
# Verify info log for no identity
mock_logger.info.assert_called_with(
"No spans with tenant/agent identity found; nothing exported."
)

Expand Down
8 changes: 4 additions & 4 deletions tests/observability/core/test_record_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ def test_opentelemetry_scope_logging(self, mock_logger):
):
pass

# Get all debug log messages
debug_messages = [str(call[0][0]) for call in mock_logger.debug.call_args_list]
# Get all info log messages
info_messages = [str(call[0][0]) for call in mock_logger.info.call_args_list]

# Check for span started and ended messages with span ID format
span_started_messages = [
msg for msg in debug_messages if f"Span started: '{activity_name}'" in msg
msg for msg in info_messages if f"Span started: '{activity_name}'" in msg
]
span_ended_messages = [
msg for msg in debug_messages if f"Span ended: '{activity_name}'" in msg
msg for msg in info_messages if f"Span ended: '{activity_name}'" in msg
]

self.assertEqual(
Expand Down