> ## Documentation Index
> Fetch the complete documentation index at: https://www.adaline.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# LogAttributesValue

# 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](/docs/reference/sdk/v2/python/classes/trace) and [spans](/docs/reference/sdk/v2/python/classes/span).

```python theme={null}
from adaline_api.models.log_attributes_value import LogAttributesValue
```

***

## Accepted Types

| Python Type | Description                                               |
| ----------- | --------------------------------------------------------- |
| `str`       | String attribute value                                    |
| `int`       | Integer attribute value (validated as `float` internally) |
| `float`     | Floating-point attribute value                            |
| `bool`      | Boolean attribute value                                   |

Values are wrapped via the `actual_instance` parameter or passed as a positional argument:

```python theme={null}
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

```python theme={null}
from adaline_api.models.log_attributes_value import LogAttributesValue

trace = monitor.log_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

```python theme={null}
from adaline_api.models.log_attributes_value import LogAttributesValue

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

### Updating Attributes

```python theme={null}
from adaline_api.models.log_attributes_value import LogAttributesValue

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

### Building Attributes Dynamically

```python theme={null}
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 = monitor.log_trace(name="request", attributes=attrs)
```

***

## Serialization

```python theme={null}
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)
```
