Object with string keys and any values
Array of KeyValue pairs, or empty array marker if no attributes
const attrs = createAttributes({
"service.name": "turtle-miner",
"turtle.id": 42,
"turtle.active": true,
"location": {
x: 100,
y: 64,
z: 200
}
});
// Result: [
// { key: "service.name", value: { stringValue: "turtle-miner" } },
// { key: "turtle.id", value: { intValue: 42 } },
// { key: "turtle.active", value: { boolValue: true } },
// { key: "location", value: { kvlistValue: { values: [...] } } }
// ]
// Empty object returns empty array marker
const emptyAttrs = createAttributes({});
// Result: emptyJsonArray (serializes as [])
🏷️ Create KeyValue pairs from an object.
Converts a plain JavaScript object into an array of OpenTelemetry KeyValue pairs. This is the most common way to create attributes for telemetry data.