Add BaggageLogProcessor to opentelemetry-processor-baggage#4371
Add BaggageLogProcessor to opentelemetry-processor-baggage#4371Manvi2402 wants to merge 7 commits intoopen-telemetry:mainfrom
Conversation
processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/log_processor.py
Show resolved
Hide resolved
processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/log_processor.py
Outdated
Show resolved
Hide resolved
processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/log_processor.py
Outdated
Show resolved
Hide resolved
|
Thanks @Manvi2402 for submitting. I think this is a nice analog feature and iiuc shouldn't interfere with the Logging API stabilization efforts. I've left some comments. Please could you also:
|
176f8d3 to
3449a3d
Compare
|
Thanks for the review @tammy-baylis-swi . I've addressed all the comments in the latest commit 3449a3d Added collision handling to avoid overwriting existing log record attributes. |
| def __init__( | ||
| self, | ||
| baggage_key_predicate: BaggageKeyPredicatesT, | ||
| max_baggage_attributes: Optional[int] = None, |
There was a problem hiding this comment.
The spec outlines 128 as a max for attributes though not specific to baggage. Maybe we could use this as a default?
processor/opentelemetry-processor-baggage/tests/test_baggage_log_processor.py
Show resolved
Hide resolved
…s=128, multiple predicates test and README example
|
Thanks for the follow-up @tammy-baylis-swi I've addressed all the comments in the latest commit: Added docstring to on_emit documenting collision handling behavior |
|
Hi @Manvi2402 please add a bit more test coverage for configurable
|
|
Hi @tammy-baylis-swi , I've added the test for max_baggage_attributes. I tried running tox -e precommit and tox -e lint-processor-baggage locally but they fail on Windows because sh command is not available. |
Thanks @Manvi2402 ! I'm not a Windows user myself but I think those tox commands should work if you use git bash or WSL. Could you give one of those a try? |
|
Hi @tammy-baylis-swi , I ran tox -e precommit and it passed after ruff auto-fixed some formatting. I also fixed the pylint issues in log_processor.py (naming convention and staticmethod). The only remaining pylint warning is ALLOW_ALL_BAGGAGE_KEYS in the existing processor.py which was there before my changes. |
MikeGoldsmith
left a comment
There was a problem hiding this comment.
Looks good for me. Thank you @Manvi2402.
|
|
||
| def __init__( | ||
| self, | ||
| baggage_key_predicate: BaggageKeyPredicate, |
There was a problem hiding this comment.
I like that you've used a Union here. The BaggageSpanProcessor just takes a single predicate, would you mind updating it to match this so they are kept consistent? Updating to use the union should be fully backward compatible so long as we use the if callable check like you have below.
There was a problem hiding this comment.
Hi @MikeGoldsmith , I've updated BaggageSpanProcessor to support multiple predicates using the same Union type, with the if callable check for backward compatibility.
Description
Adds
BaggageLogProcessorwhich reads entries stored in Baggage from the current context and adds the baggage entries' keys and values to the log record as attributes on emit.This is analogous to the existing
BaggageSpanProcessorbut for logs.Fixes #4062
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Added unit tests in
test_baggage_log_processor.py:test_check_the_baggage- verifies BaggageLogProcessor is instance of LogRecordProcessortest_baggage_added_to_log_record- verifies baggage is added to log attributestest_baggage_with_prefix- verifies predicate filtering with string prefixtest_baggage_with_regex- verifies predicate filtering with regextest_no_baggage_not_added- verifies no baggage keys added when baggage is emptyDoes This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.