Skip to content

Commit

Permalink
[AppInsights] changing initializer to not use Add()
Browse files Browse the repository at this point in the history
  • Loading branch information
brettsam committed Jun 4, 2019
1 parent ad02f1c commit 44af3a1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/WebJobs.Script/Config/ScriptTelemetryInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -29,7 +30,14 @@ public ScriptTelemetryInitializer(IOptions<ScriptJobHostOptions> hostOptions)

public void Initialize(ITelemetry telemetry)
{
telemetry?.Context?.Properties?.Add(ScriptConstants.LogPropertyHostInstanceIdKey, _hostOptions.InstanceId);
IDictionary<string, string> telemetryProps = telemetry?.Context?.Properties;

if (telemetryProps == null)
{
return;
}

telemetryProps[ScriptConstants.LogPropertyHostInstanceIdKey] = _hostOptions.InstanceId;
}
}
}

0 comments on commit 44af3a1

Please sign in to comment.