Skip to content

Conversation

@rads-1996
Copy link
Member

@rads-1996 rads-1996 commented Jan 13, 2026

Description

Implements spec update: [(https://github.com/aep-health-and-standards/Telemetry-Collection-Spec/pull/730)]. Adds logic to auto detect application ID from connection string if not already set through resource attributes.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Copilot AI review requested due to automatic review settings January 13, 2026 22:34
@github-actions github-actions bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label Jan 13, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements auto-detection of application ID from connection strings when not already set in resource attributes. The change allows the Azure Monitor trace exporter to extract the ApplicationId parameter from connection strings and automatically populate it in the OpenTelemetry resource envelope if not already present.

Changes:

  • Added application ID extraction to connection string parser
  • Modified trace exporter to parse application ID from connection string and conditionally add to resource envelope
  • Added new constant _APPLICATION_ID_RESOURCE_KEY for the resource attribute key
  • Updated tests to verify application ID handling and updated mock expectations

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
_connection_string_parser.py Added APPLICATION_ID constant and extraction logic to parse application ID from connection string
_constants.py Added _APPLICATION_ID_RESOURCE_KEY constant for resource attribute key
export/trace/_exporter.py Added logic to parse connection string, extract application ID, and conditionally add to resource envelope
test_connection_string_parser.py Added tests for application ID extraction with and without ApplicationId in connection string
tests/trace/test_trace.py Updated test mocks to include application_id parameter and added connection string with ApplicationId to test
tests/logs/test_logs.py Added application ID to test resource and verified it doesn't leak into log properties; removed debug print statement
Comments suppressed due to low confidence (1)

sdk/monitor/azure-monitor-opentelemetry-exporter/tests/trace/test_trace.py:1742

  • The test should verify that when application_id is provided and NOT already present in resource attributes, it gets added. Currently, this test has "microsoft.applicationId" already in the resource attributes (line 1725), and passes the same "test_app_id" as the second argument. This tests the "don't overwrite" behavior, but there's no test case for when the application_id should be added (i.e., when it's not already in the resource but is provided from the connection string).
    def test_get_otel_resource_envelope(self):
        exporter = self._exporter
        test_resource = resources.Resource(
            attributes={
                "string_test_key": "string_value",
                "int_test_key": -1,
                "bool_test_key": False,
                "float_test_key": 0.5,
                "sequence_test_key": ["a", "b"],
                "microsoft.applicationId": "test_app_id",
            }
        )
        envelope = exporter._get_otel_resource_envelope(test_resource, "test_app_id")
        metric_name = envelope.name
        self.assertEqual(metric_name, "Microsoft.ApplicationInsights.Metric")
        instrumentation_key = envelope.instrumentation_key
        self.assertEqual(instrumentation_key, exporter._instrumentation_key)

        monitor_base = envelope.data
        self.assertEqual(monitor_base.base_type, "MetricData")
        metrics_data = monitor_base.base_data
        resource_attributes = metrics_data.properties
        self.assertEqual(resource_attributes, test_resource.attributes)
        metrics = metrics_data.metrics
        self.assertEqual(len(metrics), 1)
        self.assertEqual(metrics[0].name, "_OTELRESOURCE_")

@rads-1996 rads-1996 marked this pull request as draft January 13, 2026 23:14
@rads-1996 rads-1996 force-pushed the add-auto-detection-for-appid branch from 7848597 to 5000421 Compare January 14, 2026 15:32
@rads-1996 rads-1996 marked this pull request as ready for review January 14, 2026 16:05
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