Skip to content

flushing properly on AWS lambda #113

@davidhewitt

Description

@davidhewitt

Continuing a conversation from the Pydantic Logfire slack: https://pydanticlogfire.slack.com/archives/C06EDRBSAH3/p1758163028178829

It turns out that a naive configuration of logfire in tandem with lambda_runtime doesn't work well on AWS Lambda. The problem (as I understand it) is that between lambda executions the background thread in which logfire performs exports is frozen and may never complete.

To make this work, I see a couple of options:

  • We could make logfire export synchronously on every span. This would probably guarantee best behaviour at the cost of performance. One option to mitigate overheads might be to export to a local lambda Extension, which I think can then batch & run the export in the background.
  • We could potentially introduce a logfire::flush() global API. This would avoid overheads, but any telemetry exported after the flush call would still be unreliably sent.

Maybe there's more advanced solutions which can combine the best of both.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions