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 @@ -1376,6 +1376,46 @@ public void TrackRequestHandlesNullRequestTelemetryGracefully()
Assert.Equal(0, this.activityItems.Count);
}

[Fact]
public void TrackRequestWithoutTimestampDefaultsToUtcNow()
{
var request = new RequestTelemetry
{
Name = "GET /api/items",
ResponseCode = "200",
Duration = TimeSpan.FromMilliseconds(75),
Success = true,
};
Assert.Equal(default, request.Timestamp);

var before = DateTime.UtcNow;
this.telemetryClient.TrackRequest(request);
var after = DateTime.UtcNow;
this.telemetryClient.Flush();

Assert.Equal(1, this.activityItems.Count);
var activity = this.activityItems[0];
Assert.InRange(activity.StartTimeUtc, before, after);
Assert.Equal(TimeSpan.FromMilliseconds(75), activity.Duration);
Assert.Equal(activity.StartTimeUtc, request.Timestamp.UtcDateTime);
}

[Fact]
public void TrackRequestWithExplicitTimestampPreservesTimestamp()
{
var startTime = new DateTimeOffset(2025, 1, 2, 3, 4, 5, TimeSpan.Zero);
var request = new RequestTelemetry("GET /api/items", startTime, TimeSpan.FromMilliseconds(123), "200", true);

this.telemetryClient.TrackRequest(request);
this.telemetryClient.Flush();

Assert.Equal(1, this.activityItems.Count);
var activity = this.activityItems[0];
Assert.Equal(startTime.UtcDateTime, activity.StartTimeUtc);
Assert.Equal(TimeSpan.FromMilliseconds(123), activity.Duration);
Assert.Equal(startTime, request.Timestamp);
}

#endregion

#region TrackDependency
Expand Down Expand Up @@ -1543,6 +1583,43 @@ public void TrackDependencyHandlesNullDependencyTelemetryGracefully()
Assert.Equal(0, this.activityItems.Count);
}

[Fact]
public void TrackDependencyWithoutTimestampDefaultsToUtcNow()
{
var dependency = new DependencyTelemetry("MyApp", "MyTarget", "Failure", string.Empty)
{
Duration = TimeSpan.FromMilliseconds(50),
};
Assert.Equal(default, dependency.Timestamp);

var before = DateTime.UtcNow;
this.telemetryClient.TrackDependency(dependency);
var after = DateTime.UtcNow;
this.telemetryClient.Flush();

Assert.Equal(1, this.activityItems.Count);
var activity = this.activityItems[0];
Assert.InRange(activity.StartTimeUtc, before, after);
Assert.Equal(TimeSpan.FromMilliseconds(50), activity.Duration);
Assert.Equal(activity.StartTimeUtc, dependency.Timestamp.UtcDateTime);
}

[Fact]
public void TrackDependencyWithExplicitTimestampPreservesTimestamp()
{
var startTime = new DateTimeOffset(2025, 1, 2, 3, 4, 5, TimeSpan.Zero);
var dependency = new DependencyTelemetry("Http", "api.example.com", "GET /", "https://api.example.com/", startTime, TimeSpan.FromMilliseconds(123), "200", true);

this.telemetryClient.TrackDependency(dependency);
this.telemetryClient.Flush();

Assert.Equal(1, this.activityItems.Count);
var activity = this.activityItems[0];
Assert.Equal(startTime.UtcDateTime, activity.StartTimeUtc);
Assert.Equal(TimeSpan.FromMilliseconds(123), activity.Duration);
Assert.Equal(startTime, dependency.Timestamp);
}

[Fact]
public void TrackDependencyWithCaseInsensitiveHttpType()
{
Expand Down
12 changes: 12 additions & 0 deletions BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/// Send events, metrics and other telemetry to the Application Insights service.
/// <a href="https://go.microsoft.com/fwlink/?linkid=525722">Learn more</a>
/// </summary>
public sealed class TelemetryClient

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

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

View workflow job for this annotation

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

The type name TelemetryClient conflicts in whole or in part with the namespace name 'Microsoft.Identity.Client.TelemetryCore.TelemetryClient'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)
{
internal readonly TelemetryConfiguration Configuration;
private readonly ActivitySource activitySource;
Expand Down Expand Up @@ -573,6 +573,12 @@
return;
}

// Preserve 2.x behavior: default an unset Timestamp to now to avoid emitting 0001-01-01.
if (telemetry.Timestamp == default)
Comment thread
mattsains-msft marked this conversation as resolved.
Resolved
{
telemetry.Timestamp = DateTimeOffset.UtcNow;
}

// Determine the appropriate ActivityKind based on dependency type
ActivityKind activityKind = GetActivityKindForDependency(telemetry.Type);

Expand Down Expand Up @@ -748,6 +754,12 @@
return;
}

// Preserve 2.x behavior: default an unset Timestamp to now to avoid emitting 0001-01-01.
if (request.Timestamp == default)
{
request.Timestamp = DateTimeOffset.UtcNow;
}

// Determine ActivityKind based on request properties
var activityKind = GetActivityKindForRequest(request);

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased
- **Breaking change:** Reduce default HTTP client metric volume in ASP.NET Core and Worker Service on .NET 8+ while retaining request latency, count, and failure dimensions through `http.client.request.duration`. Other `System.Net.Http` metrics are now opt-in through OpenTelemetry `AddView`; dashboards and alerts using them must [explicitly enable collection](MigrationGuidance.md#enabling-additional-http-client-metrics). HTTP dependency tracing and server metrics are unchanged. No new public API is introduced. Addresses the HTTP metric-volume concern in [#3192](https://github.com/microsoft/ApplicationInsights-dotnet/issues/3192).
- [Fix #3197: `NullReferenceException` when using TelemetryClient APIs when no connection string is provided.](https://github.com/microsoft/ApplicationInsights-dotnet/pull/3199)
- [Fix #3211: `TelemetryClient.TrackDependency(DependencyTelemetry)` and `TelemetryClient.TrackRequest(RequestTelemetry)` now default an unset `Timestamp` to `DateTimeOffset.UtcNow` (restoring 2.x behavior) instead of emitting `0001-01-01T00:00:00Z`, which ingestion rejects.](https://github.com/microsoft/ApplicationInsights-dotnet/pull/3219)

## Version 3.1.2
- [Fix `HttpException: Request is not available in this context` in the WEB package when calling `TrackDependency` from `Application_Start` in classic ASP.NET. The WEB activity processors now safely handle the case where `HttpContext.Request` is not yet available.](https://github.com/microsoft/ApplicationInsights-dotnet/pull/3184)
Expand Down
Loading