Skip to content

Update a span

client.Spans.Update(ctx, spanID, body) (*Span, error)
PATCH/v5/spans/{span_id}

Partially update a span’s mutable fields and return the updated span.

Only the provided fields among name, end timestamp, output, metadata, and status are changed. This endpoint is available only for accounts still served solely by the legacy trace store: once an account begins dual-writing to the tracing service — which is upsert-only and has no partial-update operation — PATCH returns 501 and PUT /v5/spans/batch must be used instead. Updates are authorized against the span’s parent trace, and an unknown id returns 404.

Credential redaction: values in the free-form input, output, metadata, and expected objects, and in name, that are credential-shaped (bearer/JWT, API keys, connection-string passwords) or under a credential-named key are replaced with [REDACTED:credential] before the span is persisted, so the stored and returned span reflects the redacted value (EY 12.3).

ParametersExpand Collapse
spanID string
body SpanUpdateParams
EndTimestamp param.Field[Time]Optional
formatdate-time
Metadata param.Field[map[string, any]]Optional
Name param.Field[string]Optional
Output param.Field[map[string, any]]Optional
Status param.Field[SpanStatus]Optional
ReturnsExpand Collapse
type Span struct{…}
ID string
AccountID string
Name string
StartTimestamp Time
formatdate-time
TraceID string

id for grouping traces together, uuid is recommended

maxLength256
ApplicationInteractionID stringOptional

The interaction ID this span belongs to

ApplicationVariantID stringOptional

The id of the application variant this span belongs to

CreatedBy IdentityOptional

The identity that created the entity.

ID string
Type IdentityType
One of the following:
const IdentityTypeUser IdentityType = "user"
const IdentityTypeServiceAccount IdentityType = "service_account"
Object IdentityObjectOptional
EndTimestamp TimeOptional
formatdate-time
Expected map[string, any]Optional
GroupID stringOptional

Reference to a group_id

Input map[string, any]Optional
InputTokens int64Optional

Prompt tokens the producer reported for this span, absent when it reported none. Same quantity the input_tokens sort orders by.

maximum4294967295
minimum0
Metadata map[string, any]Optional
Object SpanObjectOptional
ObsSpanID stringOptional

W3C span id of the observability span this span executed in.

ObsTraceID stringOptional

W3C trace id of the observability trace this span executed in. Null for spans written without the edge, and for accounts still served by the legacy trace store.

Output map[string, any]Optional
OutputTokens int64Optional

Completion tokens the producer reported for this span, absent when it reported none. Same quantity the output_tokens sort orders by.

maximum4294967295
minimum0
ParentID stringOptional

Reference to a parent span_id

Status SpanStatusOptional
One of the following:
const SpanStatusSuccess SpanStatus = "SUCCESS"
const SpanStatusError SpanStatus = "ERROR"
const SpanStatusCanceled SpanStatus = "CANCELED"
Type SpanTypeOptional
One of the following:
const SpanTypeTextInput SpanType = "TEXT_INPUT"
const SpanTypeTextOutput SpanType = "TEXT_OUTPUT"
const SpanTypeCompletionInput SpanType = "COMPLETION_INPUT"
const SpanTypeCompletion SpanType = "COMPLETION"
const SpanTypeKBRetrieval SpanType = "KB_RETRIEVAL"
const SpanTypeKBInput SpanType = "KB_INPUT"
const SpanTypeReranking SpanType = "RERANKING"
const SpanTypeExternalEndpoint SpanType = "EXTERNAL_ENDPOINT"
const SpanTypePromptEngineering SpanType = "PROMPT_ENGINEERING"
const SpanTypeDocumentInput SpanType = "DOCUMENT_INPUT"
const SpanTypeMapReduce SpanType = "MAP_REDUCE"
const SpanTypeDocumentSearch SpanType = "DOCUMENT_SEARCH"
const SpanTypeDocumentPrompt SpanType = "DOCUMENT_PROMPT"
const SpanTypeCustom SpanType = "CUSTOM"
const SpanTypeCodeExecution SpanType = "CODE_EXECUTION"
const SpanTypeDataManipulation SpanType = "DATA_MANIPULATION"
const SpanTypeEvaluation SpanType = "EVALUATION"
const SpanTypeFileRetrieval SpanType = "FILE_RETRIEVAL"
const SpanTypeKBAddChunk SpanType = "KB_ADD_CHUNK"
const SpanTypeKBManagement SpanType = "KB_MANAGEMENT"
const SpanTypeGuardrail SpanType = "GUARDRAIL"
const SpanTypeOutputGuardrail SpanType = "OUTPUT_GUARDRAIL"
const SpanTypeTracer SpanType = "TRACER"
const SpanTypeAgentTracer SpanType = "AGENT_TRACER"
const SpanTypeAgentWorkflow SpanType = "AGENT_WORKFLOW"
const SpanTypeStandalone SpanType = "STANDALONE"

Update a span

package main

import (
  "context"
  "fmt"

  "github.com/scaleapi/sgp-dev-go"
  "github.com/scaleapi/sgp-dev-go/option"
)

func main() {
  client := sgpdev.NewClient(
    option.WithAPIKey("My API Key"),
    option.WithAccountID("My Account ID"),
  )
  span, err := client.Spans.Update(
    context.TODO(),
    "span_id",
    sgpdev.SpanUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", span.ID)
}
{
  "id": "id",
  "account_id": "account_id",
  "name": "name",
  "start_timestamp": "2019-12-27T18:11:19.117Z",
  "trace_id": "trace_id",
  "application_interaction_id": "application_interaction_id",
  "application_variant_id": "application_variant_id",
  "created_by": {
    "id": "id",
    "type": "user",
    "object": "identity"
  },
  "end_timestamp": "2019-12-27T18:11:19.117Z",
  "expected": {
    "foo": "bar"
  },
  "group_id": "group_id",
  "input": {
    "foo": "bar"
  },
  "input_tokens": 0,
  "metadata": {
    "foo": "bar"
  },
  "object": "span",
  "obs_span_id": "obs_span_id",
  "obs_trace_id": "obs_trace_id",
  "output": {
    "foo": "bar"
  },
  "output_tokens": 0,
  "parent_id": "parent_id",
  "status": "SUCCESS",
  "type": "TEXT_INPUT"
}
Returns Examples
{
  "id": "id",
  "account_id": "account_id",
  "name": "name",
  "start_timestamp": "2019-12-27T18:11:19.117Z",
  "trace_id": "trace_id",
  "application_interaction_id": "application_interaction_id",
  "application_variant_id": "application_variant_id",
  "created_by": {
    "id": "id",
    "type": "user",
    "object": "identity"
  },
  "end_timestamp": "2019-12-27T18:11:19.117Z",
  "expected": {
    "foo": "bar"
  },
  "group_id": "group_id",
  "input": {
    "foo": "bar"
  },
  "input_tokens": 0,
  "metadata": {
    "foo": "bar"
  },
  "object": "span",
  "obs_span_id": "obs_span_id",
  "obs_trace_id": "obs_trace_id",
  "output": {
    "foo": "bar"
  },
  "output_tokens": 0,
  "parent_id": "parent_id",
  "status": "SUCCESS",
  "type": "TEXT_INPUT"
}