-
Notifications
You must be signed in to change notification settings - Fork 311
Add peer tags, span kind and trace root flag to MetricKey bucket #9178
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
Open
bric3
wants to merge
5
commits into
master
Choose a base branch
from
bdu/add-missing-attributes-in-metrics-key
base: master
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.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
93d1792
chore(css): Add peer tags, span kind and trace root flag to MetricKey…
bric3 d4bc933
chore(css): Use a map to create the metric key
bric3 8ad375a
Improves CSS peer tag aggregation (#9336)
amarziali 877e8cf
Hardcode eligible span kind since agent backpropagated are deprecated
amarziali 318a10e
revisit peer tags aggregation rules according to the rfc
amarziali 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
97 changes: 97 additions & 0 deletions
97
...-core/src/jmh/java/datadog/trace/common/metrics/ConflatingMetricsAggregatorBenchmark.java
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,97 @@ | ||
package datadog.trace.common.metrics; | ||
|
||
import static java.util.concurrent.TimeUnit.MICROSECONDS; | ||
import static java.util.concurrent.TimeUnit.SECONDS; | ||
|
||
import datadog.communication.ddagent.DDAgentFeaturesDiscovery; | ||
import datadog.communication.monitor.Monitoring; | ||
import datadog.trace.api.WellKnownTags; | ||
import datadog.trace.core.CoreSpan; | ||
import datadog.trace.util.Strings; | ||
import java.nio.ByteBuffer; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Set; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
@State(Scope.Benchmark) | ||
@Warmup(iterations = 1, time = 30, timeUnit = SECONDS) | ||
@Measurement(iterations = 3, time = 30, timeUnit = SECONDS) | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(MICROSECONDS) | ||
@Fork(value = 1) | ||
public class ConflatingMetricsAggregatorBenchmark { | ||
private final DDAgentFeaturesDiscovery featuresDiscovery = | ||
new FixedAgentFeaturesDiscovery( | ||
Collections.singleton("peer.hostname"), Collections.emptySet()); | ||
private final ConflatingMetricsAggregator aggregator = | ||
new ConflatingMetricsAggregator( | ||
new WellKnownTags("", "", "", "", "", ""), | ||
Collections.emptySet(), | ||
featuresDiscovery, | ||
new NullSink(), | ||
2048, | ||
2048); | ||
private final List<CoreSpan<?>> spans = generateTrace(64); | ||
|
||
static List<CoreSpan<?>> generateTrace(int len) { | ||
final List<CoreSpan<?>> trace = new ArrayList<>(); | ||
for (int i = 0; i < len; i++) { | ||
SimpleSpan span = new SimpleSpan("", "", "", "", true, true, false, 0, 10, -1); | ||
span.setTag("peer.hostname", Strings.random(10)); | ||
trace.add(span); | ||
} | ||
return trace; | ||
} | ||
|
||
static class NullSink implements Sink { | ||
|
||
@Override | ||
public void register(EventListener listener) {} | ||
|
||
@Override | ||
public void accept(int messageCount, ByteBuffer buffer) {} | ||
} | ||
|
||
static class FixedAgentFeaturesDiscovery extends DDAgentFeaturesDiscovery { | ||
private final Set<String> peerTags; | ||
private final Set<String> spanKinds; | ||
|
||
public FixedAgentFeaturesDiscovery(Set<String> peerTags, Set<String> spanKinds) { | ||
// create a fixed discovery with metrics enabled | ||
super(null, Monitoring.DISABLED, null, false, true); | ||
this.peerTags = peerTags; | ||
this.spanKinds = spanKinds; | ||
} | ||
|
||
@Override | ||
public void discover() { | ||
// do nothing | ||
} | ||
|
||
@Override | ||
public boolean supportsMetrics() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public Set<String> peerTags() { | ||
return peerTags; | ||
} | ||
} | ||
|
||
@Benchmark | ||
public void benchmark(Blackhole blackhole) { | ||
blackhole.consume(aggregator.publish(spans)); | ||
} | ||
} |
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
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.
🎯 suggestion: Can't we make a dedicated type for the cache and creator rather than using a
Pair<DDCache<String, UTF8BytesString>, Function<String, UTF8BytesString>>
? It feels hard to read.Because it always end up calling
cache.computeIfAbsent(key, creator)
, so the wholePair<...>
thing can be simplified as a functional interface like:Function<String, UTF8BytesString>
.