line: parse DogStatsD container ID field on lines without tags - #748
Open
Vasu-Madaan wants to merge 1 commit into
Open
line: parse DogStatsD container ID field on lines without tags#748Vasu-Madaan wants to merge 1 commit into
Vasu-Madaan wants to merge 1 commit into
Conversation
The DogStatsD v1.2 container ID field (|c:<id>) can appear on a line that has no |# tags. In that case LineToEvents fell through to the legacy multi-metric ':' split, which shredded the |c:<id> field: the sample was dropped and counted as malformed_container_id + malformed_component, so the metric was never exported. Detect the container ID field (always the final '|'-delimited field) and, like |# tags, skip the legacy ':' split for such lines. A valid legacy line always ends in a bare stat type (c, g, ms, ...), never "c:<id>", so this does not affect legacy multi-metric parsing. Add tests for counter/gauge/timer/complex-value container ID lines without tags.
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.
Problem
The DogStatsD v1.2 container ID field (
|c:<id>) can appear on a line that has no|#tags (for example a DogStatsD client with origin/container detection enabled but no constant tags configured). A counter then looks like:LineToEventsonly treats a line as DogStatsD (and skips the legacy multi-metric:split) when it contains|#. Without tags, the line falls through tostrings.Split(elements[1], ":"), which splits on every colon and shreds the container ID field:The first fragment
1|c|cparses value=1, type=c, and a trailing barecthat fails the container-ID check (malformed_container_id); the second fragment has too few parts (malformed_component). The sample is dropped and the metric is never exported, even though the same line with tags parses correctly:Fix
Detect the container ID field (always the final
|-delimited field) and, like|#tags, skip the legacy:split for such lines. A valid legacy multi-metric line always ends in a bare stat type (c,g,ms, ...), neverc:<id>, so legacy parsing is unaffected.Tests
Adds
LineToEventscases for counter/gauge/timer/complex-value container-ID lines without tags.gofmt,go vet, andgo test ./...pass.Note: Claude was used to help investigate and prepare this change.