From bab94b90d74c105371c572cc0cfcd9fb6b5b53ec Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Thu, 21 Jan 2021 09:00:20 -0700 Subject: [PATCH] Update for service.name (in elastic-apm 5.10.1) --- ecs_logging/_stdlib.py | 1 + tests/test_apm.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/ecs_logging/_stdlib.py b/ecs_logging/_stdlib.py index 1353602..b38ab90 100644 --- a/ecs_logging/_stdlib.py +++ b/ecs_logging/_stdlib.py @@ -165,6 +165,7 @@ def format_to_ecs(self, record): extras["span.id"] = extras.pop("elasticapm_span_id", None) extras["transaction.id"] = extras.pop("elasticapm_transaction_id", None) extras["trace.id"] = extras.pop("elasticapm_trace_id", None) + extras["service.name"] = extras.pop("elasticapm_service_name", None) # Merge in any keys that were set within 'extra={...}' for field, value in extras.items(): diff --git a/tests/test_apm.py b/tests/test_apm.py index 81d3e21..0490b0f 100644 --- a/tests/test_apm.py +++ b/tests/test_apm.py @@ -39,6 +39,7 @@ def test_elasticapm_structlog_log_correlation_ecs_fields(spec_validator): "span": {"id": span_id}, "trace": {"id": trace_id}, "transaction": {"id": transaction_id}, + "service": {"name": "apm-service"}, } @@ -85,6 +86,7 @@ def test_elastic_apm_stdlib_no_filter_log_correlation_ecs_fields(): "span": {"id": span_id}, "trace": {"id": trace_id}, "transaction": {"id": transaction_id}, + "service": {"name": "apm-service"}, } @@ -129,6 +131,7 @@ def test_elastic_apm_stdlib_with_filter_log_correlation_ecs_fields(): "span": {"id": span_id}, "trace": {"id": trace_id}, "transaction": {"id": transaction_id}, + "service": {"name": "apm-service"}, } @@ -174,4 +177,5 @@ def test_elastic_apm_stdlib_exclude_fields(): }, "message": "test message", "trace": {"id": trace_id}, + "service": {"name": "apm-service"}, }