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).
Cap attribute size
TraceConfig’s hide_* fields redact or drop values; only base64_image_max_length actually truncates, and only for base64 images. Everything else, an oversized input, output, or tool payload, is sent at full size and can be rejected outright (see ingestion request limits).
To cap the size of every attribute value before it is exported, set an OpenTelemetry span limit instead. This applies to all instrumentors and all attributes, not just images.
# Truncates every span attribute value to 100,000 characters
export OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=100000 from fi_instrumentation import register, SpanLimits
trace_provider = register(
project_name="my_project",
span_limits=SpanLimits(max_attribute_length=100000),
) span_limits is a register() argument; there is no per-instrumentor equivalent, so set it once at registration.
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>" Questions & Discussion