• 🎯 Create an AnyValue from a JavaScript value.

    Automatically converts JavaScript values to the appropriate AnyValue type. This is the primary way to convert regular values into OpenTelemetry-compatible attribute values.

    Parameters

    • value: unknown

      The JavaScript value to convert

    Returns AnyValue

    An AnyValue representation of the input

    // Primitive values
    const stringVal = createAnyValue("hello world");
    // Result: { stringValue: "hello world" }

    const numberVal = createAnyValue(42);
    // Result: { intValue: 42 }

    const floatVal = createAnyValue(3.14159);
    // Result: { doubleValue: 3.14159 }

    const boolVal = createAnyValue(true);
    // Result: { boolValue: true }

    // Arrays
    const arrayVal = createAnyValue(["item1", "item2", 42]);
    // Result: { arrayValue: { values: [{ stringValue: "item1" }, { stringValue: "item2" }, { intValue: 42 }] } }

    // Objects
    const objectVal = createAnyValue({ name: "turtle", level: 64 });
    // Result: { kvlistValue: { values: [{ key: "name", value: { stringValue: "turtle" } }, { key: "level", value: { intValue: 64 } }] } }