Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -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 @@ -473,7 +473,7 @@
this.Configuration.FeatureReporter.MarkFeatureInUse(StatsbeatFeatures.TrackException);
if (exception == null)
{
exception = new Exception(Utils.PopulateRequiredStringValue(null, "message", typeof(ExceptionTelemetry).FullName));

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net472)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net480)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net462)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net481)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net9.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net10.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net8.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net481)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net472)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net480)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 476 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net462)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)
}

var state = new DictionaryLogState(this.Context, properties, exception.Message);
Expand All @@ -493,7 +493,7 @@
// TODO investigate how problem id, custom message, etc should appear in portal
if (telemetry == null)
{
var exception = new Exception(Utils.PopulateRequiredStringValue(null, "message", typeof(ExceptionTelemetry).FullName));

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net472)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net480)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net462)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net481)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net9.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net10.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net8.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net481)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net472)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net480)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 496 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net462)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)
telemetry = new ExceptionTelemetry(exception);
}

Expand Down Expand Up @@ -645,6 +645,11 @@
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 Expand Up @@ -1252,7 +1257,7 @@
else
{
// Fallback: create a generic exception with the message
rootException = new Exception(telemetry.Message ?? "<no message>");

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net472)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net480)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net462)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net481)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net9.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net10.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net8.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net481)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net472)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net480)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1260 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net462)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)
}

// Enrich the exception with metadata
Expand All @@ -1270,7 +1275,7 @@
{
if (exceptionDetailsList == null || exceptionDetailsList.Count == 0)
{
return new Exception("<no exception details>");

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net472)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net480)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net462)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net481)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net9.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net10.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net8.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net481)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net472)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net480)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1278 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net462)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)
}

// Process from innermost (index 0) to outermost (last index)
Expand All @@ -1289,11 +1294,11 @@

if (innerException != null)
{
currentException = new Exception($"[{typeName}] {message}", innerException);

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net472)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net480)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net462)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net481)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net9.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net10.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net8.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net481)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net472)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net480)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1297 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net462)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)
}
else
{
currentException = new Exception($"[{typeName}] {message}");

Check warning on line 1301 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net480)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1301 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net462)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1301 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net10.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1301 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net9.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1301 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net481)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1301 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (ubuntu-latest, net8.0)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1301 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net481)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)

Check warning on line 1301 in BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs

View workflow job for this annotation

GitHub Actions / build-test-SHIM (windows-latest, net462)

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)
}

// Set the current exception as the inner for the next iteration
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 @@ -228,7 +228,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 @@ -244,7 +244,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 @@ -216,7 +216,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 @@ -232,7 +232,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