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

Could logfire use decoupled processor on AWS lambda? #883

Open
bensi94 opened this issue Feb 21, 2025 · 2 comments
Open

Could logfire use decoupled processor on AWS lambda? #883

bensi94 opened this issue Feb 21, 2025 · 2 comments
Labels
Question Further information is requested

Comments

@bensi94
Copy link

bensi94 commented Feb 21, 2025

Question

Hi,

I love logfire, thank you for your fantastic work.

I have recently been using it with AWS lambda and it works great with the logfire.instrument_aws_lambda.

However, one downside I’ve noticed is that traces and metrics are flushed during function execution, adding a noticeable performance overhead (as shown in this AWS X-Ray screenshot).

Image

I’ve been wondering if it could be integrated with something like the OpenTelemetry Lambda Collector using a decouple processor to offload the processing and reduce the overhead. In that case, logfire could push logs to this as an alternative backend.

I haven’t fully tested this yet, and I’m not entirely sure how to set it up. Do you think this could work in theory? If so, how would the exporter authenticate with logfire, given that it doesn’t natively handle the logfire token?

Alternatively, instead of relying on the OpenTelemetry Lambda Collector, could logfire implement a similar approach internally with this kind of decoupling as the collector does it instead?

Would love to hear your thoughts!

Thanks!

@bensi94 bensi94 added the Question Further information is requested label Feb 21, 2025
@alexmojaki
Copy link
Contributor

Hi @bensi94, thanks for sharing, this looks very interesting. It looks like you currently know more about this area than we do. So I think it would be best for you to try it out. Yes, I do think it could work. The relevant collector config looks something like this:

    exporters:
      otlphttp:
        endpoint: "https://logfire-api.pydantic.dev"
        headers:
          Authorization: "Bearer ${env:LOGFIRE_TOKEN}"

(based on https://logfire.pydantic.dev/docs/how-to-guides/otel-collector/#collecting-system-logs)

Alternatively, instead of relying on the OpenTelemetry Lambda Collector, could logfire implement a similar approach internally with this kind of decoupling as the collector does it instead?

In https://github.com/open-telemetry/opentelemetry-lambda/blob/main/collector/processor/decoupleprocessor/README.md it says:

The processor is aware of the Lambda lifecycle and will prevent the environment from being frozen or shutdown until any pending traces/metrics/logs have been exported.

I don't know how that works, but it sounds like it relies on using a Lambda extension. So I don't think the SDK could do this on its own, but maybe there could be a logfire extension? I really don't know.

@bensi94
Copy link
Author

bensi94 commented Feb 24, 2025

Thanks @alexmojaki! I will check this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants