Skip to content

DateTime.UtcNow is not good enough for high precision durations in DiagnosticSource.Activity #20314

@cwe1ss

Description

@cwe1ss

/cc @lmolkova @vancem

The new Activity class uses DateTime.UtcNow to calculate the duration of an activity. However depending on the system, the precision of DateTime might be at ~ 15ms.

I don't think this is precise enough for server scenarios.

In my OpenTracing instrumentation, I'm currently using a combination of DateTime + Stopwatch to overcome this issue. My code isn't in production yet though, so I'm not sure if this has any drawbacks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.DateTimeenhancementProduct code improvement that does NOT require public API changes/additions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions