-
Notifications
You must be signed in to change notification settings - Fork 1.5k
wip #54928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
vickenty
wants to merge
2
commits into
main
Choose a base branch
from
vickenty/diu
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
wip #54928
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed | ||
| // under the Apache License Version 2.0. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2016-present Datadog, Inc. | ||
|
|
||
| package serverimpl | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/DataDog/datadog-agent/pkg/metrics" | ||
| "github.com/DataDog/datadog-agent/pkg/tagset" | ||
| ) | ||
|
|
||
| // TestInternedTagsReachTheSample checks that tags parsed off the wire arrive at | ||
| // the aggregator as handles rather than being copied into plain strings, and that | ||
| // the handles are canonical: the same tag seen on two different messages resolves | ||
| // to the same handle, so the aggregator holds one copy of the string. | ||
| func TestInternedTagsReachTheSample(t *testing.T) { | ||
| conf := enrichConfig{defaultHostname: "default-hostname"} | ||
|
|
||
| first, err := parseAndEnrichMultipleMetricMessageNoResolve(t, | ||
| []byte("daemon:666|g|#env:prod,service:api"), conf) | ||
| require.NoError(t, err) | ||
| require.Len(t, first, 1) | ||
|
|
||
| second, err := parseAndEnrichMultipleMetricMessageNoResolve(t, | ||
| []byte("other:1|c|#env:prod,service:api"), conf) | ||
| require.NoError(t, err) | ||
| require.Len(t, second, 1) | ||
|
|
||
| // The pipeline populates ITags, not Tags. | ||
| require.Len(t, first[0].ITags, 2) | ||
| assert.Nil(t, first[0].Tags, "the interned pipeline must not materialize Tags") | ||
|
|
||
| assert.Equal(t, []string{"env:prod", "service:api"}, tagset.Values(first[0].ITags)) | ||
|
|
||
| // Handles are canonical across parsers and messages. | ||
| assert.Equal(t, first[0].ITags, second[0].ITags, | ||
| "identical tags on different messages must share handles") | ||
|
|
||
| // The memoized hash matches what the accumulator would compute for the string. | ||
| for _, itag := range first[0].ITags { | ||
| assert.Equal(t, tagset.Intern(itag.Value()).Hash(), itag.Hash()) | ||
| } | ||
| } | ||
|
|
||
| // TestInternedTagsFeedAccumulator checks the aggregator side: GetTags must push | ||
| // the handles into the hashing accumulator with their precomputed hashes, and the | ||
| // resulting tag set must be identical to the one a plain-string sample produces. | ||
| func TestInternedTagsFeedAccumulator(t *testing.T) { | ||
| conf := enrichConfig{defaultHostname: "default-hostname"} | ||
|
|
||
| samples, err := parseAndEnrichMultipleMetricMessageNoResolve(t, | ||
| []byte("daemon:666|g|#env:prod,service:api"), conf) | ||
| require.NoError(t, err) | ||
| require.Len(t, samples, 1) | ||
|
|
||
| interned := tagset.NewHashingTagsAccumulator() | ||
| interned.AppendInterned(samples[0].ITags...) | ||
|
|
||
| plain := tagset.NewHashingTagsAccumulatorWithTags([]string{"env:prod", "service:api"}) | ||
|
|
||
| assert.Equal(t, plain.Get(), interned.Get()) | ||
| assert.Equal(t, plain.Hash(), interned.Hash(), | ||
| "interned tags must hash identically to the same tags as strings") | ||
| } | ||
|
|
||
| func parseAndEnrichMultipleMetricMessageNoResolve(t *testing.T, message []byte, conf enrichConfig) ([]metrics.MetricSample, error) { | ||
| deps := newServerDeps(t) | ||
| stringInternerTelemetry := newSiTelemetry(false, deps.Telemetry) | ||
| parser := newParser(deps.Config, newFloat64ListPool(deps.Config, deps.Telemetry), 1, deps.WMeta, stringInternerTelemetry) | ||
| parsed, err := parser.parseMetricSample(message) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return enrichMetricSample(nil, parsed, "", 0, "", conf, nil), nil | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
impl_testtarget has an explicit source list that does not includeintern_pipeline_test.go, so the repository's supported Bazel test path silently skips both newly added end-to-end interning assertions. Add this file tocomp/dogstatsd/server/impl/BUILD.bazelso the coverage runs under Bazel.AGENTS.md reference: AGENTS.md:L93-L96
Useful? React with 👍 / 👎.