@@ -255,6 +255,7 @@ def test_logging_filter_no_span(elasticapm_client):
255255 record = logging .LogRecord (__name__ , logging .DEBUG , __file__ , 252 , "dummy_msg" , [], None )
256256 f .filter (record )
257257 assert record .elasticapm_transaction_id == transaction .id
258+ assert record .elasticapm_service_name == transaction .tracer .config .service_name
258259 assert record .elasticapm_trace_id == transaction .trace_parent .trace_id
259260 assert record .elasticapm_span_id is None
260261 assert record .elasticapm_labels
@@ -277,6 +278,7 @@ def test_logging_filter_span(elasticapm_client):
277278 record = logging .LogRecord (__name__ , logging .DEBUG , __file__ , 252 , "dummy_msg" , [], None )
278279 f .filter (record )
279280 assert record .elasticapm_transaction_id == transaction .id
281+ assert record .elasticapm_service_name == transaction .tracer .config .service_name
280282 assert record .elasticapm_trace_id == transaction .trace_parent .trace_id
281283 assert record .elasticapm_span_id == span .id
282284 assert record .elasticapm_labels
@@ -291,6 +293,7 @@ def test_logging_filter_span(elasticapm_client):
291293 record = logging .LogRecord (__name__ , logging .DEBUG , __file__ , 252 , "dummy_msg2" , [], None )
292294 f .filter (record )
293295 assert record .elasticapm_transaction_id == transaction .id
296+ assert record .elasticapm_service_name == transaction .tracer .config .service_name
294297 assert record .elasticapm_trace_id == transaction .trace_parent .trace_id
295298 assert record .elasticapm_span_id is None
296299 assert record .elasticapm_labels
@@ -303,6 +306,7 @@ def test_structlog_processor_span(elasticapm_client):
303306 event_dict = {}
304307 new_dict = structlog_processor (None , None , event_dict )
305308 assert new_dict ["transaction.id" ] == transaction .id
309+ assert new_dict ["service.name" ] == transaction .tracer .config .service_name
306310 assert new_dict ["trace.id" ] == transaction .trace_parent .trace_id
307311 assert new_dict ["span.id" ] == span .id
308312
@@ -316,6 +320,7 @@ def test_structlog_processor_span(elasticapm_client):
316320 event_dict = {}
317321 new_dict = structlog_processor (None , None , event_dict )
318322 assert new_dict ["transaction.id" ] == transaction .id
323+ assert new_dict ["service.name" ] == transaction .tracer .config .service_name
319324 assert new_dict ["trace.id" ] == transaction .trace_parent .trace_id
320325 assert "span.id" not in new_dict
321326
@@ -331,6 +336,7 @@ def test_automatic_log_record_factory_install(elasticapm_client):
331336 record_factory = logging .getLogRecordFactory ()
332337 record = record_factory (__name__ , logging .DEBUG , __file__ , 252 , "dummy_msg" , [], None )
333338 assert record .elasticapm_transaction_id == transaction .id
339+ assert record .elasticapm_service_name == transaction .tracer .config .service_name
334340 assert record .elasticapm_trace_id == transaction .trace_parent .trace_id
335341 assert record .elasticapm_span_id == span .id
336342 assert record .elasticapm_labels
@@ -342,10 +348,12 @@ def test_formatter():
342348 formatted_record = formatter .format (record )
343349 assert "| elasticapm" in formatted_record
344350 assert hasattr (record , "elasticapm_transaction_id" )
351+ assert hasattr (record , "elasticapm_service_name" )
345352 record = logging .LogRecord (__name__ , logging .DEBUG , __file__ , 252 , "dummy_msg" , [], None )
346353 formatted_time = formatter .formatTime (record )
347354 assert formatted_time
348355 assert hasattr (record , "elasticapm_transaction_id" )
356+ assert hasattr (record , "elasticapm_service_name" )
349357
350358
351359def test_logging_handler_no_client (recwarn ):
0 commit comments