blizz
blizz

Reputation: 4168

C# Application Insights - multiple instances of TelemetryClient

I would like to log Application Insights telemetry data to both my own account and a client's account.

Is there any issue with using multiple instances of TelemetryClient to log the same data to two different Application Insights instrumentation keys? Or is there a better way to do this?

Upvotes: 0

Views: 1240

Answers (1)

ZakiMa
ZakiMa

Reputation: 6281

You can specify InstrumentationKey either on TelemetryClient level:

    this.Client = new TelemetryClient();
    this.Client.InstrumentationKey = "<your ikey>";

Or directly on individual item level:

    public void ModifyItem(ITelemetry item)
    {
        // Replace ikey
        item.Context.InstrumentationKey = this.ikey;
    }

If you are sending to different ikeys auto-collected data then you can modify instrumentation key either in TelemetryInitializer or even direct data yourself using TelemetryProcessor.

Upvotes: 5

Related Questions