Skip to content

elasticapm.label fails when trying to warn that no transaction is present #1595

Closed
@dennis-wey

Description

@dennis-wey

Describe the bug:
https://github.com/elastic/apm-agent-python/blob/main/elasticapm/traces.py#L1092

When neither Transaction nor client is present, elasticapm.label( . . .) will fail while trying do print a warning.
This can happen for example when testing routes with fastapi.

Open Question would be whether the warning should be printed if no client is present.
I think it makes sense to do this since this is also the default from the config.

To Reproduce

import elasticapm

elasticapm.label(foo="foo")

Environment (please complete the following information)

  • OS: Tested on Linux and Mac but should appear everywhere else
  • Python version: Tested on 3.9/3.10
  • Agent version: 6.10.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions