Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue in span serialization when using APM Server < 7.16 #1510

Merged
merged 3 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion elasticapm/traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def to_dict(self) -> dict:
result["otel"]["attributes"] = self.context.pop("otel_attributes")
else:
# Attributes map to labels for older versions
attributes = self.context.pop("otel_attributes")
attributes = self.context.pop("otel_attributes", {})
if attributes and ("tags" not in self.context):
self.context["tags"] = {}
for key, value in attributes.items():
Expand Down
17 changes: 17 additions & 0 deletions tests/client/transaction_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@
from elasticapm.utils.disttracing import TraceParent


@pytest.mark.parametrize("elasticapm_client", [{"server_version": (7, 15)}, {"server_version": (7, 16)}], indirect=True)
def test_transaction_span(elasticapm_client):
elasticapm_client.begin_transaction("test")
with elasticapm.capture_span("test", extra={"a": "b"}):
pass
elasticapm_client.end_transaction("test", constants.OUTCOME.SUCCESS)
transactions = elasticapm_client.events[constants.TRANSACTION]
assert len(transactions) == 1
assert transactions[0]["name"] == "test"
assert transactions[0]["type"] == "test"
assert transactions[0]["result"] == constants.OUTCOME.SUCCESS

spans = elasticapm_client.events[constants.SPAN]
assert len(spans) == 1
assert spans[0]["name"] == "test"


@pytest.mark.parametrize(
"elasticapm_client", [{"transactions_ignore_patterns": ["^OPTIONS", "views.api.v2"]}], indirect=True
)
Expand Down