Skip to content

Commit 77a6c3f

Browse files
committed
Fix sampling ratio test. Fix span event sampling and extend tests.
1 parent 87efbdb commit 77a6c3f

File tree

4 files changed

+179
-44
lines changed

4 files changed

+179
-44
lines changed

sdk/highlight-run/src/client/graph/operators/query.gql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ query GetSamplingConfig($project_id: ID!) {
1313
}
1414
}
1515
events {
16-
name {
16+
name {
17+
...MatchParts
18+
}
19+
attributes {
20+
key {
1721
...MatchParts
1822
}
19-
attributes {
20-
key {
21-
...MatchParts
22-
}
23-
attribute {
24-
...MatchParts
25-
}
23+
attribute {
24+
...MatchParts
2625
}
26+
}
2727
}
2828
samplingRatio
2929
}

sdk/highlight-run/src/client/otel/sampling/CustomSampler.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,11 @@ export class CustomSampler implements ExportSampler {
156156
eventConfig: SpanEventMatchConfig,
157157
event: TimedEvent,
158158
): boolean {
159-
// Match by event name
160-
if (!this.matchesValue(eventConfig.name, event.name)) {
161-
return false
159+
if (eventConfig.name) {
160+
// Match by event name
161+
if (!this.matchesValue(eventConfig.name, event.name)) {
162+
return false
163+
}
162164
}
163165

164166
// Match by event attributes if specified

sdk/highlight-run/src/client/otel/sampling/log-test-scenarios.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"expected_result": {
2121
"sample": true,
2222
"attributes": {
23-
"launchdarkly.samplingRatio": 42
23+
"launchdarkly.sampling.ratio": 42
2424
}
2525
}
2626
},
@@ -29,7 +29,7 @@
2929
"expected_result": {
3030
"sample": false,
3131
"attributes": {
32-
"launchdarkly.samplingRatio": 42
32+
"launchdarkly.sampling.ratio": 42
3333
}
3434
}
3535
}
@@ -56,7 +56,7 @@
5656
"expected_result": {
5757
"sample": true,
5858
"attributes": {
59-
"launchdarkly.samplingRatio": 42
59+
"launchdarkly.sampling.ratio": 42
6060
}
6161
}
6262
},
@@ -65,7 +65,7 @@
6565
"expected_result": {
6666
"sample": false,
6767
"attributes": {
68-
"launchdarkly.samplingRatio": 42
68+
"launchdarkly.sampling.ratio": 42
6969
}
7070
}
7171
}
@@ -117,7 +117,7 @@
117117
"expected_result": {
118118
"sample": true,
119119
"attributes": {
120-
"launchdarkly.samplingRatio": 42
120+
"launchdarkly.sampling.ratio": 42
121121
}
122122
}
123123
},
@@ -126,7 +126,7 @@
126126
"expected_result": {
127127
"sample": false,
128128
"attributes": {
129-
"launchdarkly.samplingRatio": 42
129+
"launchdarkly.sampling.ratio": 42
130130
}
131131
}
132132
}
@@ -163,7 +163,7 @@
163163
"expected_result": {
164164
"sample": true,
165165
"attributes": {
166-
"launchdarkly.samplingRatio": 75
166+
"launchdarkly.sampling.ratio": 75
167167
}
168168
}
169169
},
@@ -172,7 +172,7 @@
172172
"expected_result": {
173173
"sample": false,
174174
"attributes": {
175-
"launchdarkly.samplingRatio": 75
175+
"launchdarkly.sampling.ratio": 75
176176
}
177177
}
178178
}
@@ -209,7 +209,7 @@
209209
"expected_result": {
210210
"sample": true,
211211
"attributes": {
212-
"launchdarkly.samplingRatio": 75
212+
"launchdarkly.sampling.ratio": 75
213213
}
214214
}
215215
},
@@ -218,7 +218,7 @@
218218
"expected_result": {
219219
"sample": false,
220220
"attributes": {
221-
"launchdarkly.samplingRatio": 75
221+
"launchdarkly.sampling.ratio": 75
222222
}
223223
}
224224
}
@@ -255,7 +255,7 @@
255255
"expected_result": {
256256
"sample": true,
257257
"attributes": {
258-
"launchdarkly.samplingRatio": 100
258+
"launchdarkly.sampling.ratio": 100
259259
}
260260
}
261261
},
@@ -264,7 +264,7 @@
264264
"expected_result": {
265265
"sample": false,
266266
"attributes": {
267-
"launchdarkly.samplingRatio": 100
267+
"launchdarkly.sampling.ratio": 100
268268
}
269269
}
270270
}
@@ -301,7 +301,7 @@
301301
"expected_result": {
302302
"sample": true,
303303
"attributes": {
304-
"launchdarkly.samplingRatio": 50
304+
"launchdarkly.sampling.ratio": 50
305305
}
306306
}
307307
},
@@ -310,7 +310,7 @@
310310
"expected_result": {
311311
"sample": false,
312312
"attributes": {
313-
"launchdarkly.samplingRatio": 50
313+
"launchdarkly.sampling.ratio": 50
314314
}
315315
}
316316
}
@@ -374,7 +374,7 @@
374374
"expected_result": {
375375
"sample": true,
376376
"attributes": {
377-
"launchdarkly.samplingRatio": 90
377+
"launchdarkly.sampling.ratio": 90
378378
}
379379
}
380380
},
@@ -383,7 +383,7 @@
383383
"expected_result": {
384384
"sample": false,
385385
"attributes": {
386-
"launchdarkly.samplingRatio": 90
386+
"launchdarkly.sampling.ratio": 90
387387
}
388388
}
389389
}

0 commit comments

Comments
 (0)