-
-
Notifications
You must be signed in to change notification settings - Fork 64
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(serverless): Axiom logger #216
Conversation
Instead of manually checking environment variables we can instantiate the Axiom client and it will inherit configuration from the environment.
This fixes a bug where only the very first event would've been sent to Axiom. The receiver is now transformed into an async stream and passed to `ingest_stream`, which will automatically send events every second or in batches of 1000 (whichever happens first). It also renames the `timestamp` field to `_time` so Axiom recognizes it. And it upgrades axiom-rs to 0.6 because that release added the flush every second functionality.
316b9f2
to
eb5da2f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix and improvements, smart use of ingest_stream
! Love Axiom, really great product.
There's more things that can be improved (e.g. ingest_stream should log errors and restart instead of panicking on error) but this is meant to be a first step.
Definitely agree on this point, I'll log an issue for this.
Could you also add a changeset describing your changes by running pnpm changeset
(and selecting the serverless package) at the root of the project?
Using `log::warn` does nothing if the logger is not setup.
@QuiiBz Thanks for the kind words — I've added the changeset 💯 We should also probably drop the |
Agree, could you add an |
I don't think it's that would fix it, the My proposal would be to have a kind of guard that drops the Does that make sense? |
Yeah, you're right, I've misunderstood your point. I think we could also use |
This is a std::sync::RwLock which you generally shouldn't use in an asyncc environment but we can't await in the `log::Log` trait sooo I hope this is fine? The RwLock should never block while the application is running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good! I only have a small suggestion:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks a lot
Hey everyone, this project looks exciting! I've noticed you're using Axiom so I fixed the logger for you, hope that's alright 😊
About
This PR fixes a bug where only the first log event would've been sent to Axiom.
Instead of grabbing the first value from the receiver, it turns the receiver into an async stream and passes it to
ingest_stream
for ingestion.There's more things that can be improved (e.g.
ingest_stream
should log errors and restart instead of panicking on error) but this is meant to be a first step.It also changes the way Axiom is detected to using the client constructor which will automatically configure from environment variables.
And it renames the
timestamp
field name to_time
so it's properly detected by Axiom.Please let me know if you have any questions regarding Axiom, adding support for the
log
crate is already on our list 😁