Mask Span Attributes
Redact sensitive inputs, outputs, images, and embeddings from spans before they are exported — using environment variables or TraceConfig in code.
What it is
Mask Span Attributes lets you control which data gets recorded in your traces. Using environment variables or a TraceConfig object passed to any auto-instrumentor, you can hide inputs, outputs, messages, images, text, and embedding vectors before they leave your application. This is useful for preventing sensitive data from being logged and for reducing payload size when working with large base64-encoded images.
Use cases
- Privacy and compliance — Hide user inputs and LLM outputs to prevent sensitive data from being stored in trace backends.
- Image redaction — Suppress base64-encoded images from input messages or cap their length to reduce payload size.
- Selective masking — Hide only specific parts of a span (e.g. input text but not output messages) while keeping the rest visible.
- Environment-specific config — Use environment variables for deployment-level defaults and
TraceConfigin code for per-instrumentor overrides.
How to
Review available settings
The following environment variables control what gets masked. Set them before your application starts for a global default, or configure them in code using TraceConfig (see next step).
| Environment Variable | Description | Type | Default |
|---|---|---|---|
FI_HIDE_INPUTS | Hides input values, all input messages, and embedding input text | bool | False |
FI_HIDE_OUTPUTS | Hides output values and all output messages | bool | False |
FI_HIDE_INPUT_MESSAGES | Hides all input messages and embedding input text | bool | False |
FI_HIDE_OUTPUT_MESSAGES | Hides all output messages | bool | False |
FI_HIDE_INPUT_IMAGES | Hides images from input messages | bool | False |
FI_HIDE_INPUT_TEXT | Hides text from input messages and input embeddings | bool | False |
FI_HIDE_OUTPUT_TEXT | Hides text from output messages | bool | False |
FI_HIDE_EMBEDDING_VECTORS | Hides returned embedding vectors | bool | False |
FI_BASE64_IMAGE_MAX_LENGTH | Caps the character count of a base64 encoded image | int | 32,000 |
Configure in code with TraceConfig
Pass a TraceConfig object to any auto-instrumentor to set masking options directly in code. Values set here take precedence over environment variables.
from fi_instrumentation import TraceConfig
config = TraceConfig(
hide_inputs=False,
hide_outputs=False,
hide_input_messages=False,
hide_output_messages=False,
hide_input_images=False,
hide_input_text=False,
hide_output_text=False,
hide_embedding_vectors=False,
base64_image_max_length=32000,
)
from traceai_openai import OpenAIInstrumentor
OpenAIInstrumentor().instrument(
tracer_provider=trace_provider,
config=config,
)import { OpenAIInstrumentor, FITraceConfig } from "@traceai/openai";
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
const config: FITraceConfig = {
hideInputs: false,
hideOutputs: false,
hideInputMessages: false,
hideOutputMessages: false,
hideInputImages: false,
hideInputText: false,
hideOutputText: false,
hideEmbeddingVectors: false,
base64ImageMaxLength: 32000,
};
const instrumentor = new OpenAIInstrumentor();
instrumentor.instrument(
tracerProvider,
config
);
console.log("OpenAIInstrumentor configured with custom TraceConfig."); Key concepts
TraceConfig— An object accepted by all traceAI auto-instrumentors. Use it to specify masking settings directly in code, scoped to a single instrumentor.- Environment variables — Global defaults applied to all instrumentors. Useful for deployment-level configuration without changing code.
- Precedence order —
TraceConfigin code → environment variables → default values. More specific settings always win. hide_inputs/hide_outputs— Broad flags that hide all input/output values and messages in one setting.base64_image_max_length— Caps the logged length of base64-encoded images. Default is 32,000 characters.
What you can do next
Set Up Tracing
Register a tracer provider and add instrumentation.
Add Attributes & Metadata
Attach custom data to spans for filtering and evals.
Instrument with traceAI Helpers
Use FITracer decorators and context managers for typed spans.
Auto Instrumentation
Browse all supported framework instrumentors.