Skip to content

[Observability] Fix operator precedence in event logger to prevent token metric redaction - #83

Merged
Kaap10 merged 1 commit into
PicadoLabs:mainfrom
LetMeSleep8h:fix/event-logger-precedence
Oct 25, 2026
Merged

Kaap10 merged 1 commit into
PicadoLabs:mainfrom
LetMeSleep8h:fix/event-logger-precedence

Conversation

@LetMeSleep8h

Copy link
Copy Markdown
Contributor

Fixes #71.

"key" in k.lower() or "secret" in k.lower() or "token" in k.lower() and "count" not in k.lower() — and bound only the last clause, so any token key without count was masked and input_tokens/output_tokens/total_tokens disappeared from telemetry.

The looks-secret test is now a single parenthesised group:

  • key, secret → redacted as before;
  • token → redacted unless the key ends in plural tokens (the usage metrics) or carries count — so auth_token and access_token (singular) stay redacted, input_tokens/token_count survive.

New test test_log_router_event_keeps_token_counts_and_redacts_secrets pins both sides: four token-count keys pass through, three credential-shaped keys are [REDACTED]. pytest backend/tests/test_observability.py: 5 passed.

'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 Kaap10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Kaap10
Kaap10 merged commit 55256bd into PicadoLabs:main Oct 25, 2026
4 checks passed
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.

[Observability] Fix Operator Precedence in Event Logger to Prevent Token Metric Redaction

2 participants