update_current_span()

Signature

update_current_span(
respan_params: Dict | RespanParams = None,
attributes: Dict = None,
status: Status | StatusCode = None,
status_description: str = None,
name: str = None,
) -> 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

from respan import Respan, workflow, get_client
from opentelemetry.trace import StatusCode
respan = Respan(api_key="your-api-key")
@workflow(name="process")
def process(user_id: str):
client = get_client()
client.update_current_span(
respan_params={
"customer_identifier": user_id,
"trace_group_identifier": "pipeline-a",
"metadata": {"env": "production", "version": "2.1"},
},
attributes={"custom.step": "validation"},
status=StatusCode.OK,
name="process.success",
)
return "ok"
process("user-123")