Skip to content

Commit 1d211af

Browse files
tpellissierclaude
andcommitted
Fix build: skip OTel tests when not installed, fix docs
- Add skipUnless(_OTEL_AVAILABLE) to 3 tests that require opentelemetry - Clarify on_request_error docstring: covers both HTTP and network errors - Fix SKILL.md: separate request vs response fields in hook data docs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent dee1179 commit 1d211af

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/PowerPlatform/Dataverse/claude_skill/dataverse-sdk-use/SKILL.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ config = DataverseConfig(
343343
)
344344
```
345345

346-
Hook data available per request: `operation`, `table_name`, `method`, `url`, `status_code`, `duration_ms`, `service_request_id`, `client_request_id`, `correlation_id`.
346+
Hook data available on the **request** object: `operation`, `table_name`, `method`, `url`, `client_request_id`, `correlation_id`.
347+
Hook data available on the **response** object: `status_code`, `duration_ms`, `service_request_id`.
347348

348349
Zero overhead when `TelemetryConfig` is not set.
349350

src/PowerPlatform/Dataverse/core/telemetry.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,12 @@ def on_request_end(self, request: RequestContext, response: ResponseContext) ->
191191
"""Called after each HTTP request completes (success or failure)."""
192192

193193
def on_request_error(self, request: RequestContext, error: Exception) -> None:
194-
"""Called when an unhandled network-level exception occurs."""
194+
"""Called when an error occurs during an HTTP request.
195+
196+
This includes both network/transport exceptions and HTTP-level
197+
failures (e.g. 4xx/5xx responses surfaced as ``HttpError``).
198+
Always fired before ``on_request_end``.
199+
"""
195200

196201
def get_additional_headers(self) -> Dict[str, str]:
197202
"""Return additional headers to include in outbound requests."""

tests/unit/core/test_telemetry.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
TelemetryHook,
1717
TelemetryManager,
1818
_TrackedRequest,
19+
_OTEL_AVAILABLE,
1920
create_telemetry_manager,
2021
)
2122
from PowerPlatform.Dataverse.data._odata import (
@@ -332,6 +333,7 @@ def test_span_not_created_without_otel(self):
332333
) as tracked:
333334
self.assertIsNone(tracked._span)
334335

336+
@unittest.skipUnless(_OTEL_AVAILABLE, "requires opentelemetry")
335337
def test_span_end_called_in_finally(self):
336338
mock_tracer = MagicMock()
337339
mock_span = MagicMock()
@@ -347,6 +349,7 @@ def test_span_end_called_in_finally(self):
347349

348350
mock_span.end.assert_called_once()
349351

352+
@unittest.skipUnless(_OTEL_AVAILABLE, "requires opentelemetry")
350353
def test_record_response_sets_span_status_ok(self):
351354
from opentelemetry.trace import StatusCode
352355

@@ -364,6 +367,7 @@ def test_record_response_sets_span_status_ok(self):
364367
status_arg = mock_span.set_status.call_args[0][0]
365368
self.assertEqual(status_arg.status_code, StatusCode.OK)
366369

370+
@unittest.skipUnless(_OTEL_AVAILABLE, "requires opentelemetry")
367371
def test_record_response_sets_span_status_error(self):
368372
mock_span = MagicMock()
369373
ctx = RequestContext(

0 commit comments

Comments
 (0)