Add support for adding callables as extra fields#95
Open
piotrmaslanka wants to merge 1 commit intoeht16:masterfrom
Open
Add support for adding callables as extra fields#95piotrmaslanka wants to merge 1 commit intoeht16:masterfrom
piotrmaslanka wants to merge 1 commit intoeht16:masterfrom
Conversation
eht16
reviewed
Mar 24, 2024
| extra_fields.update(self._extra) | ||
| for field_name, field_value in self._extra.items(): | ||
| if callable(field_value): | ||
| field_value = field_value() |
Owner
There was a problem hiding this comment.
I wonder if we should catch errors from the callable (and if so, move it into a seperate method).
If the callable throws an error, this way the whole log event will be lost.
If the error is handled, the log event can be sent anyways and we could log the error for later analysis.
What do you think?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Support was added for specifying callables as extra fields. This is super useful if we're trying to attach span_id and trace_id to a log entry in order to cross-match it with a tracing system, such as Jaeger, and we need that data dynamically rather than statically at startup.
Example: