Skip to content

get_default_trace_events filters in UTC but returns event_time in server-local time, unmarked #3198

Description

@erikdarlingdata

get_default_trace_events filters in UTC and returns event_time in the monitored server's LOCAL time, with nothing on the response saying so. Every correlation against another surface is silently off by the server's UTC offset.

Measured

Server kappa (kappa-01, US Eastern, UTC-4).

Call A — as_of=2026-09-09T05:30:00Z, hours_back=3 (UTC window 02:30–05:30). Returned 22 events, timestamped 00:28:02 through 01:22:01. None of those labels is inside the window requested.

Call B — as_of=2026-09-09T04:35:00Z, hours_back=1 (UTC window 03:35–04:35). Returned exactly the 6 events labelled 00:28:02–00:28:21, and correctly dropped the 00:44 and 01:22 ones.

That is the discriminating result. The narrower UTC window kept precisely the events whose labels plus four hours (04:28) fall inside it, and excluded the ones whose labels plus four hours (04:44, 05:22) fall outside. The filter is correct and operating in UTC; the rendered event_time is local.

Why it matters beyond cosmetics

collection_log / get_collection_log collection_time, list_servers last_collection, and this tool's own as_of parameter are all UTC. event_time is not, and no field, note or suffix marks it.

So the natural operation — line trace events up against a collector error or an incident window — is wrong by the offset, and wrong in the direction that inverts causality: an event that really happened at 04:28 UTC reads as 00:28, appearing to precede a 04:28 collector error by four hours rather than coinciding with it.

Found while correlating a real incident. kappa logged "Database 'kappa' cannot be opened. It is in the middle of a restore" at 04:28:06 UTC; this tool reports the matching SQLServerHostManager object alters at "00:28:04" and "00:28:21". They are the same twenty seconds. Read as printed, they are four hours apart and unrelated.

I only noticed because the returned times fell outside the window I had asked for. A caller who asked for a wide window would get plausible-looking timestamps and no signal at all that they were in a different frame.

Fix options, in preference order

  1. Return UTC, matching every neighbouring surface and the tool's own as_of. Cleanest, and a behaviour change callers may be compensating for.
  2. Keep local but say so unambiguously — rename to event_time_local, add the offset as its own field, and state it in the tool description. Weaker: it leaves two frames on one response.

Whichever way, the tool description should state the frame explicitly. It currently documents as_of as UTC and says nothing about the returned column, which is what makes the mismatch invisible.

Check the siblings before closing

get_default_trace_events is unlikely to be the only reader of a trace/XEvent-sourced timestamp. Worth a sweep of the other event-shaped surfaces (get_health_parser_*, get_deadlocks, get_blocked_process_*, get_system_health_events) for the same pattern rather than fixing this one in isolation — a mixed-frame response set is worse than a consistently wrong one, because it defeats the workaround.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions