Files
litellm/tests/logging_callback_tests
Cesar Garcia d693596e87 feat(langfuse): Add support for custom masking function (#17826)
* feat(langfuse): Add support for custom masking function

Allow users to pass a custom masking function via metadata to selectively
redact sensitive data (credit cards, emails, PII) before sending to Langfuse.

Usage:
```python
def mask_pii(data):
    if isinstance(data, str):
        data = re.sub(r'\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b', '[CARD]', data)
    return data

litellm.completion(
    model="gpt-4",
    messages=[...],
    metadata={"langfuse_masking_function": mask_pii}
)
```

* fix(langfuse): Isolate masking function from other logging integrations

Extract langfuse_masking_function from metadata early in the flow and store
it in a dedicated key (_langfuse_masking_function) that only the Langfuse
logger knows to look for. This prevents the callable from leaking to other
logging integrations (Datadog, S3, etc.) which would serialize it as
"<function at 0x...>".

Changes:
- scrub_sensitive_keys_in_metadata() now extracts and stores the function
- Langfuse logger looks in the dedicated key first, falls back to metadata
- Added tests to verify isolation works correctly
2025-12-11 15:36:54 -08:00
..
2025-11-22 10:21:52 -08:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-10-04 10:39:17 -07:00
2025-10-25 10:19:24 -07:00