Skip to content

Commit afa7d9a

Browse files
tpellissierclaude
andcommitted
Add telemetry documentation to README and SDK skill
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 20e3f46 commit afa7d9a

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ A Python client library for Microsoft Dataverse that provides a unified interfac
4141
- **🔗 Relationship Management**: Create one-to-many and many-to-many relationships between tables with full metadata control
4242
- **📎 File Operations**: Upload files to Dataverse file columns with automatic chunking for large files
4343
- **🔐 Azure Identity**: Built-in authentication using Azure Identity credential providers with comprehensive support
44+
- **📡 Telemetry & Observability**: Opt-in telemetry hooks, OpenTelemetry tracing/metrics, and Python logging integration
4445
- **🛡️ Error Handling**: Structured exception hierarchy with detailed error context and retry guidance
4546

4647
## Getting started
@@ -386,6 +387,31 @@ client.files.upload(
386387
)
387388
```
388389

390+
### Telemetry & observability
391+
392+
```python
393+
from PowerPlatform.Dataverse.core.telemetry import TelemetryConfig, TelemetryHook
394+
from PowerPlatform.Dataverse.core.config import DataverseConfig
395+
396+
# Custom hook -- receives events for every HTTP request
397+
class MyHook(TelemetryHook):
398+
def on_request_end(self, request, response):
399+
print(f"{request.operation} -> {response.status_code} in {response.duration_ms:.0f}ms")
400+
print(f" service_request_id: {response.service_request_id}")
401+
402+
config = DataverseConfig(telemetry=TelemetryConfig(hooks=[MyHook()]))
403+
client = DataverseClient(url, credential, config=config)
404+
405+
# OpenTelemetry integration (pip install PowerPlatform-Dataverse-Client[telemetry])
406+
config = DataverseConfig(
407+
telemetry=TelemetryConfig(
408+
enable_tracing=True, # OTel spans with semantic conventions
409+
enable_metrics=True, # duration/count/error counters
410+
enable_logging=True, # Python logging integration
411+
)
412+
)
413+
```
414+
389415
## Next steps
390416

391417
### More sample code

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,37 @@ client.files.upload(
310310
)
311311
```
312312

313+
### Telemetry & Observability
314+
315+
The SDK supports opt-in telemetry via hooks, OpenTelemetry, and Python logging:
316+
317+
```python
318+
from PowerPlatform.Dataverse.core.telemetry import TelemetryConfig, TelemetryHook
319+
from PowerPlatform.Dataverse.core.config import DataverseConfig
320+
321+
# Custom hook -- receives on_request_start, on_request_end, on_request_error
322+
class MyHook(TelemetryHook):
323+
def on_request_end(self, request, response):
324+
print(f"{request.operation} -> {response.status_code} in {response.duration_ms:.0f}ms")
325+
326+
config = DataverseConfig(telemetry=TelemetryConfig(hooks=[MyHook()]))
327+
client = DataverseClient(url, credential, config=config)
328+
329+
# OpenTelemetry (pip install PowerPlatform-Dataverse-Client[telemetry])
330+
config = DataverseConfig(
331+
telemetry=TelemetryConfig(enable_tracing=True, enable_metrics=True)
332+
)
333+
334+
# Python logging
335+
config = DataverseConfig(
336+
telemetry=TelemetryConfig(enable_logging=True, log_level="DEBUG")
337+
)
338+
```
339+
340+
Hook data available per request: `operation`, `table_name`, `method`, `url`, `status_code`, `duration_ms`, `service_request_id`, `client_request_id`, `correlation_id`.
341+
342+
Zero overhead when `TelemetryConfig` is not set.
343+
313344
## Error Handling
314345

315346
The SDK provides structured exceptions with detailed error information:

0 commit comments

Comments
 (0)