---
title: JudgmentSpanProcessor
seo:
  title: JudgmentSpanProcessor — Python SDK
  description: >-
    Span processor that manages span lifecycle, state, and batched export.
    (Python SDK)
description: Span processor that manages span lifecycle, state, and batched export.
---

Extends the OpenTelemetry `BatchSpanProcessor` with per-span mutable
state (counters, lists), partial-span emission for streaming updates,
and automatic baggage propagation.

Created automatically by `Tracer.init()`. Use it directly only when
building a custom tracing pipeline.

## Attributes

| Prop | Type | Default | Description |
| - | - | - | - |
| `tracer?` | `Any` | `tracer` | |

***

## state\_set()

Store a value in the mutable state for a span.

```python
def state_set(span_context, key, value) -> None:
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `span_context` | `SpanContext` | - | |
| `key` | `str` | - | |
| `value` | `Any` | - | |

### Returns

`None`

***

## state\_get()

Retrieve a value from the mutable state for a span.

```python
def state_get(span_context, key, default=None) -> Any:
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `span_context` | `SpanContext` | - | |
| `key` | `str` | - | |
| `default?` | `Any` | `None` | |

### Returns

`Any`

***

## state\_incr()

Atomically increment a counter. Returns the value before increment.

```python
def state_incr(span_context, key) -> int:
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `span_context` | `SpanContext` | - | |
| `key` | `str` | - | |

### Returns

`int`

***

## state\_append()

Atomically append to a list. Returns the new list.

```python
def state_append(span_context, key, item) -> list[Any]:
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `span_context` | `SpanContext` | - | |
| `key` | `str` | - | |
| `item` | `Any` | - | |

### Returns

`list[Any]`

***

## emit\_partial()

Export the current span's in-progress state for streaming updates.

```python
def emit_partial() -> None:
```

### Returns

`None`

***

## on\_start()

```python
def on_start(span, parent_context=None) -> None:
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `span` | `Span` | - | |
| `parent_context?` | `Optional[Context]` | `None` | |

### Returns

`None`

***

## on\_end()

```python
def on_end(span) -> None:
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `span` | `ReadableSpan` | - | |

### Returns

`None`
