Skip to content

TelemetryClient.TrackDependency no longer default an uninitialized ITelemetry.Timestamp to UtcNow when creating the backing Activity #3211

Closed

Description

@Knusprig69

Description

Since migrating from the classic Application Insights SDK pipeline to the newer Activity/OpenTelemetry-based pipeline (Microsoft.ApplicationInsights + Azure.Monitor.OpenTelemetry.Exporter), calling the TelemetryClient.TrackDependency method with a manually constructed DependencyTelemetry which do not explicitly set Timestamp will now be exported with Timestamp = DateTimeOffset.MinValue ("0001-01-01T00:00:00.0000000Z"), instead of defaulting to the current UTC time.

Previous (classic) behavior

In the classic SDK, TelemetryClient.Track(ITelemetry telemetry) (or equivalent internal initialization) explicitly checked whether Timestamp still had its default/uninitialized value and, if so, assigned it via PreciseTimestamp.GetUtcNow() before serialization/transmission. This meant that code such as:

telemetryClient.TrackDependency(new DependencyTelemetry(typeName, target, dependencyName, data));

— without ever setting Timestamp — worked correctly and always produced a sensible, "now" timestamp.

Current (regressed) behavior

In the current SDK version, TelemetryClient.TrackDependency(DependencyTelemetry) converts the ITelemetry object into an Activity and assigns ITelemetry.Timestamp directly to Activity.StartTime, without checking whether the value is still the type default (default(DateTimeOffset) / DateTimeOffset.MinValue).

Note: this is specific to TrackDependency(DependencyTelemetry). TelemetryClient.StartOperation(...) (combined with StopOperation) is not affected — it correctly assigns the Activity's start time itself when the operation is started, regardless of whether Timestamp was set on the DependencyTelemetry passed in. The regression only applies to the "fire and forget" TrackDependency path, where the Activity's StartTime is derived directly and unconditionally from the (possibly unset) ITelemetry.Timestamp.

As a result:

  • The emitted telemetry item is serialized with "time":"0001-01-01T00:00:00.0000000Z".
  • Application Insights ingestion rejects such items via a 206 Partial Success response with error code 103 ("Field 'time' on type 'Envelope' is older than the allowed min date").
  • Combined with a separate bug we found in Azure.Monitor.OpenTelemetry.Exporter's HttpPipelineHelper.HandlePartialSuccess (offline-storage blob is not deleted when a partial-success response contains only non-retryable errors), this causes the entire storage-persisted batch — including already-successfully-transmitted items — to be resent indefinitely, producing duplicate telemetry entries in Application Insights.

Repro

var telemetryClient = new TelemetryClient(configuration); // configured with OpenTelemetry/Azure Monitor exporter
telemetryClient.TrackDependency(new DependencyTelemetry("MyApp", "MyTarget", "Failure", ""));

No Timestamp is set on the DependencyTelemetry. Inspect the resulting exported item (e.g. via a custom Activity/BaseProcessor or the offline-storage blob content) — time is 0001-01-01T00:00:00.0000000Z instead of the call time.

Expected behavior

When TrackDependency converts the ITelemetry to an Activity, it should replicate the previous safety check: if Timestamp is still default(DateTimeOffset), it should default to DateTimeOffset.UtcNow before being applied to Activity.StartTime, consistent with pre-migration behavior. Alternatively, this should be clearly documented as a breaking change so consumers know they must always set Timestamp explicitly when calling TrackDependency directly (as opposed to using StartOperation/StopOperation, which is unaffected).

Environment

  • Microsoft.ApplicationInsights.AspNetCore 3.1.2
  • Azure.Monitor.OpenTelemetry.Exporter 1.8.3
  • .NET 10 / C# 14
  • SDK version string observed: dotnet10.0.11-servicing.26:otel1.16.0:shc3.1.2

Related/downstream issue

This surfaces a second, independent bug in Azure.Monitor.OpenTelemetry.Exporter's offline-storage retry handling (HttpPipelineHelper.HandlePartialSuccess), where blobs containing only non-retryable partial-success errors (or a mix of successful items and non-retryable errors) are never deleted, causing an infinite resend loop. Filed separately against Azure/azure-sdk-for-net, but flagging the connection here since both bugs together are what caused user-visible duplicate telemetry entries in production.

Activity

  1. github-actions commented on Sep 21, 2026

    @github-actions

    This issue was marked stale due to lack of activity and will be closed in 7 days. Commenting will instruct the bot to automatically remove the label. This bot runs once per day.

  2. added a commit that references this issue on Sep 25, 2026
    07099fc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions