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();
});
FieldTypeDefaultWhat it hides
hide_inputsboolFalseAll input values and messages
hide_outputsboolFalseAll output values and messages
hide_input_messagesboolFalseInput messages only
hide_output_messagesboolFalseOutput messages only
hide_input_imagesboolFalseImages in inputs
hide_input_textboolFalseText in input messages
hide_output_textboolFalseText in output messages
hide_embedding_vectorsboolFalseEmbedding vectors
hide_llm_invocation_parametersboolFalseModel parameters (temperature, etc.)
base64_image_max_lengthint32000Truncate base64 images beyond this length
pii_redactionboolFalseAutomatically 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 TypePatternReplaced with
Email addressesuser@example.com<EMAIL_ADDRESS>
Social Security Numbers123-45-6789<SSN>
Credit card numbers4111-1111-1111-1111<CREDIT_CARD>
API keyssk_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