or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

attribute-generation.mdconfiguration.mdcontext-management.mdindex.mdtracer-spans.mdtype-definitions.mdutilities.md

configuration.mddocs/

0

# Configuration & Control

1

2

Configuration utilities for controlling tracing behavior, data privacy settings, and instrumentation suppression in OpenInference instrumentation.

3

4

## Capabilities

5

6

### Trace Configuration

7

8

Central configuration class for controlling tracing configurations including data privacy settings and payload size limits.

9

10

```python { .api }

11

@dataclass(frozen=True)

12

class TraceConfig:

13

"""

14

Configuration for controlling tracing behavior and data privacy.

15

16

Args:

17

hide_llm_invocation_parameters (Optional[bool]): Hide LLM invocation parameters

18

hide_inputs (Optional[bool]): Hide input values and messages

19

hide_outputs (Optional[bool]): Hide output values and messages

20

hide_input_messages (Optional[bool]): Hide all input messages

21

hide_output_messages (Optional[bool]): Hide all output messages

22

hide_input_images (Optional[bool]): Hide images from input messages

23

hide_input_text (Optional[bool]): Hide text from input messages

24

hide_output_text (Optional[bool]): Hide text from output messages

25

hide_embedding_vectors (Optional[bool]): Hide embedding vectors

26

hide_prompts (Optional[bool]): Hide LLM prompts

27

base64_image_max_length (Optional[int]): Limit characters in base64 image encodings

28

"""

29

hide_llm_invocation_parameters: Optional[bool] = None

30

hide_inputs: Optional[bool] = None

31

hide_outputs: Optional[bool] = None

32

hide_input_messages: Optional[bool] = None

33

hide_output_messages: Optional[bool] = None

34

hide_input_images: Optional[bool] = None

35

hide_input_text: Optional[bool] = None

36

hide_output_text: Optional[bool] = None

37

hide_embedding_vectors: Optional[bool] = None

38

hide_prompts: Optional[bool] = None

39

base64_image_max_length: Optional[int] = None

40

41

def mask(

42

self,

43

key: str,

44

value: Union[AttributeValue, Callable[[], AttributeValue]]

45

) -> Optional[AttributeValue]:

46

"""

47

Apply masking to attribute values based on configuration.

48

49

Args:

50

key (str): The attribute key

51

value (Union[AttributeValue, Callable[[], AttributeValue]]): The attribute value or value factory

52

53

Returns:

54

Optional[AttributeValue]: Masked value, None to exclude, or original value

55

"""

56

```

57

58

**Usage Example:**

59

60

```python

61

from openinference.instrumentation import TraceConfig, TracerProvider

62

63

# Create configuration with privacy settings

64

config = TraceConfig(

65

hide_llm_invocation_parameters=True,

66

hide_inputs=True,

67

hide_embedding_vectors=True,

68

base64_image_max_length=1000

69

)

70

71

# Use with TracerProvider

72

tracer_provider = TracerProvider(config=config)

73

tracer = tracer_provider.get_tracer(__name__)

74

75

# Configuration can also read from environment variables

76

# OPENINFERENCE_HIDE_INPUTS=true

77

# OPENINFERENCE_HIDE_LLM_INVOCATION_PARAMETERS=true

78

config_from_env = TraceConfig() # Will use env vars

79

```

80

81

### Environment Variable Configuration

82

83

TraceConfig automatically reads from environment variables when values are not explicitly provided:

84

85

- `OPENINFERENCE_HIDE_LLM_INVOCATION_PARAMETERS`

86

- `OPENINFERENCE_HIDE_INPUTS`

87

- `OPENINFERENCE_HIDE_OUTPUTS`

88

- `OPENINFERENCE_HIDE_INPUT_MESSAGES`

89

- `OPENINFERENCE_HIDE_OUTPUT_MESSAGES`

90

- `OPENINFERENCE_HIDE_INPUT_IMAGES`

91

- `OPENINFERENCE_HIDE_INPUT_TEXT`

