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

Support custom loggers #98

Open
onlyplo opened this issue Sep 23, 2019 · 3 comments
Open

Support custom loggers #98

onlyplo opened this issue Sep 23, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@onlyplo
Copy link

onlyplo commented Sep 23, 2019

This is a Feature Proposal

Description

  • Need a way to log out timeout error messages as using our own repo's/companies logging convention. Currently the middleware lambda-powertools-middleware-log-timeout locks us down to the following error message 'invocation timed out'
  • Need a way to also track the occurrence of timeouts as a metric. Ideally a way to plug in datadog or newrelic clients to track custom metrics

Proposed solution:

  • Add override parameter to enable consumers to use their own logging function when a timeout occurs.
  • example of how it could be implemented: d4f873b
@onlyplo onlyplo added the enhancement New feature or request label Sep 23, 2019
@theburningmonk
Copy link
Contributor

Is the problem the invocation timed out message, if so, there's a simpler solution to let you customize the log message itself.

But sounds like the problem you actually have, and the solution you're looking for, is a way to use your own logger instead of the one from the powertools, right? The solution for this problem would need to work for more than just this middleware. Maybe a possible solution here is to let the powertools logger take in a proxy for console.log that it calls instead of console.log? That way, you can inject your company's logging convention between the powertool logger and stdout.

As for custom metrics, you have a few solutions here:

  • event hooks in the middleware: downside - you gotta consider this in code EVERYWHERE, upside - no additional infra)
  • CloudWatch metric filter: downside - you gotta configure the metric filter for EVERY lambda log group (you can automate this though), upside - no code change
  • post-process the log messages and turn them into custom metrics <like this guy>: downside - extra infra complexity, upside - deploy once per region and can be automated with a regional template stack (or maybe something you can do through AWS Control Tower?)

@onlyplo
Copy link
Author

onlyplo commented Sep 23, 2019

Actually the core problem is the inability to do a simple metrics.increment('failed.timeout', 1); with the datadog logging package whenever there is a timeout. Not looking to overcomplicate the solution with metric filters and log trawling.

Yes the message invocation timed out also doesn't match our repo's log naming convention hence I expanded the issue and the sample to allow the consumers to do add a custom function to do what we wish when a timeout occurs. (we can live the log message for now).

I agree powertools in general should allow consumers to inject their own logger as the current conventions are quite prescriptive, but perhaps we should splinter that off into a separate issue.

@theburningmonk
Copy link
Contributor

theburningmonk commented Sep 26, 2019

Ok, let's keep this ticket for the custom logger thread since that's where we started off on. I'm gonna start a new issue for metrics.

For that, the simplest thing I can think of is to let you pass in a callback function, but let's carry on the discussed on the other thread.

@theburningmonk theburningmonk changed the title Add custom logger to log-timeout middleware Support custom loggers Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants