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 TraceConfig in 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 VariableDescriptionTypeDefault
FI_HIDE_INPUTSHides input values, all input messages, and embedding input textboolFalse
FI_HIDE_OUTPUTSHides output values and all output messagesboolFalse
FI_HIDE_INPUT_MESSAGESHides all input messages and embedding input textboolFalse
FI_HIDE_OUTPUT_MESSAGESHides all output messagesboolFalse
FI_HIDE_INPUT_IMAGESHides images from input messagesboolFalse
FI_HIDE_INPUT_TEXTHides text from input messages and input embeddingsboolFalse
FI_HIDE_OUTPUT_TEXTHides text from output messagesboolFalse
FI_HIDE_EMBEDDING_VECTORSHides returned embedding vectorsboolFalse
FI_BASE64_IMAGE_MAX_LENGTHCaps the character count of a base64 encoded imageint32,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 orderTraceConfig in 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

Was this page helpful?

Questions & Discussion