Skip to content

Add ObservedTimestamp to LogRecordData#6979

Merged
Kielek merged 10 commits into
open-telemetry:mainfrom
juliuskoval:ObservedTimeStamp
Jun 9, 2026
Merged

Add ObservedTimestamp to LogRecordData#6979
Kielek merged 10 commits into
open-telemetry:mainfrom
juliuskoval:ObservedTimeStamp

Conversation

@juliuskoval

@juliuskoval juliuskoval commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Towards #4433

Changes

Adds ObservedTimestamp to LogRecordData and LogRecord.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions Bot added pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package labels Mar 18, 2026
@juliuskoval

juliuskoval commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

On a somewhat related note, it seems to me that the spec suggests that LogRecordData.Timestamp should be nullable. LogRecord.Timestamp is always set in OpenTelemetryLogger so it shouldn't be a breaking change, but it would be changing the stable public API.

@juliuskoval juliuskoval marked this pull request as ready for review March 18, 2026 17:53
@juliuskoval juliuskoval requested a review from a team as a code owner March 18, 2026 17:53
@codecov

codecov Bot commented Mar 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.73%. Comparing base (67a2e1f) to head (aec8a0a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/OpenTelemetry/Logs/LogRecord.cs 66.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6979      +/-   ##
==========================================
- Coverage   89.73%   89.73%   -0.01%     
==========================================
  Files         276      276              
  Lines       14628    14635       +7     
==========================================
+ Hits        13127    13132       +5     
- Misses       1501     1503       +2     
Flag Coverage Δ
unittests-Project-Experimental 89.53% <92.30%> (-0.20%) ⬇️
unittests-Project-Stable 89.63% <92.30%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/OpenTelemetry.Api/Logs/LogRecordData.cs 100.00% <100.00%> (ø)
...metry.Exporter.Console/ConsoleLogRecordExporter.cs 97.14% <100.00%> (+0.04%) ⬆️
...ementation/Serializer/ProtobufOtlpLogSerializer.cs 98.50% <100.00%> (-0.04%) ⬇️
.../OpenTelemetry/Logs/ILogger/OpenTelemetryLogger.cs 90.00% <100.00%> (+0.10%) ⬆️
src/OpenTelemetry/Logs/LoggerSdk.cs 100.00% <100.00%> (ø)
src/OpenTelemetry/Logs/LogRecord.cs 70.77% <66.66%> (-0.09%) ⬇️

... and 1 file with indirect coverage changes

Comment thread src/OpenTelemetry.Api/.publicApi/Experimental/PublicAPI.Unshipped.txt Outdated
Comment thread src/OpenTelemetry.Api/CHANGELOG.md Outdated

@rajkumar-rangaraj rajkumar-rangaraj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a suggestion to update OTLP Exporter changelog.

@Kielek

Kielek commented Mar 20, 2026

Copy link
Copy Markdown
Member

On a somewhat related note, it seems to me that the spec suggests that LogRecordData.Timestamp and LogRecord.Timestamp should be nullable. LogRecord.Timestamp is always set in OpenTelemetryLogger so it shouldn't be a breaking change, but it would be changing the stable public API.

I think that we should document this spec deviation in the document (can be separate PR). What is more it will be great to create some issue to fix it. There is label required major bump.

@juliuskoval

Copy link
Copy Markdown
Contributor Author

On a somewhat related note, it seems to me that the spec suggests that LogRecordData.Timestamp and LogRecord.Timestamp should be nullable. LogRecord.Timestamp is always set in OpenTelemetryLogger so it shouldn't be a breaking change, but it would be changing the stable public API.

I think that we should document this spec deviation in the document (can be separate PR). What is more it will be great to create some issue to fix it. There is label required major bump.

I created this issue to track all the deviations from the spec. #6992

@Kielek Kielek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for delays with reviews. Finally, I was able to finish other OTel Auto task.

If we go with non-nullable approach, it should be fine with some small adjustments.

I have checked also other possibilities (the code is still dirty and probably needs to be split into at least 2 PRs, but it shows potential solution without breaking changes.
Description https://github.com/Kielek/opentelemetry-dotnet/blob/3ee221fe48f17ca399b3dd4d59d7cca9cf8b96de/docs/design/make-timestamp-nullable.md

and the PR itself: Kielek@3ee221f

Comment thread src/OpenTelemetry.Api/Logs/LogRecordData.cs
@github-actions github-actions Bot added the pkg:OpenTelemetry.Exporter.Console Issues related to OpenTelemetry.Exporter.Console NuGet package label Mar 29, 2026
@juliuskoval

juliuskoval commented Mar 29, 2026

Copy link
Copy Markdown
Contributor Author

@Kielek Sorry about taking so long as well. Regarding your proposed solutions, couldn't we just leave LogRecord.Timestamp as it is right now given that all options would lead to deviations from the spec and document the difference somewhere?

@juliuskoval

Copy link
Copy Markdown
Contributor Author

Hi @Kielek, do you have any thoughts on my previous comment?

@Kielek

Kielek commented Apr 2, 2026

Copy link
Copy Markdown
Member

Yes, I have one more discussion about this last days. We could change a bit behavior in non-public class and treat DateTime.MinValue/default as not set (for both values) + check it during exporting.

As I know Go-lang is implemented in this way. Hidden null, to avoid extra memory footprint by Nullable version.

I will play a bit with thin Tuesday+ next week.

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Apr 10, 2026
intellitect-bot pushed a commit to IntelliTect/EssentialCSharp.Web that referenced this pull request Jun 12, 2026
….0 (#1201)

Updated
[OpenTelemetry.Exporter.OpenTelemetryProtocol](https://github.com/open-telemetry/opentelemetry-dotnet)
from 1.15.3 to 1.16.0.

<details>
<summary>Release notes</summary>

_Sourced from [OpenTelemetry.Exporter.OpenTelemetryProtocol's
releases](https://github.com/open-telemetry/opentelemetry-dotnet/releases)._

## 1.16.0

For highlights and announcements pertaining to this release see:
[Release Notes >
1.16.0](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/RELEASENOTES.md#​1160).

The following changes are from the previous release
[1.16.0-rc.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.16.0-rc.1).

* NuGet: [OpenTelemetry
v1.16.0](https://www.nuget.org/packages/OpenTelemetry/1.16.0)

  No notable changes.

See
[CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.16.0/src/OpenTelemetry/CHANGELOG.md)
for details.

* NuGet: [OpenTelemetry.Api
v1.16.0](https://www.nuget.org/packages/OpenTelemetry.Api/1.16.0)

  No notable changes.

See
[CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.16.0/src/OpenTelemetry.Api/CHANGELOG.md)
for details.

* NuGet: [OpenTelemetry.Api.ProviderBuilderExtensions
v1.16.0](https://www.nuget.org/packages/OpenTelemetry.Api.ProviderBuilderExtensions/1.16.0)

  No notable changes.

See
[CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.16.0/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md)
for details.

* NuGet: [OpenTelemetry.Exporter.Console
v1.16.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.Console/1.16.0)

  No notable changes.

See
[CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.16.0/src/OpenTelemetry.Exporter.Console/CHANGELOG.md)
for details.

* NuGet: [OpenTelemetry.Exporter.InMemory
v1.16.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.InMemory/1.16.0)

  No notable changes.

See
[CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.16.0/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md)
for details.

* NuGet: [OpenTelemetry.Exporter.OpenTelemetryProtocol
v1.16.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.OpenTelemetryProtocol/1.16.0)

  No notable changes.

See
[CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.16.0/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md)
for details.

* NuGet: [OpenTelemetry.Exporter.Zipkin
v1.16.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.Zipkin/1.16.0)

  No notable changes.

See
[CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.16.0/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md)
for details.

* NuGet: [OpenTelemetry.Extensions.Hosting
v1.16.0](https://www.nuget.org/packages/OpenTelemetry.Extensions.Hosting/1.16.0)

  No notable changes.

 ... (truncated)

## 1.16.0-rc.1

The following changes are from the previous release
[1.15.3](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.15.3).

* NuGet: [OpenTelemetry
v1.16.0-rc.1](https://www.nuget.org/packages/OpenTelemetry/1.16.0-rc.1)

* Stop validating View-provided metric stream `Name` against the
instrument
    name syntax, per
[spec
clarification](open-telemetry/opentelemetry-specification#5094).

([#​7300](open-telemetry/opentelemetry-dotnet#7300))
  
* Fix incorrect validation of `OTEL_BSP_*` and `OTEL_BLRP_*` environment
    variables.

([#​7187](open-telemetry/opentelemetry-dotnet#7187))
  
* Fix observable instrument callbacks running once per reader instead of
    once per collection cycle.

([#​7188](open-telemetry/opentelemetry-dotnet#7188))
  
* Added exception safety for user-supplied `ExemplarReservoir`
implementations.
Exceptions thrown from `Offer` are now caught and logged rather than
propagating
    out of `Counter.Add`/`Histogram.Record`.

([#​7277](open-telemetry/opentelemetry-dotnet#7277))
  
* Update `OpenTelemetrySdkEventSource` to support the W3C randomness
flag.

([#​7301](open-telemetry/opentelemetry-dotnet#7301))
  
  * Added `ObservedTimestamp` property to `LogRecord`.

([#​6979](open-telemetry/opentelemetry-dotnet#6979))
  
* **Breaking Change** Explicit histogram boundaries no longer allow more
than
    10 million values.

([#​7165](open-telemetry/opentelemetry-dotnet#7165))
  
* Fixed a circular reference which could cause a `LoggerProvider` to
fail to
resolve when one of its dependencies depends on `ILogger` or
`ILoggerFactory`.
As part of this fix the `LoggerProvider` resolved from dependency
injection
is now created lazily when the first logger is created rather than when
`ILoggerProvider` or `ILoggerFactory` is resolved. A consequence is that
any
invalid configuration now surfaces when the first log record is written
instead
    of when the logging services are resolved.

([#​7308](open-telemetry/opentelemetry-dotnet#7308))

See
[CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.16.0-rc.1/src/OpenTelemetry/CHANGELOG.md)
for details.

* NuGet: [OpenTelemetry.Api
v1.16.0-rc.1](https://www.nuget.org/packages/OpenTelemetry.Api/1.16.0-rc.1)

  * **Experimental (pre-release builds only):**
Add support for using environment variables as context propagation
carriers.

([#​7174](open-telemetry/opentelemetry-dotnet#7174))
  
* Fix `BaggagePropagator` to correctly follow Key and Value Encoding
rules as per
 ... (truncated)

## 1.16.0-beta.1

The following changes are from the previous release
[1.15.3-beta.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/coreunstable-1.15.3-beta.1).

* NuGet: [OpenTelemetry.Exporter.Prometheus.AspNetCore
v1.16.0-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Prometheus.AspNetCore/1.16.0-beta.1)

* Fixed scrape response cache freshness using monotonic time so it is
not
    affected by NTP system clock adjustments.

([#​7253](open-telemetry/opentelemetry-dotnet#7253))
  
  * **Breaking Change** Removed `DisableTimestamp` property from
    `PrometheusAspNetCoreOptions`.

([#​7176](open-telemetry/opentelemetry-dotnet#7176))
  
* Fixed the serialization of `NaN`, `PositiveInfinity`, and
`NegativeInfinity`
    values in Prometheus metrics to be compliant with the specification.

([#​7179](open-telemetry/opentelemetry-dotnet#7179))
  
* Fixed loss of precision when serializing `double` and `float` values
in
Prometheus metrics to be compliant with the specification by using 17
    significant digits to represent such values.

([#​7179](open-telemetry/opentelemetry-dotnet#7179))
  
* Fix non-ASCII characters in metric names and unit strings not being
sanitized
    correctly during Prometheus serialization.

([#​7184](open-telemetry/opentelemetry-dotnet#7184))
  
* Fix case where reader tracking could be reset while readers were still
active.

([#​7190](open-telemetry/opentelemetry-dotnet#7190))
  
* Improve `Accept` header handling for format negotiation so OpenMetrics
is
    selected correctly by considering whitespace and `q` weights.

([#​7208](open-telemetry/opentelemetry-dotnet#7208))
  
  * Emit OpenMetrics exemplars for counters and histogram buckets.

([#​7222](open-telemetry/opentelemetry-dotnet#7222))
  
* Fix incorrect handling of untyped metrics when using OpenMetrics
format.

([#​7219](open-telemetry/opentelemetry-dotnet#7219))
  
* Fix Prometheus/OpenMetrics serialization to emit metric and label
names
containing `_` instead of dropping them and prefixing leading digits.
    Invalid characters are replaced with `_` instead of being dropped.

([#​7209](open-telemetry/opentelemetry-dotnet#7209))
  
* Add `escaping=underscores` to the `Accept` header handling for content
    negotiation so OpenMetrics are handled correctly.

([#​7209](open-telemetry/opentelemetry-dotnet#7209))
  
* Omit histogram `_sum` and `_count` in OpenMetrics when negative bucket
    thresholds are present.

([#​7221](open-telemetry/opentelemetry-dotnet#7221))
 ... (truncated)

Commits viewable in [compare
view](open-telemetry/opentelemetry-dotnet@core-1.15.3...core-1.16.0).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=OpenTelemetry.Exporter.OpenTelemetryProtocol&package-manager=nuget&previous-version=1.15.3&new-version=1.16.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

keep-open Prevents issues and pull requests being closed as stale pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package pkg:OpenTelemetry.Exporter.Console Issues related to OpenTelemetry.Exporter.Console NuGet package pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants