Skip to content

Conversation

@demula
Copy link
Contributor

@demula demula commented Jul 18, 2023

Add extra environment variables to further configure the logrus logger in the extension.

This is very useful when the target app has to deal with different logger setups such as zerolog, zap, go-logr and others. This happens when integrating different lambda extensions and other libraries such as OpenTelemetry and the target application has zap or zerolog.

There are not significant code changes and not setting a variable will result in using the defaults previously used in the extension (logrus defaults) ensure compatibility with exiting users.

This feature enables the following setups:

  • Use json as a formatter
  • Skip sending timestamps as part of the log entry
  • Specify the format of the timestamps
  • Change default field names of logrus allowing log entries to use "ts" instead of "time" for example.

To use it, just setup the corresponding environment variables in the AWS lambda configuration and you can have logs like this ones:

{"level":"debug","msg":"Serving on 0.0.0.0:4040","svc":"pyroscope-lambda-ext-main","ts":"2023-07-18T12:47:58.318877953Z"}
{"comp":"orchestrator","level":"debug","msg":"Starting Server","svc":"pyroscope-lambda-ext-main","ts":"2023-07-18T12:47:58.31884208Z"}
{"comp":"orchestrator","level":"debug","msg":"Starting Server","svc":"pyroscope-lambda-ext-main","ts":"2023-07-18T12:47:58.31884208Z"}
{"comp":"orchestrator","level":"debug","msg":"Starting self profiler","svc":"pyroscope-lambda-ext-main","ts":"2023-07-18T12:47:58.318807397Z"}

@CLAassistant
Copy link

CLAassistant commented Jul 18, 2023

CLA assistant check
All committers have signed the CLA.

@petethepig petethepig self-requested a review August 11, 2023 17:45
@petethepig petethepig merged commit 2389785 into grafana:main Aug 11, 2023
@petethepig
Copy link
Collaborator

Thank you for the contribution @demula! I released a new version with this change: https://github.com/grafana/pyroscope-lambda-extension/releases/tag/v1.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants