{"record":{"id":"645b69be7b3fdb56","repo":"elsa-workflows/elsa-core","slug":"the-otlp-timestamp-is-outside-the-supported-range","errorCode":null,"errorMessage":"The OTLP timestamp is outside the supported range.","messagePattern":"The OTLP timestamp is outside the supported range\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Diagnostics.OpenTelemetry/Ingestion/HttpProtobuf/OtlpHttpProtobufParser.cs","lineNumber":566,"sourceCode":"            .Select(x => x!)\n            .Distinct(StringComparer.OrdinalIgnoreCase)\n            .ToList();\n\n        return new TelemetryTrace(spans.Key, root.SpanId, root.Name, start, end, end - start, status, orderedSpans.Select(x => x.ResourceId).Distinct(StringComparer.OrdinalIgnoreCase).ToList(), workflowInstanceIds, orderedSpans.Count);\n    }\n\n    private static string? GetAttribute(IDictionary<string, string?> attributes, string key) => attributes.TryGetValue(key, out var value) ? value : null;\n\n    private static DateTimeOffset FromUnixNanos(ulong value)\n    {\n        try\n        {\n            var ticks = checked((long)(value / 100));\n            return DateTimeOffset.UnixEpoch.AddTicks(ticks);\n        }\n        catch (Exception e) when (e is OverflowException or ArgumentOutOfRangeException)\n        {\n            throw new InvalidDataException(\"The OTLP timestamp is outside the supported range.\", e);\n        }\n    }\n\n    private static string ToHex(ReadOnlySpan<byte> bytes)\n    {\n        return Convert.ToHexString(bytes).ToLowerInvariant();\n    }\n\n    private static string SpanKindName(ulong value) => value switch\n    {\n        1 => \"internal\",\n        2 => \"server\",\n        3 => \"client\",\n        4 => \"producer\",\n        5 => \"consumer\",\n        _ => \"unspecified\"\n    };\n","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Diagnostics.OpenTelemetry/Ingestion/HttpProtobuf/OtlpHttpProtobufParser.cs#L548-L584","documentation":"When parsing OTLP protobuf payloads, 64-bit nanosecond timestamps are converted to DateTimeOffset via ticks added to UnixEpoch inside a checked block. Overflow or a resulting out-of-range value is caught and rethrown as InvalidDataException with this message, keeping the original exception as the inner exception.","triggerScenarios":"An OTLP record carries time_unix_nano / observed_time_unix_nano values that overflow DateTimeOffset's tick range (negative near-zero values, year-0 or year-10000+ dates) when converted from nanoseconds.","commonSituations":"Misconfigured SDKs emitting 0 or sentinel timestamps that become extreme dates; clock bugs producing negative durations; third-party exporters writing malformed nano timestamps.","solutions":["Inspect the raw OTLP payload and correct or reject records with time_unix_nano values near 0 or outside 1970-10000.","Fix the emitting SDK/exporter clock configuration so timestamps are real epoch nanoseconds.","If malicious/unknown senders are expected, validate the timestamp range client-side before export or reject at the collector boundary."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"static bool IsPlausibleUnixNano(ulong nano) =>\n    nano is > 0 and < 253_402_300_799_999_999_999; // within DateTimeOffset range","typeGuard":null,"tryCatchPattern":"try { ParseAndIngest(payload); }\ncatch (InvalidDataException ex) { logger.LogWarning(ex, \"Rejected OTLP payload with out-of-range timestamp.\"); }","preventionTips":["Ensure emitting SDKs use real epoch-nanosecond clocks; reject 0/sentinel timestamps at the source.","Validate exporter clocks (NTP sync, no negative durations) before shipping traces."],"tags":["opentelemetry","otlp","timestamp","parsing"],"backgroundTag":"value-out-of-range","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}