in src/WebJobs.Extensions.DurableTask/Correlation/TelemetryActivator.cs [159:218]
private TelemetryConfiguration SetupTelemetryConfiguration()
{
TelemetryConfiguration config = TelemetryConfiguration.CreateDefault();
if (this.OnSend != null)
{
config.TelemetryChannel = new NoOpTelemetryChannel { OnSend = this.OnSend };
}
string resolvedInstrumentationKey = this.nameResolver.Resolve("APPINSIGHTS_INSTRUMENTATIONKEY");
string resolvedConnectionString = this.nameResolver.Resolve("APPLICATIONINSIGHTS_CONNECTION_STRING");
bool instrumentationKeyProvided = !string.IsNullOrEmpty(resolvedInstrumentationKey);
bool connectionStringProvided = !string.IsNullOrEmpty(resolvedConnectionString);
if (instrumentationKeyProvided && connectionStringProvided)
{
this.endToEndTraceHelper.ExtensionWarningEvent(
hubName: this.options.HubName,
functionName: string.Empty,
instanceId: string.Empty,
message: "Both 'APPINSIGHTS_INSTRUMENTATIONKEY' and 'APPLICATIONINSIGHTS_CONNECTION_STRING' are defined in the current environment variables. Please specify one. We recommend specifying 'APPLICATIONINSIGHTS_CONNECTION_STRING'.");
}
if (!instrumentationKeyProvided && !connectionStringProvided)
{
this.endToEndTraceHelper.ExtensionWarningEvent(
hubName: this.options.HubName,
functionName: string.Empty,
instanceId: string.Empty,
message: "'APPINSIGHTS_INSTRUMENTATIONKEY' or 'APPLICATIONINSIGHTS_CONNECTION_STRING' were not defined in the current environment variables, but distributed tracing is enabled. Please specify one. We recommend specifying 'APPLICATIONINSIGHTS_CONNECTION_STRING'.");
}
if (instrumentationKeyProvided)
{
this.endToEndTraceHelper.ExtensionInformationalEvent(
hubName: this.options.HubName,
functionName: string.Empty,
instanceId: string.Empty,
message: "Reading APPINSIGHTS_INSTRUMENTATIONKEY...",
writeToUserLogs: true);
#pragma warning disable CS0618 // Type or member is obsolete
config.InstrumentationKey = resolvedInstrumentationKey;
#pragma warning restore CS0618 // Type or member is obsolete
}
if (connectionStringProvided)
{
this.endToEndTraceHelper.ExtensionInformationalEvent(
hubName: this.options.HubName,
functionName: string.Empty,
instanceId: string.Empty,
message: "Reading APPLICATIONINSIGHTS_CONNECTION_STRING...",
writeToUserLogs: true);
config.ConnectionString = resolvedConnectionString;
}
return config;
}