3535
3636@pytest .mark .parametrize (
3737 "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+ ],
3945 indirect = True ,
4046)
4147def test_exact_match (elasticapm_client ):
@@ -73,7 +79,13 @@ def test_exact_match(elasticapm_client):
7379
7480@pytest .mark .parametrize (
7581 "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+ ],
7789 indirect = True ,
7890)
7991def test_same_kind (elasticapm_client ):
@@ -114,7 +126,13 @@ def test_same_kind(elasticapm_client):
114126
115127@pytest .mark .parametrize (
116128 "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+ ],
118136 indirect = True ,
119137)
120138def test_exact_match_after_same_kind (elasticapm_client ):
@@ -162,7 +180,13 @@ def test_exact_match_after_same_kind(elasticapm_client):
162180
163181@pytest .mark .parametrize (
164182 "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+ ],
166190 indirect = True ,
167191)
168192def test_nested_spans (elasticapm_client ):
@@ -199,7 +223,13 @@ def test_nested_spans(elasticapm_client):
199223
200224@pytest .mark .parametrize (
201225 "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+ ],
203233 indirect = True ,
204234)
205235def 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):
224254
225255@pytest .mark .parametrize (
226256 "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+ ],
228264 indirect = True ,
229265)
230266def test_compressed_spans_not_counted (elasticapm_client ):
@@ -254,3 +290,43 @@ def test_compressed_spans_not_counted(elasticapm_client):
254290 spans = elasticapm_client .events [SPAN ]
255291 assert len (spans ) == transaction ["span_count" ]["started" ] == 1
256292 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