fix(sentry): accept ISO timestamps and non-string span data in nested items - #349
Draft
tsan88 wants to merge 1 commit into
Draft
fix(sentry): accept ISO timestamps and non-string span data in nested items#349tsan88 wants to merge 1 commit into
tsan88 wants to merge 1 commit into
Conversation
… items Nested envelope structures declared their timestamps as json.Number while the top-level ErrorEvent already used FlexibleTS. PHP/Laravel SDKs send ISO 8601 strings in breadcrumbs, transactions, spans and logs, so unmarshalling failed with "invalid number literal, trying to unmarshal ... into Number" and the entire event was dropped (the request still answered 200). RawSpan.Data had the same class of problem: declared map[string]string, but SDKs put numbers and booleans there (http.response.status_code: 200), which failed with "cannot unmarshal number into Go struct field RawSpan.spans.data of type string" and dropped the transaction with all of its spans. Measured on a production stream before the fix: of 1326 envelopes accepted by the proxy for one PHP project only 62 reached the database. Breadcrumb, Transaction, RawSpan and LogRecord now use FlexibleTS, and span attributes go through a SpanData type that normalizes values to strings, so existing consumers stay unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Envelopes were being dropped on parse, with the SDK still getting HTTP 200.
Nested envelope structures declared their timestamps as
json.Number, while the top-levelErrorEventalready usedFlexibleTS. PHP/Laravel SDKs put ISO 8601 strings into breadcrumbs, transactions, spans and logs, so unmarshalling failed withand the whole event was discarded.
RawSpan.Datahad the same class of problem: declaredmap[string]string, but SDKs put numbers and booleans there (http.response.status_code: 200), which failed withand dropped the transaction together with all of its spans.
Measured on a production instance before the fix, over one hour: of 1326 envelopes accepted by the proxy for one PHP project, only 62 reached the database. A second project got 135 events in and stored none at all.
Changes
Breadcrumb,Transaction,RawSpanandLogRecordtimestamps useFlexibleTS, the type this repo already has for exactly this.SpanDatatype that normalizes values to strings, soclassifySpan,extractServiceNameand the spans table stay unchanged. Objects and arrays keep their raw JSON instead of being lost.Testing
go vet ./...,go test ./...andgo buildpass. Added regression tests for both shapes (TestFlexibleTS_NestedStructures,TestSpanData_AcceptsNonStringValues). Running in production on our instance since 2026-09-03.