Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public string Name
/// <summary>
/// Gets or sets the application-defined operation SyntheticSource.
/// </summary>
public string SyntheticSource
internal string SyntheticSource
{
get { return string.IsNullOrEmpty(this.syntheticSource) ? null : this.syntheticSource; }
set { this.syntheticSource = value; }
Expand Down
5 changes: 5 additions & 0 deletions BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,57 @@ private AspNetCoreEventSource()
}

/// <summary>
/// Logs an event for when generic error occur within the SDK.
/// Logs an event for when adding Application Insights telemetry fails.
/// </summary>
[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);
}

/// <summary>
/// Logs an event for when an invalid TracesPerSecond value is configured.
/// </summary>
[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);
}

/// <summary>
/// Logs an event for when an invalid SamplingRatio value is configured.
/// </summary>
[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);
}

/// <summary>
/// Logs an event for when telemetry configuration fails.
/// </summary>
[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);
}

/// <summary>
/// Keywords for the AspNetEventSource.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static IServiceCollection AddApplicationInsightsTelemetryWorkerService(th
}
catch (Exception e)
{
WorkerServiceEventSource.Instance.LogError(e.ToInvariantString());
WorkerServiceEventSource.Instance.FailedToAddTelemetry(e.ToInvariantString());
return services;
}
}
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,57 @@ private WorkerServiceEventSource()
}

/// <summary>
/// Logs error message.
/// Logs an event for when adding Application Insights telemetry fails.
/// </summary>
/// <param name="message">Message.</param>
/// <param name="errorMessage">Error message.</param>
/// <param name="appDomainName">An ignored placeholder to make EventSource happy.</param>
[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);
}

/// <summary>
/// Logs an event for when an invalid TracesPerSecond value is configured.
/// </summary>
[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);
}

/// <summary>
/// Logs an event for when an invalid SamplingRatio value is configured.
/// </summary>
[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);
}

/// <summary>
/// Logs an event for when telemetry configuration fails.
/// </summary>
[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);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Loading