Skip to main content

LogAttributesValue

The allowed value type for trace and span attributes: str, int, float, or bool.

Overview

LogAttributesValue is a oneOf union that accepts a single primitive value. It is used as Dict[str, LogAttributesValue] for the attributes parameter when creating or updating traces and spans.
from adaline_api.models.log_attributes_value import LogAttributesValue

Accepted Types

Python TypeDescription
strString attribute value
intInteger attribute value (validated as float internally)
floatFloating-point attribute value
boolBoolean attribute value
Values are wrapped via the actual_instance parameter or passed as a positional argument:
LogAttributesValue(actual_instance="some string")
LogAttributesValue(actual_instance=42)
LogAttributesValue(actual_instance=3.14)
LogAttributesValue(actual_instance=True)

# Positional shorthand
LogAttributesValue("some string")
LogAttributesValue(42)

Examples

Setting Trace Attributes

from adaline_api.models.log_attributes_value import LogAttributesValue

trace = adaline.create_trace(
    name="chat-request",
    attributes={
        "user_id": LogAttributesValue("user_abc123"),
        "session_id": LogAttributesValue("sess_xyz"),
        "premium_user": LogAttributesValue(True),
        "request_count": LogAttributesValue(42),
    },
)

Setting Span Attributes

from adaline_api.models.log_attributes_value import LogAttributesValue

span = trace.create_span(
    name="llm-call",
    attributes={
        "model": LogAttributesValue("gpt-4o"),
        "temperature": LogAttributesValue(0.7),
        "max_tokens": LogAttributesValue(1024),
        "stream": LogAttributesValue(False),
    },
)

Updating Attributes

from adaline_api.models.log_attributes_value import LogAttributesValue

span.update({
    "attributes": {
        "latency_ms": LogAttributesValue(320.5),
        "cached": LogAttributesValue(True),
    },
})

Building Attributes Dynamically

from adaline_api.models.log_attributes_value import LogAttributesValue
from typing import Dict

def build_attributes(
    user_id: str,
    environment: str,
    retries: int,
    is_test: bool = False,
) -> Dict[str, LogAttributesValue]:
    return {
        "user_id": LogAttributesValue(user_id),
        "environment": LogAttributesValue(environment),
        "retries": LogAttributesValue(retries),
        "is_test": LogAttributesValue(is_test),
    }

attrs = build_attributes("user_123", "production", 0)
trace = adaline.create_trace(name="request", attributes=attrs)

Serialization

from adaline_api.models.log_attributes_value import LogAttributesValue

val = LogAttributesValue("hello")

d = val.to_dict()   # 'hello'
j = val.to_json()   # '"hello"'

restored = LogAttributesValue.from_dict(d)
restored = LogAttributesValue.from_json(j)