92

- `OPENINFERENCE_HIDE_OUTPUT_TEXT`

93

- `OPENINFERENCE_HIDE_EMBEDDING_VECTORS`

94

- `OPENINFERENCE_HIDE_PROMPTS`

95

- `OPENINFERENCE_BASE64_IMAGE_MAX_LENGTH`

96

97

**Usage Example:**

98

99

```bash

100

# Set environment variables

101

export OPENINFERENCE_HIDE_INPUTS=true

102

export OPENINFERENCE_BASE64_IMAGE_MAX_LENGTH=2000

103

```

104

105

```python

106

# TraceConfig will automatically use these environment variables

107

config = TraceConfig()

108

print(config.hide_inputs) # True (from environment)

109

print(config.base64_image_max_length) # 2000 (from environment)

110

```

111

112

### Tracing Suppression

113

114

Context manager to pause OpenTelemetry instrumentation within a specific scope.

115

116

```python { .api }

117

class suppress_tracing:

118

"""

119

Context manager to pause OpenTelemetry instrumentation.

120

No spans will be created within this context.

121

"""

122

def __enter__(self) -> "suppress_tracing": ...

123

def __exit__(

124

self,

125

exc_type: Optional[Type[BaseException]],

126

exc_value: Optional[BaseException],

127

traceback: Optional[TracebackType]

128

) -> None: ...

129

def __aenter__(self) -> "suppress_tracing": ...

130

def __aexit__(

131

self,

132

exc_type: Optional[Type[BaseException]],

133

exc_value: Optional[BaseException],

134

traceback: Optional[TracebackType]

135

) -> None: ...

136

```

137

138

**Usage Example:**

139

140

```python

141

from openinference.instrumentation import suppress_tracing

142

143

# Synchronous usage

144

with suppress_tracing():

145

# No tracing will occur within this block

146

sensitive_database_operation()

147

internal_cache_update()

148

149

# Asynchronous usage

150

async with suppress_tracing():

151

# No tracing for async operations either

152

await sensitive_async_operation()

153

154

# Can be used as decorator

155

@suppress_tracing()

156

def internal_helper_function():

157

# This function won't be traced

158

pass

159

```

160

161

### Redacted Value Constant

162

163

Constant value used when data is redacted due to privacy settings.

164

165

```python { .api }

166

REDACTED_VALUE: str = "__REDACTED__"

167

```

168

169

**Usage Example:**

170

171

```python

172

from openinference.instrumentation import REDACTED_VALUE, TraceConfig

173

174

config = TraceConfig(hide_inputs=True)

175

176

# When inputs are hidden, they will show as REDACTED_VALUE

177

# span.attributes["input.value"] = "__REDACTED__"

178

```

179

180

## Data Privacy Features

181

182

The TraceConfig system provides comprehensive data privacy controls:

183

184

### Input/Output Privacy

185

- **hide_inputs**: Hides all input values and MIME types

186

- **hide_outputs**: Hides all output values and MIME types

187

- **hide_input_messages**: Hides all LLM input messages

188

- **hide_output_messages**: Hides all LLM output messages

189

190

### Content-Specific Privacy

191

- **hide_input_text**: Hides text content from input messages only

192

- **hide_output_text**: Hides text content from output messages only

193

- **hide_input_images**: Hides image content from input messages

194

- **hide_embedding_vectors**: Hides vector data from embeddings

195

196

### System Privacy

197

- **hide_llm_invocation_parameters**: Hides LLM configuration parameters

198

- **hide_prompts**: Hides LLM prompt content

199

- **base64_image_max_length**: Limits size of base64-encoded images

200

201

### Masking Behavior

202

203

When privacy settings are enabled:

204

205

1. **Exclusion**: Some attributes are completely excluded (return None)

206

2. **Redaction**: Some attributes are replaced with `REDACTED_VALUE`

207

3. **Truncation**: Long base64 images are truncated to the specified length

208

209

The `mask()` method applies these transformations consistently across all attribute generation functions.