Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

attrnorm

v1.47.0
go.opentelemetry.io/otel/sdk/log/internal/attrnorm

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

14 matches

Top ↑

Package attrnorm normalizes attribute values.

Functions

KeyValueDedup

func KeyValueDedup(kv attribute.KeyValue) (attribute.KeyValue, bool)

KeyValueDedup returns kv with all map values deduplicated and whether it changed.

KeyValueDedupLimitDepth

func KeyValueDedupLimitDepth(
	kv attribute.KeyValue,
	depthLimit int,
) (attribute.KeyValue, bool, bool)

KeyValueDedupLimitDepth returns kv with all map values deduplicated and all array and map values limited to depthLimit. The boolean results report depth limiting and deduplication changes, respectively.

KeyValueLimitDepth

func KeyValueLimitDepth(kv attribute.KeyValue, depthLimit int) (attribute.KeyValue, bool)

KeyValueLimitDepth returns kv with all array and map values limited to depthLimit. Map keys are not deduplicated.

KeyValuesDedup

func KeyValuesDedup(kvs []attribute.KeyValue) ([]attribute.KeyValue, bool)

KeyValuesDedup returns kvs with all map values deduplicated and whether they changed.

The returned slice is the original kvs slice if no value needs deduplication. Top-level keys in kvs are not deduplicated.

KeyValuesDedupLimitDepth

func KeyValuesDedupLimitDepth(
	kvs []attribute.KeyValue,
	depthLimit int,
) ([]attribute.KeyValue, bool, bool)

KeyValuesDedupLimitDepth returns kvs with all map values deduplicated and all array and map values limited to depthLimit. The boolean results report depth limiting and deduplication changes, respectively.

The returned slice is the original kvs slice if no value needs normalization. Top-level keys in kvs are not deduplicated.

SetDedup

func SetDedup(set attribute.Set) (attribute.Set, bool)

SetDedup returns set with all map values deduplicated and whether it changed.

The returned Set is the original set if no value needs deduplication. Top-level key uniqueness remains attribute.Set's responsibility; this only normalizes map attribute values.

SetDedupLimitDepth

func SetDedupLimitDepth(
	set attribute.Set,
	depthLimit int,
) (attribute.Set, bool, bool)

SetDedupLimitDepth returns set with all map values deduplicated and all array and map values limited to depthLimit. The boolean results report depth limiting and deduplication changes, respectively.

The returned Set is the original set if no value needs normalization. Top-level key uniqueness remains attribute.Set's responsibility; this only normalizes attribute values.

SetLimitDepth

func SetLimitDepth(set attribute.Set, depthLimit int) (attribute.Set, bool)

SetLimitDepth returns set with all array and map values limited to depthLimit. Map keys are not deduplicated.

The returned Set is the original set if no value changes.

Truncate

func Truncate(limit int, attr attribute.KeyValue) attribute.KeyValue

Truncate returns a truncated version of attr. Only string, string slice, byte slice, slice, and map attribute values are truncated. String values are truncated according to limit. Each string slice value is truncated in this fashion (the slice length itself is unaffected), and byte slice values are truncated to at most limit bytes. For slice and map attribute values, the limit is applied recursively to contained values.

No truncation is performed for a negative limit.

TruncateValue

func TruncateValue(limit int, v attribute.Value) attribute.Value

TruncateValue returns a truncated version of v. Only string, string slice, byte slice, and (recursively) slice and map values are modified.

No truncation is performed for a negative limit.

ValueDedup

func ValueDedup(value attribute.Value) (attribute.Value, bool)

ValueDedup returns value with all map values deduplicated and whether it changed.

Duplicate map keys are resolved using last-value-wins semantics.

ValueDedupLimitDepth

func ValueDedupLimitDepth(
	value attribute.Value,
	depthLimit int,
) (attribute.Value, bool, bool)

ValueDedupLimitDepth returns value with all map values deduplicated and all array and map values limited to depthLimit. The boolean results report depth limiting and deduplication changes, respectively.

Duplicate map keys are resolved using last-value-wins semantics. Depth starts at one for value and increments when descending into an array element or map value. An array or map beyond a non-negative depthLimit is replaced by an empty value. A negative depthLimit disables depth limiting.

ValueLimitDepth

func ValueLimitDepth(value attribute.Value, depthLimit int) (attribute.Value, bool)

ValueLimitDepth returns value with all array and map values limited to depthLimit. Map keys are not deduplicated.

Depth starts at one for value and increments when descending into an array element or map value. An array or map beyond a non-negative depthLimit is replaced by an empty value. A negative depthLimit disables depth limiting.

Dependency graph