Commit 1c2a386
authored
Add srv_src field to client stats payload (#8339)
## Summary of changes
Add `srv_src` field to the client stats payload, propagating the service
name source alongside trace stats.
## Reason for change
Per the [service name source
RFC](https://docs.google.com/document/d/11OnbVYMDK-c5D-_V4QfOvL0Pc0z5oFQFGY3xSI-W7xk/edit?tab=t.0#heading=h.uoivahvmuvbg),
the source must be propagated in both trace and stats payloads. The
trace payload (`_dd.svc_src` span meta) was added in PR #8302. This
completes the implementation by adding `srv_src` at the stats bucket
level.
## Implementation details
- **`StatsAggregationKey.cs`**: Added `ServiceSource` field. It
participates in equality and hash code, so stats with different sources
aggregate into distinct buckets.
- **`StatsAggregator.cs`**: `BuildKey()` now reads
`span.Context.ServiceNameSource` and passes it to the aggregation key.
- **`StatsBuffer.cs`**: `SerializeBucket()` conditionally serializes
`srv_src` when `ServiceSource` is non-null (dynamic map size: 13 with
source, 12 without).
## Test coverage
- `KeyEquality_WithServiceSource`: Verifies that keys with different
sources are not equal.
- `Serialization_WithServiceSource`: Verifies `srv_src` is serialized
when present and absent when null.
- Existing `StatsBufferTests` and `StatsAggregatorTests` updated and
passing.
## Other details
[APMLP-1015](https://datadoghq.atlassian.net/browse/APMLP-1015)
Related agent PR: DataDog/datadog-agent#45982
Reference Java implementation:
DataDog/dd-trace-java#10653
[APMLP-1015]:
https://datadoghq.atlassian.net/browse/APMLP-1015?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ1 parent d5d94dd commit 1c2a386
5 files changed
Lines changed: 78 additions & 9 deletions
File tree
- tracer
- src/Datadog.Trace/Agent
- test
- Datadog.Trace.TestHelpers/Stats
- Datadog.Trace.Tests/Agent
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| |||
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
| 61 | + | |
57 | 62 | | |
58 | 63 | | |
59 | 64 | | |
| |||
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
| 75 | + | |
70 | 76 | | |
71 | 77 | | |
72 | 78 | | |
| |||
86 | 92 | | |
87 | 93 | | |
88 | 94 | | |
| 95 | + | |
89 | 96 | | |
90 | 97 | | |
91 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
194 | 204 | | |
195 | 205 | | |
196 | 206 | | |
| |||
200 | 210 | | |
201 | 211 | | |
202 | 212 | | |
| 213 | + | |
203 | 214 | | |
204 | 215 | | |
205 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| |||
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
130 | 138 | | |
131 | 139 | | |
132 | 140 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
51 | 54 | | |
Lines changed: 48 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
29 | 40 | | |
30 | 41 | | |
31 | 42 | | |
| |||
55 | 66 | | |
56 | 67 | | |
57 | 68 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
61 | 72 | | |
62 | 73 | | |
63 | 74 | | |
| |||
103 | 114 | | |
104 | 115 | | |
105 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
106 | 145 | | |
107 | 146 | | |
108 | 147 | | |
109 | 148 | | |
110 | 149 | | |
111 | | - | |
112 | | - | |
| 150 | + | |
| 151 | + | |
113 | 152 | | |
114 | 153 | | |
115 | 154 | | |
| |||
144 | 183 | | |
145 | 184 | | |
146 | 185 | | |
147 | | - | |
| 186 | + | |
148 | 187 | | |
149 | 188 | | |
150 | 189 | | |
| |||
175 | 214 | | |
176 | 215 | | |
177 | 216 | | |
| 217 | + | |
178 | 218 | | |
179 | 219 | | |
180 | 220 | | |
| |||
0 commit comments