• 🔑 Create a KeyValue pair from a key and value.

    Convenience function to create OpenTelemetry KeyValue pairs. The value is automatically converted to an AnyValue.

    Parameters

    • key: string

      The attribute key

    • value: unknown

      The attribute value (will be converted to AnyValue)

    Returns KeyValue

    A KeyValue pair

    const serviceNameAttr = createKeyValue("service.name", "turtle-miner");
    // Result: { key: "service.name", value: { stringValue: "turtle-miner" } }

    const levelAttr = createKeyValue("mining.level", 64);
    // Result: { key: "mining.level", value: { intValue: 64 } }

    const activeAttr = createKeyValue("turtle.active", true);
    // Result: { key: "turtle.active", value: { boolValue: true } }