35
35
36
36
@pytest .mark .parametrize (
37
37
"elasticapm_client" ,
38
- [{"span_compression_same_kind_max_duration" : "5ms" , "span_compression_exact_match_max_duration" : "5ms" }],
38
+ [
39
+ {
40
+ "span_compression_enabled" : True ,
41
+ "span_compression_same_kind_max_duration" : "5ms" ,
42
+ "span_compression_exact_match_max_duration" : "5ms" ,
43
+ }
44
+ ],
39
45
indirect = True ,
40
46
)
41
47
def test_exact_match (elasticapm_client ):
@@ -73,7 +79,13 @@ def test_exact_match(elasticapm_client):
73
79
74
80
@pytest .mark .parametrize (
75
81
"elasticapm_client" ,
76
- [{"span_compression_same_kind_max_duration" : "5ms" , "span_compression_exact_match_max_duration" : "5ms" }],
82
+ [
83
+ {
84
+ "span_compression_enabled" : True ,
85
+ "span_compression_same_kind_max_duration" : "5ms" ,
86
+ "span_compression_exact_match_max_duration" : "5ms" ,
87
+ }
88
+ ],
77
89
indirect = True ,
78
90
)
79
91
def test_same_kind (elasticapm_client ):
@@ -114,7 +126,13 @@ def test_same_kind(elasticapm_client):
114
126
115
127
@pytest .mark .parametrize (
116
128
"elasticapm_client" ,
117
- [{"span_compression_same_kind_max_duration" : "5ms" , "span_compression_exact_match_max_duration" : "5ms" }],
129
+ [
130
+ {
131
+ "span_compression_enabled" : True ,
132
+ "span_compression_same_kind_max_duration" : "5ms" ,
133
+ "span_compression_exact_match_max_duration" : "5ms" ,
134
+ }
135
+ ],
118
136
indirect = True ,
119
137
)
120
138
def test_exact_match_after_same_kind (elasticapm_client ):
@@ -162,7 +180,13 @@ def test_exact_match_after_same_kind(elasticapm_client):
162
180
163
181
@pytest .mark .parametrize (
164
182
"elasticapm_client" ,
165
- [{"span_compression_same_kind_max_duration" : "5ms" , "span_compression_exact_match_max_duration" : "5ms" }],
183
+ [
184
+ {
185
+ "span_compression_enabled" : True ,
186
+ "span_compression_same_kind_max_duration" : "5ms" ,
187
+ "span_compression_exact_match_max_duration" : "5ms" ,
188
+ }
189
+ ],
166
190
indirect = True ,
167
191
)
168
192
def test_nested_spans (elasticapm_client ):
@@ -199,7 +223,13 @@ def test_nested_spans(elasticapm_client):
199
223
200
224
@pytest .mark .parametrize (
201
225
"elasticapm_client" ,
202
- [{"span_compression_same_kind_max_duration" : "5ms" , "span_compression_exact_match_max_duration" : "5ms" }],
226
+ [
227
+ {
228
+ "span_compression_enabled" : True ,
229
+ "span_compression_same_kind_max_duration" : "5ms" ,
230
+ "span_compression_exact_match_max_duration" : "5ms" ,
231
+ }
232
+ ],
203
233
indirect = True ,
204
234
)
205
235
def test_buffer_is_reported_if_next_child_ineligible (elasticapm_client ):
@@ -224,7 +254,13 @@ def test_buffer_is_reported_if_next_child_ineligible(elasticapm_client):
224
254
225
255
@pytest .mark .parametrize (
226
256
"elasticapm_client" ,
227
- [{"span_compression_same_kind_max_duration" : "5ms" , "span_compression_exact_match_max_duration" : "5ms" }],
257
+ [
258
+ {
259
+ "span_compression_enabled" : True ,
260
+ "span_compression_same_kind_max_duration" : "5ms" ,
261
+ "span_compression_exact_match_max_duration" : "5ms" ,
262
+ }
263
+ ],
228
264
indirect = True ,
229
265
)
230
266
def test_compressed_spans_not_counted (elasticapm_client ):
@@ -254,3 +290,43 @@ def test_compressed_spans_not_counted(elasticapm_client):
254
290
spans = elasticapm_client .events [SPAN ]
255
291
assert len (spans ) == transaction ["span_count" ]["started" ] == 1
256
292
assert transaction ["span_count" ]["dropped" ] == 0
293
+
294
+
295
+ @pytest .mark .parametrize (
296
+ "elasticapm_client" ,
297
+ [
298
+ {
299
+ "span_compression_enabled" : False ,
300
+ "span_compression_same_kind_max_duration" : "5ms" ,
301
+ "span_compression_exact_match_max_duration" : "5ms" ,
302
+ }
303
+ ],
304
+ indirect = True ,
305
+ )
306
+ def test_span_compression_disabled (elasticapm_client ):
307
+ transaction = elasticapm_client .begin_transaction ("test" )
308
+ with elasticapm .capture_span (
309
+ "test" ,
310
+ span_type = "a" ,
311
+ span_subtype = "b" ,
312
+ span_action = "c" ,
313
+ leaf = True ,
314
+ duration = 2 ,
315
+ extra = {"destination" : {"service" : {"resource" : "x" }}},
316
+ ) as span1 :
317
+ assert not span1 .is_compression_eligible ()
318
+ with elasticapm .capture_span (
319
+ "test" ,
320
+ span_type = "a" ,
321
+ span_subtype = "b" ,
322
+ span_action = "c" ,
323
+ leaf = True ,
324
+ duration = 3 ,
325
+ extra = {"destination" : {"service" : {"resource" : "x" }}},
326
+ ) as span2 :
327
+ assert not span2 .is_compression_eligible ()
328
+ elasticapm_client .end_transaction ("test" )
329
+ spans = elasticapm_client .events [SPAN ]
330
+ assert len (spans ) == 2
331
+ span = spans [0 ]
332
+ assert "composite" not in span
0 commit comments