Repository navigation
[Observability] Fix operator precedence in event logger to prevent token metric redaction - #83
Merged
Conversation
'or token in k.lower() and count not in k.lower()' bound the 'and' clause alone, so every 'token' key without 'count' was masked - hiding input_tokens/output_tokens/total_tokens from telemetry. The looks-secret test is now one parenthesised group with a plural-'tokens'/count whitelist inside, so singular 'auth_token' is still redacted. Fixes PicadoLabs#71
Kaap10
approved these changes
Oct 25, 2026
Kaap10
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed and verified. The boolean expression is cleanly parenthesized to preserve token usage metrics while keeping credentials redacted. Test coverage passes locally and in CI.
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.
Fixes #71.
"key" in k.lower() or "secret" in k.lower() or "token" in k.lower() and "count" not in k.lower()—andbound only the last clause, so anytokenkey withoutcountwas masked andinput_tokens/output_tokens/total_tokensdisappeared from telemetry.The looks-secret test is now a single parenthesised group:
key,secret→ redacted as before;token→ redacted unless the key ends in pluraltokens(the usage metrics) or carriescount— soauth_tokenandaccess_token(singular) stay redacted,input_tokens/token_countsurvive.New test
test_log_router_event_keeps_token_counts_and_redacts_secretspins both sides: four token-count keys pass through, three credential-shaped keys are[REDACTED].pytest backend/tests/test_observability.py: 5 passed.