diff --git a/.publicApi/Microsoft.ApplicationInsights.dll/Stable/PublicAPI.Unshipped.txt b/.publicApi/Microsoft.ApplicationInsights.dll/Stable/PublicAPI.Unshipped.txt
index 89aec753a..bbd96f508 100644
--- a/.publicApi/Microsoft.ApplicationInsights.dll/Stable/PublicAPI.Unshipped.txt
+++ b/.publicApi/Microsoft.ApplicationInsights.dll/Stable/PublicAPI.Unshipped.txt
@@ -138,8 +138,6 @@ Microsoft.ApplicationInsights.Extensibility.Implementation.LocationContext.Ip.se
Microsoft.ApplicationInsights.Extensibility.Implementation.OperationContext
Microsoft.ApplicationInsights.Extensibility.Implementation.OperationContext.Name.get -> string
Microsoft.ApplicationInsights.Extensibility.Implementation.OperationContext.Name.set -> void
-Microsoft.ApplicationInsights.Extensibility.Implementation.OperationContext.SyntheticSource.get -> string
-Microsoft.ApplicationInsights.Extensibility.Implementation.OperationContext.SyntheticSource.set -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry
Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.OperationTelemetry() -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Sanitize() -> void
diff --git a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationContext.cs b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationContext.cs
index f3643305a..6ede0b733 100644
--- a/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationContext.cs
+++ b/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationContext.cs
@@ -29,7 +29,7 @@ public string Name
///
/// Gets or sets the application-defined operation SyntheticSource.
///
- public string SyntheticSource
+ internal string SyntheticSource
{
get { return string.IsNullOrEmpty(this.syntheticSource) ? null : this.syntheticSource; }
set { this.syntheticSource = value; }
diff --git a/BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs b/BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs
index aa45494a4..bed95fb55 100644
--- a/BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs
+++ b/BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs
@@ -645,6 +645,11 @@ public void TrackDependency(DependencyTelemetry telemetry)
dependencyTelemetryActivity.SetTag(SemanticConventions.AttributeMicrosoftDependencyResultCode, telemetry.ResultCode);
}
+ if (!string.IsNullOrEmpty(telemetry.Context?.Operation?.Name))
+ {
+ dependencyTelemetryActivity.SetTag(SemanticConventions.AttributeMicrosoftOperationName, telemetry.Context.Operation.Name);
+ }
+
// Add GlobalProperties first (lower priority)
if (this.Context?.GlobalPropertiesValue != null)
{
diff --git a/NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensibility/Implementation/Tracing/AspNetCoreEventSource.cs b/NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensibility/Implementation/Tracing/AspNetCoreEventSource.cs
index 54e340ce9..4637765e1 100644
--- a/NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensibility/Implementation/Tracing/AspNetCoreEventSource.cs
+++ b/NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensibility/Implementation/Tracing/AspNetCoreEventSource.cs
@@ -31,18 +31,57 @@ private AspNetCoreEventSource()
}
///
- /// Logs an event for when generic error occur within the SDK.
+ /// Logs an event for when adding Application Insights telemetry fails.
///
[Event(
1,
Keywords = Keywords.Diagnostics,
- Message = "An error has occurred which may prevent application insights from functioning. Error message: '{0}' ",
+ Message = "Failed to add Application Insights telemetry. Error: '{0}'",
Level = EventLevel.Error)]
- public void LogError(string errorMessage, string appDomainName = "Incorrect")
+ public void FailedToAddTelemetry(string errorMessage, string appDomainName = "Incorrect")
{
this.WriteEvent(1, errorMessage, this.applicationNameProvider.Name);
}
+ ///
+ /// Logs an event for when an invalid TracesPerSecond value is configured.
+ ///
+ [Event(
+ 2,
+ Keywords = Keywords.Diagnostics,
+ Message = "Invalid TracesPerSecond value '{0}'. Value must be at least 0. Using default value.",
+ Level = EventLevel.Warning)]
+ public void InvalidTracesPerSecondConfigured(double tracesPerSecond, string appDomainName = "Incorrect")
+ {
+ this.WriteEvent(2, tracesPerSecond, this.applicationNameProvider.Name);
+ }
+
+ ///
+ /// Logs an event for when an invalid SamplingRatio value is configured.
+ ///
+ [Event(
+ 3,
+ Keywords = Keywords.Diagnostics,
+ Message = "Invalid SamplingRatio value '{0}'. Value must be between 0.0 and 1.0. Using default value.",
+ Level = EventLevel.Warning)]
+ public void InvalidSamplingRatioConfigured(float samplingRatio, string appDomainName = "Incorrect")
+ {
+ this.WriteEvent(3, samplingRatio, this.applicationNameProvider.Name);
+ }
+
+ ///
+ /// Logs an event for when telemetry configuration fails.
+ ///
+ [Event(
+ 4,
+ Keywords = Keywords.Diagnostics,
+ Message = "Failed to configure telemetry. Error: '{0}'",
+ Level = EventLevel.Error)]
+ public void TelemetryConfigurationFailure(string errorMessage, string appDomainName = "Incorrect")
+ {
+ this.WriteEvent(4, errorMessage, this.applicationNameProvider.Name);
+ }
+
///
/// Keywords for the AspNetEventSource.
///
diff --git a/NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs b/NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs
index f8bc798b4..bc7e8cfb8 100644
--- a/NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs
+++ b/NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs
@@ -105,7 +105,7 @@ public static IServiceCollection AddApplicationInsightsTelemetry(this IServiceCo
}
catch (Exception e)
{
- AspNetCoreEventSource.Instance.LogError(e.ToInvariantString());
+ AspNetCoreEventSource.Instance.FailedToAddTelemetry(e.ToInvariantString());
return services;
}
}
@@ -243,7 +243,7 @@ internal static IOpenTelemetryBuilder UseApplicationInsightsTelemetry(this IOpen
}
else
{
- AspNetCoreEventSource.Instance.LogError($"Invalid TracesPerSecond value '{serviceOptions.TracesPerSecond.Value}'. Value must be at least 0. Using default value.");
+ AspNetCoreEventSource.Instance.InvalidTracesPerSecondConfigured(serviceOptions.TracesPerSecond.Value);
}
}
@@ -259,7 +259,7 @@ internal static IOpenTelemetryBuilder UseApplicationInsightsTelemetry(this IOpen
}
else
{
- AspNetCoreEventSource.Instance.LogError($"Invalid SamplingRatio value '{serviceOptions.SamplingRatio.Value}'. Value must be between 0.0 and 1.0. Using default value.");
+ AspNetCoreEventSource.Instance.InvalidSamplingRatioConfigured(serviceOptions.SamplingRatio.Value);
}
}
diff --git a/NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs b/NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs
index c05c027d2..0b67eecc5 100644
--- a/NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs
+++ b/NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs
@@ -102,7 +102,7 @@ public static IServiceCollection AddApplicationInsightsTelemetryWorkerService(th
}
catch (Exception e)
{
- WorkerServiceEventSource.Instance.LogError(e.ToInvariantString());
+ WorkerServiceEventSource.Instance.FailedToAddTelemetry(e.ToInvariantString());
return services;
}
}
@@ -231,7 +231,7 @@ internal static IOpenTelemetryBuilder UseApplicationInsightsTelemetry(this IOpen
}
else
{
- WorkerServiceEventSource.Instance.LogError($"Invalid TracesPerSecond value '{serviceOptions.TracesPerSecond.Value}'. Value must be at least 0. Using default value.");
+ WorkerServiceEventSource.Instance.InvalidTracesPerSecondConfigured(serviceOptions.TracesPerSecond.Value);
}
}
@@ -247,7 +247,7 @@ internal static IOpenTelemetryBuilder UseApplicationInsightsTelemetry(this IOpen
}
else
{
- WorkerServiceEventSource.Instance.LogError($"Invalid SamplingRatio value '{serviceOptions.SamplingRatio.Value}'. Value must be between 0.0 and 1.0. Using default value.");
+ WorkerServiceEventSource.Instance.InvalidSamplingRatioConfigured(serviceOptions.SamplingRatio.Value);
}
}
diff --git a/NETCORE/src/Microsoft.ApplicationInsights.WorkerService/Implementation/Tracing/WorkerServiceEventSource.cs b/NETCORE/src/Microsoft.ApplicationInsights.WorkerService/Implementation/Tracing/WorkerServiceEventSource.cs
index ca36de9ab..899b2b7aa 100644
--- a/NETCORE/src/Microsoft.ApplicationInsights.WorkerService/Implementation/Tracing/WorkerServiceEventSource.cs
+++ b/NETCORE/src/Microsoft.ApplicationInsights.WorkerService/Implementation/Tracing/WorkerServiceEventSource.cs
@@ -29,14 +29,57 @@ private WorkerServiceEventSource()
}
///
- /// Logs error message.
+ /// Logs an event for when adding Application Insights telemetry fails.
///
- /// Message.
+ /// Error message.
/// An ignored placeholder to make EventSource happy.
- [Event(1, Message = "An error has occurred which may prevent application insights from functioning. Error message: '{0}'", Level = EventLevel.Error)]
- public void LogError(string message, string appDomainName = "Incorrect")
+ [Event(
+ 1,
+ Keywords = Keywords.Diagnostics,
+ Message = "Failed to add Application Insights telemetry. Error: '{0}'",
+ Level = EventLevel.Error)]
+ public void FailedToAddTelemetry(string errorMessage, string appDomainName = "Incorrect")
{
- this.WriteEvent(1, message, this.applicationNameProvider.Name);
+ this.WriteEvent(1, errorMessage, this.applicationNameProvider.Name);
+ }
+
+ ///
+ /// Logs an event for when an invalid TracesPerSecond value is configured.
+ ///
+ [Event(
+ 2,
+ Keywords = Keywords.Diagnostics,
+ Message = "Invalid TracesPerSecond value '{0}'. Value must be at least 0. Using default value.",
+ Level = EventLevel.Warning)]
+ public void InvalidTracesPerSecondConfigured(double tracesPerSecond, string appDomainName = "Incorrect")
+ {
+ this.WriteEvent(2, tracesPerSecond, this.applicationNameProvider.Name);
+ }
+
+ ///
+ /// Logs an event for when an invalid SamplingRatio value is configured.
+ ///
+ [Event(
+ 3,
+ Keywords = Keywords.Diagnostics,
+ Message = "Invalid SamplingRatio value '{0}'. Value must be between 0.0 and 1.0. Using default value.",
+ Level = EventLevel.Warning)]
+ public void InvalidSamplingRatioConfigured(float samplingRatio, string appDomainName = "Incorrect")
+ {
+ this.WriteEvent(3, samplingRatio, this.applicationNameProvider.Name);
+ }
+
+ ///
+ /// Logs an event for when telemetry configuration fails.
+ ///
+ [Event(
+ 4,
+ Keywords = Keywords.Diagnostics,
+ Message = "Failed to configure telemetry. Error: '{0}'",
+ Level = EventLevel.Error)]
+ public void TelemetryConfigurationFailure(string errorMessage, string appDomainName = "Incorrect")
+ {
+ this.WriteEvent(4, errorMessage, this.applicationNameProvider.Name);
}
///
diff --git a/NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs b/NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs
index 67a747fcb..46753900d 100644
--- a/NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs
+++ b/NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs
@@ -63,9 +63,9 @@ internal static void AddTelemetryConfiguration(
catch (Exception ex)
{
#if AI_ASPNETCORE_WEB
- AspNetCoreEventSource.Instance.LogError(ex.ToInvariantString());
+ AspNetCoreEventSource.Instance.TelemetryConfigurationFailure(ex.ToInvariantString());
#else
- WorkerServiceEventSource.Instance.LogError(ex.ToInvariantString());
+ WorkerServiceEventSource.Instance.TelemetryConfigurationFailure(ex.ToInvariantString());
#endif
}
}