Skip to content

Conversation

@hectorhdzg
Copy link
Member

Fixes #1476

export function setup(setupString?: string) {
if (!defaultClient) {
defaultClient = new TelemetryClient(setupString);
defaultClient = new TelemetryClient(setupString, { useGlobalProviders: true });
Copy link
Member

Choose a reason for hiding this comment

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

I am a bit confused here, I though the title meant not to use the global providers for telemetry client, but here we are setting it to True.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only scenario where we want to enable it, the default client when the SDK is initialized using

let appInsights = require("applicationinsights");
appInsights.setup("<YOUR_CONNECTION_STRING>").start();

// Create attribute processors with context tags and common properties
this._attributeSpanProcessor = new AttributeSpanProcessor({ ...this.context.tags, ...this.commonProperties });
this._attributeLogProcessor = new AttributeLogProcessor({ ...this.context.tags, ...this.commonProperties });
this._options.spanProcessors = [...(this._options.spanProcessors || []), this._attributeSpanProcessor];
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice addition, thanks for noticing this omission!

Copy link
Contributor

@JacksonWeber JacksonWeber left a comment

Choose a reason for hiding this comment

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

LGTM

@hectorhdzg hectorhdzg changed the title Add funcitonality for TelemetryClient to not use global providers Add functionality for TelemetryClient to not use global providers Dec 10, 2025
@hectorhdzg hectorhdzg merged commit 9c2dfcf into microsoft:main Dec 12, 2025
16 checks passed
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.

Issue with multiple TelemetryClients running in same Node.js process not respecting configurations

3 participants