Skip to main content

Privacy Controls

OpenInference provides comprehensive privacy controls to help you maintain security and compliance while still benefiting from observability. You can mask PII, filter sensitive data, and selectively suppress tracing.

Overview

Privacy controls in OpenInference allow you to:
  • Mask sensitive data - Replace PII with "__REDACTED__" placeholder
  • Filter specific content - Hide images, text, or embeddings selectively
  • Suppress tracing - Completely disable tracing for specific code blocks
  • Control payload size - Limit large data like base64-encoded images

Redacted Value Placeholder

When content is hidden, OpenInference uses the constant "__REDACTED__" as a placeholder. This allows trace consumers to identify that content was intentionally hidden rather than missing or empty. The redacted value constant is available for import:

PII Masking

Hiding Text Content

Protect user messages and LLM responses while preserving trace structure:
This configuration:
  • Replaces message text with "__REDACTED__"
  • Preserves message structure and metadata
  • Maintains trace flow and timing information

Hiding Complete Messages

Remove entire message objects from traces:

Hiding All Inputs/Outputs

Hide both values and messages completely:
Note: Setting hide_inputs=True automatically hides input messages. Setting hide_input_messages=True hides only messages but not the input value.

Data Filtering

Hiding Images

Remove images from traces while keeping text:
This is useful when:
  • Images may contain sensitive or identifying information
  • You want to reduce storage costs
  • Compliance requires removing visual data

Limiting Image Size

Truncate large base64-encoded images:
Images exceeding this length are replaced with "__REDACTED__".

Hiding Embeddings

Protect embedding vectors and their associated text:

Suppressing Tracing

Context Manager (Python)

Completely disable tracing for specific code blocks:

Async Support (Python)

JavaScript Suppression

Use OpenTelemetry’s built-in suppression:

Common Privacy Scenarios

GDPR Compliance

Minimize personal data collection:

HIPAA Compliance

Protect healthcare information:

Financial Services

Hide transaction details and account numbers:

Development vs. Production

Use environment-specific configurations:

Cost Optimization

Reduce storage costs while maintaining observability:

Advanced Patterns

Selective Message Filtering

Hide text but keep images for debugging:

Embedding Privacy

Hide vectors but keep text for searchability:

LLM-Specific Controls

Hide only invocation parameters:

Completions API Privacy

For legacy completions API:

Best Practices

  1. Start restrictive - Begin with more privacy controls and relax as needed
  2. Test in development - Verify traces contain expected information before deploying
  3. Document your choices - Keep a record of which privacy controls are enabled and why
  4. Use environment variables - Make privacy settings configurable per environment
  5. Review regularly - Audit your privacy settings as requirements change
  6. Combine methods - Use both TraceConfig and suppress_tracing for comprehensive control
  7. Monitor impact - Ensure privacy controls don’t hide critical debugging information

Validation

Verify your privacy controls are working:

Next Steps