TraceConfig
Configure masking and PII redaction with TraceConfig.
Control what data gets captured. Useful for privacy compliance, reducing payload size, or masking sensitive data.
from fi_instrumentation import TraceConfig
config = TraceConfig(
hide_inputs=True,
hide_outputs=True,
pii_redaction=True,
)
# Pass to instrumentors
OpenAIInstrumentor().instrument(
tracer_provider=trace_provider,
config=config,
) TraceAI.init(TraceConfig.builder()
.baseUrl("https://api.futureagi.com")
.apiKey("your-key")
.projectName("my-project")
.hideInputs(true)
.hideOutputs(true)
.hideInputMessages(true)
.hideOutputMessages(true)
.build()
); In TypeScript, TraceConfig is passed per-instrumentor, not to register():
import { OpenAIInstrumentation } from "@traceai/openai";
import { registerInstrumentations } from "@opentelemetry/instrumentation";
registerInstrumentations({
tracerProvider,
instrumentations: [
new OpenAIInstrumentation({
traceConfig: {
hideInputs: true,
hideOutputs: true,
hideInputImages: true,
hideEmbeddingVectors: true,
base64ImageMaxLength: 16000,
piiRedaction: true,
},
}),
],
}); var tracer = TraceAI.Register(opts =>
{
opts.ProjectName = "my-project";
opts.TraceConfig = TraceConfig.Builder()
.HideInputs(true)
.HideOutputs(true)
.HideInputImages(true)
.HideEmbeddingVectors(true)
.Base64ImageMaxLength(16000)
.Build();
}); | Field | Type | Default | What it hides |
|---|---|---|---|
hide_inputs | bool | False | All input values and messages |
hide_outputs | bool | False | All output values and messages |
hide_input_messages | bool | False | Input messages only |
hide_output_messages | bool | False | Output messages only |
hide_input_images | bool | False | Images in inputs |
hide_input_text | bool | False | Text in input messages |
hide_output_text | bool | False | Text in output messages |
hide_embedding_vectors | bool | False | Embedding vectors |
hide_llm_invocation_parameters | bool | False | Model parameters (temperature, etc.) |
base64_image_max_length | int | 32000 | Truncate base64 images beyond this length |
pii_redaction | bool | False | Automatically mask PII (Python only) |
Each field maps to an environment variable with the FI_ prefix (e.g. hide_inputs -> FI_HIDE_INPUTS).
PII Redaction (Python)
When pii_redaction=True, the SDK automatically detects and masks 6 types of personally identifiable information:
| PII Type | Pattern | Replaced with |
|---|---|---|
| Email addresses | user@example.com | <EMAIL_ADDRESS> |
| Social Security Numbers | 123-45-6789 | <SSN> |
| Credit card numbers | 4111-1111-1111-1111 | <CREDIT_CARD> |
| API keys | sk_live_..., pk_test_... | <API_KEY> |
| IP addresses (IPv4) | 192.168.1.1 | <IP_ADDRESS> |
| Phone numbers | +1-555-123-4567 | <PHONE_NUMBER> |
# Enable via code
config = TraceConfig(pii_redaction=True)
# Or via environment variable
# export FI_PII_REDACTION=true
# Direct usage
from fi_instrumentation.instrumentation.pii_redaction import redact_pii_in_string
redacted = redact_pii_in_string("Email me at test@example.com")
# "Email me at <EMAIL_ADDRESS>" Was this page helpful?
Questions & Discussion