update_current_span()

Signature

1update_current_span(
2 respan_params: Dict | RespanParams = None,
3 attributes: Dict = None,
4 status: Status | StatusCode = None,
5 status_description: str = None,
6 name: str = None,
7) -> bool

Returns True if the span was updated successfully, False otherwise.

Parameters

ParameterTypeDescription
respan_paramsDict | RespanParamsRespan-specific parameters: customer_identifier, customer_email, customer_name, trace_group_identifier, metadata.
attributesDictCustom OpenTelemetry span attributes.
statusStatus | StatusCodeSpan status (StatusCode.OK, StatusCode.ERROR, etc.).
status_descriptionstrHuman-readable status description.
namestrOverride the span display name.

Respan params

KeyTypeDescription
customer_identifierstrUser or customer identifier. Appears in the Respan dashboard for filtering.
customer_emailstrCustomer email address.
customer_namestrCustomer display name.
trace_group_identifierstrGroup related traces together (e.g., by experiment, session, or pipeline).
metadataDictCustom key-value pairs for analytics and filtering.

Example

1from respan import Respan, workflow, get_client
2from opentelemetry.trace import StatusCode
3
4respan = Respan(api_key="your-api-key")
5
6@workflow(name="process")
7def process(user_id: str):
8 client = get_client()
9 client.update_current_span(
10 respan_params={
11 "customer_identifier": user_id,
12 "trace_group_identifier": "pipeline-a",
13 "metadata": {"env": "production", "version": "2.1"},
14 },
15 attributes={"custom.step": "validation"},
16 status=StatusCode.OK,
17 name="process.success",
18 )
19 return "ok"
20
21process("user-123")