Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion elasticapm/traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,8 @@ def label(**labels):
"""
transaction = execution_context.get_transaction()
if not transaction:
if elasticapm.get_client().config.enabled:
client = elasticapm.get_client()
if not client or client.config.enabled:
error_logger.warning("Ignored labels %s. No transaction currently active.", ", ".join(labels.keys()))
else:
transaction.label(**labels)
Expand Down
4 changes: 4 additions & 0 deletions tests/client/client_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,3 +536,7 @@ def test_check_server_version(elasticapm_client):
)
def test_user_agent(elasticapm_client, expected):
assert elasticapm_client.get_user_agent() == "apm-agent-python/unknown (myapp{})".format(expected)


def test_label_without_client():
elasticapm.label(foo="foo")