Skip to content

Conversation

@JacksonWeber
Copy link
Contributor

This pull request enhances the Application Insights agent loader to proactively detect and report conflicts with existing OpenTelemetry global providers before attaching the agent. It introduces a new diagnostic message for OpenTelemetry conflicts and adds comprehensive unit tests to ensure correct detection and logging of these scenarios.

OpenTelemetry conflict detection and diagnostics:

  • Added a new _detectOpenTelemetryGlobals method in AgentLoader to check for global OpenTelemetry TracerProvider, MeterProvider, and LoggerProvider instances before agent attachment, and log a diagnostic message if any are detected. [1] [2]
  • Introduced a new diagnostic message ID, openTelemetryConflict, in DiagnosticMessageId for logging OpenTelemetry provider conflicts.

Unit test improvements:

  • Updated agentLoader unit tests to mock and restore OpenTelemetry globals, ensuring isolation between tests and preventing side effects. [1] [2]
  • Added tests for detecting and logging TracerProvider, MeterProvider, and LoggerProvider conflicts, verifying that the correct diagnostic messages are emitted when these providers are present.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant