[APMSVLS-464][APMSVLS-463] fix: Configure span kind and peer tag stats#1189
[APMSVLS-464][APMSVLS-463] fix: Configure span kind and peer tag stats#1189lucaspimentel wants to merge 10 commits into
Conversation
Tests verify that StatsConcentratorService computes stats for spans with span.kind and populates peer_tags in output. Both tests currently fail due to empty span_kinds_stats_computed and peer_tag_keys vecs passed to SpanConcentrator::new(). 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
Pass STATS_ELIGIBLE_SPAN_KINDS and DEFAULT_PEER_TAG_KEYS to SpanConcentrator::new() to match the Go agent defaults. This enables stats for OTel spans with span.kind and adds per-dependency granularity via peer tags for client/producer/consumer spans. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
c06bc9b to
2eb4403
Compare
|
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR configures Bottlecap’s SpanConcentrator to match the Go agent defaults for (1) which span.kind values are eligible for stats computation and (2) which peer-related tag keys are used to populate per-dependency peer_tags, closing gaps in agent-side trace stats aggregation.
Changes:
- Configure
SpanConcentratorwith the Go agent’s default computed span kinds (client,server,producer,consumer) instead of an empty list. - Configure
SpanConcentratorwith the Go agent’s default peer tag key set (basePeerTags) instead of an empty list. - Add end-to-end tests for span-kind-based stats eligibility and peer tag population in emitted stats.
| /// A non-root, non-measured span with `span.kind`="client" should produce stats | ||
| /// when `ComputeStatsBySpanKind` is enabled (i.e. `span_kinds_stats_computed` is | ||
| /// populated). With the current empty vec, this span is silently dropped. |
There was a problem hiding this comment.
Fixed. Reworded doc comment to describe the current span-kind allowlist behavior.
| /// A client span with peer tag meta keys (`db.instance`, `db.system`) should produce | ||
| /// stats with non-empty `peer_tags` when `peer_tag_keys` is configured. With the | ||
| /// current empty vec, `peer_tags` in the output will always be empty. |
There was a problem hiding this comment.
Fixed. Reworded doc comment to describe the current peer_tag_keys behavior.
| assert!( | ||
| result.is_some(), | ||
| "Expected stats for a client span with peer tags, but got None. \ | ||
| span.kind-based eligibility is not working." | ||
| ); |
There was a problem hiding this comment.
Fixed. Removed the span.kind eligibility sentence from the failure message.
| /// TODO: The source of truth is the Go agent's `basePeerTags` (derived from | ||
| /// pkg/trace/semantics/mappings.json); this list is hand-copied here and in other Rust repos. | ||
| /// Refactor so they stay in sync with the Go agent instead of each keeping its own copy. | ||
| const DEFAULT_PEER_TAG_KEYS: [&str; 43] = [ |
There was a problem hiding this comment.
Fixed. Changed DEFAULT_PEER_TAG_KEYS to &[&str].
| /// TODO: The source of truth is the Go agent's `KindsComputed`; this list is hand-copied here | ||
| /// and in other Rust repos. Refactor so they stay in sync with the Go agent instead of each | ||
| /// keeping its own copy. | ||
| const STATS_ELIGIBLE_SPAN_KINDS: [&str; 4] = ["client", "consumer", "producer", "server"]; |
There was a problem hiding this comment.
nit: prefer &[&str] over [&str; 4] to make future update easier.
There was a problem hiding this comment.
Fixed. Changed STATS_ELIGIBLE_SPAN_KINDS to &[&str].
Overview
Configure
SpanConcentratorin bottlecap with the Go agent's defaultComputeStatsBySpanKindspan kinds andbasePeerTagspeer tag keys, fixing two gaps in agent-side trace stats computation:APMSVLS-464:span_kinds_stats_computedwas empty, so non-top-level, non-measured spans withspan.kind=server/client/producer/consumer) were silently excluded from stats.APMSVLS-463:peer_tag_keyswas empty, so client/producer/consumer spans had no per-dependency granularity in stats output (e.g., all S3 buckets, DynamoDB tables, Kafka topics lumped together).Changes
STATS_ELIGIBLE_SPAN_KINDSconstant (4 span kinds matching the Go agent'sKindsComputed)DEFAULT_PEER_TAG_KEYSconstant (43 peer tag keys matching the Go agent'sbasePeerTagsfrommappings.json)SpanConcentrator::new()instead of empty vecsStatsConcentratorServicepipeline for both featuresFollow-up
Both constants are hand-copied from the Go agent (
KindsComputedandbasePeerTags), which is the source of truth, and the same lists are also duplicated inserverless-components. A future refactor should keep the Rust agents in sync with the Go agent rather than each maintaining its own copy.Testing
test_span_kind_stats_computed: sends a non-root, non-measured client span through the service, verifies stats are produced withspan_kind="client"test_peer_tags_populated: sends a client span withdb.instanceanddb.systemmeta, verifiespeer_tagscontains both in the stats output