Skip to content

Conversation

@pvaneck
Copy link
Member

@pvaneck pvaneck commented Dec 16, 2025

Generation from TypeSpec from the branch in this PR: Azure/azure-rest-api-specs#38795

Noteable changes

  • The time field in TelemetryItem seems to have always been typed as datetime.datetime, but was being set as a ISO8601 date string. I have adjusted the tests and the _create_telemetry_item method to set the time to a datetime object and have adjusted the tests accordingly. The datetime objects will be serialized to the ISO8601 formatted strings (e.g. 2025-12-15T13:45:30.0000000Z when sent in a request anyway, so this should be fine.
  • In instances where there is a dict field in a generated model (e.g. TelemetryItem.tags), modifying it using attribute access doesn't currently work. For example:
    s = TelemetryItem(name=name, time=time, tags={"a": "b"})
    s.tags["c"] = "d" 
    print(s.tags)  # Would print {"a": "b"} with no "c" key
    This issue has been raised with the TypeSpec team, but I have adjusted the dictionary updates to use the following work-around:
    s = TelemetryItem(name=name, time=time, tags={"a": "b"})
    tags = s.tags
    tags["c"] = "d'
    s.tags = tags

Notes:

  • Since two different TypeSpec projects are contained in this project (Exporter and LiveMetrics), I am using the batch generation feature of tsp-client where the Exporter project will be emitted into azure/monitor/opentelemetry/exporter/_generated. LiveMetrics will be emitted to azure/monitor/opentelemetry/exporter/_quickpulse/_generated in the future.
  • A lot of the formatting updates are due to black being automatically be run upon generation. If we want to reduce the diff, we can run black on the existing codebase first in a separate PR.
  • One test failure tests/trace/test_trace.py::TestAzureTraceExporter::test_get_otel_resource_envelope was left as is, but is currently failing. It is comparing OTel Resource attributes with MetricsData.properties, but the properties field is type and serialized as Dict[str, str]. Thus, all values end up as strings when checking the values of properties. Should the test be modified or is the typing inaccurate?

@github-actions github-actions bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label Dec 16, 2025
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
@pvaneck pvaneck force-pushed the monitor-otel-exporter-typespec branch from cd26a71 to b658113 Compare December 16, 2025 21:27
@rads-1996
Copy link
Member

@pvaneck I can create a separate PR that runs the black format checks on the existing exporter code. I will share it once it is ready for review.

@pvaneck
Copy link
Member Author

pvaneck commented Dec 18, 2025

@rads-1996 Thanks, but I believe it was already formatted with #44462. I just need to rebase off of main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Monitor - Exporter Monitor OpenTelemetry Exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants