-
Notifications
You must be signed in to change notification settings - Fork 361
lambda-extension: remove logging #384
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
Conversation
When running on AWS lambda I encountered the following error: ``` thread 'main' panicked at 'Could not determine the UTC offset on this system. Possible causes are that the time crate does not implement "local_offset_at" on your system, or that you are running in a multi-threaded environment and the time crate is returning "None" from "local_offset_at" to avoid unsafe behaviour. See the time crate's documentation for more information. (https://time-rs.github.io/internal-api/time/index.html#feature-flags): IndeterminateOffset', /home/simon/.cargo/registry/src/gb.xjqchip.workers.dev-1ecc6299db9ec823/simple_logger-1.16.0/src/lib.rs:409:85 ``` This means that the simple logger setup could not find the current time. Instead, we can print to stdout which is also collected by CloudWatch. We can leave more sophisticated control of the output to the user.
Happy to discuss further how to handle this issue properly if required. Perhaps it's user error on my part. |
I'm a little confused what the issue is here. Can you give a little more detail on your setup? Are you running theses examples directly, or basing your code off of them? |
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.
That code serves as examples, you don't really need it to run extensions. Wouldn't it be better to fix the underlying problem than leaving it for everyone to figure out how to setup logging?
I believe the examples should work again if you add this to the dev-dependencies:
time = { version = "0.3.5", features = ["local-offset"] }
See https://time-rs.github.io/internal-api/time/sys/local_offset_at/index.html
Ah this makes more sense now. Nice catch @calavera |
I mentioned this to @nmoutschen over Twitter DMs, but I think the right solution here is to not use local time in when logging and instead default to UTC and rely on the log ingestion system (CloudWatch or otherwise) to determine the local ingestion time and convert it to a some localized time instead. If a change is to be made, I'd probably get rid of (An important disclosure: I help maintain some tracing libraries, including |
yeah, that's a good point. The only reason why these examples use simple logger is because the other examples also use it, and I wanted to keep them similar. I normally use |
Sorry for the brief description of the issue, I realise that wasn't enough information at the time of posting. Thank you all for understanding my issue and resolving it. I've tried using use tracing_subscriber::util::SubscriberInitExt;
#[tokio::main]
async fn main() -> Result<(), Error> {
tracing_subscriber::fmt().json().finish().init();
// ...
} I agree with logging in UTC - I believe this should be the default. I'm happy to update this PR to use |
If you are willing to do it in this PR we're more than happy to review it! Otherwise I agree with @davidbarsky, and think we should at the very least open an issue for this separately and start working on it. |
hey @mindriot101, thanks a lot for bringing this up. We've decided to replace all the logging examples with tracing, so this change is not necessary anymore, see #389. I'm going to close this PR 🙌 |
That's great, I'm glad this discussion happened at least 👍 |
Issue #, if available:
Description of changes:
When running on AWS lambda I encountered the following error:
This means that the simple logger setup could not find the current time.
Instead, we can print to stdout which is also collected by CloudWatch.
We can leave more sophisticated control of the output to the user.
By submitting this pull request