// String value
const stringValue: AnyValue = { stringValue: "hello world" };
// Number values
const intValue: AnyValue = { intValue: 42 };
const doubleValue: AnyValue = { doubleValue: 3.14159 };
// Boolean value
const boolValue: AnyValue = { boolValue: true };
// Array value
const arrayValue: AnyValue = {
arrayValue: {
values: [
{ stringValue: "item1" },
{ stringValue: "item2" }
]
}
};
// Object value
const objectValue: AnyValue = {
kvlistValue: {
values: [
{ key: "name", value: { stringValue: "turtle" } },
{ key: "level", value: { intValue: 64 } }
]
}
};
🎯 AnyValue is used to represent any type of attribute value.
This is a discriminated union that can contain primitives, arrays, or nested objects. It's the foundation for all attribute values in OpenTelemetry, providing type safety while allowing flexible data structures.