Skip to content

[Monitor] Generate exporter with TypeSpec#44442

Open
pvaneck wants to merge 12 commits intoAzure:mainfrom
pvaneck:monitor-otel-exporter-typespec
Open

[Monitor] Generate exporter with TypeSpec#44442
pvaneck wants to merge 12 commits intoAzure:mainfrom
pvaneck:monitor-otel-exporter-typespec

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 TypeSpec, defaults in models are treated as server-side defaults. The version property in the Domain model has a default of 2, however, the generated code does not include this as a default. The code was updated to explicitly set the version argument when constructing subclasses of Domain.

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.
  • One test, tests/trace/test_trace.py::TestAzureTraceExporter::test_get_otel_resource_envelope, was failing after the regeneration. 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.

Asks for team

  1. Validate whether using datetime objects instead of strings when creating TelemetryItems is acceptable.
  2. Validate whether properties being strings inside MetricsData is acceptable.

@github-actions github-actions bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label Dec 16, 2025
@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.

@pvaneck pvaneck force-pushed the monitor-otel-exporter-typespec branch 4 times, most recently from 8ee495f to 20fc16d Compare January 16, 2026 00:56
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
@pvaneck pvaneck force-pushed the monitor-otel-exporter-typespec branch from 20fc16d to bc3ca46 Compare January 17, 2026 00:22
result = exporter._transmit(self._envelopes_to_export)

track_dropped_mock.assert_called_once()
track_dropped_mock.assert_any_call(self._envelopes_to_export, 402)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these function calls changed?

@hectorhdzg hectorhdzg marked this pull request as ready for review February 6, 2026 23:17
@hectorhdzg hectorhdzg requested a review from lzchen as a code owner February 6, 2026 23:17
Copilot AI review requested due to automatic review settings February 6, 2026 23:17
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.

3 participants