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

# End Trace

> ViewSet for Trace operations.

IMPORTANT — Memory safety:
Traces can have hundreds of spans, each with metadata containing base64
screenshots (1MB+). Never use TraceSerializer or prefetch_related("spans")
here — that eagerly loads ALL span data and WILL OOM on 2GB instances.

Safe patterns:
- list: TraceListSerializer (no spans, just trace metadata + annotated count)
- retrieve: SpanTreeSerializer with .only() (minimal columns, no metadata)
- create/end: TraceDetailSerializer (no spans at all)
- Individual span detail: fetched separately via SpanViewSet



## OpenAPI

````yaml POST /api/tracing/traces/{trace_id}/end/
openapi: 3.0.3
info:
  title: Bedrock API
  version: 1.0.0
  description: API for managing agent templates, agents, organizations, and adapter state
servers: []
security: []
paths:
  /api/tracing/traces/{trace_id}/end/:
    post:
      tags:
        - tracing
      description: >-
        ViewSet for Trace operations.


        IMPORTANT — Memory safety:

        Traces can have hundreds of spans, each with metadata containing base64

        screenshots (1MB+). Never use TraceSerializer or
        prefetch_related("spans")

        here — that eagerly loads ALL span data and WILL OOM on 2GB instances.


        Safe patterns:

        - list: TraceListSerializer (no spans, just trace metadata + annotated
        count)

        - retrieve: SpanTreeSerializer with .only() (minimal columns, no
        metadata)

        - create/end: TraceDetailSerializer (no spans at all)

        - Individual span detail: fetched separately via SpanViewSet
      operationId: tracing_traces_end_create
      parameters:
        - in: path
          name: trace_id
          schema:
            type: string
            format: uuid
          description: A UUID string identifying this trace.
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TraceDetailRequest'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/TraceDetailRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/TraceDetailRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TraceDetail'
          description: ''
      security:
        - tokenAuth: []
        - APIKeyAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    TraceDetailRequest:
      type: object
      description: >-
        Trace serializer without nested spans (spans handled separately for
        pagination).
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
        agent:
          type: string
          format: uuid
          nullable: true
        ended_at:
          type: string
          format: date-time
          nullable: true
        error:
          type: string
        metadata: {}
      required:
        - name
    TraceDetail:
      type: object
      description: >-
        Trace serializer without nested spans (spans handled separately for
        pagination).
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        name:
          type: string
          maxLength: 255
        agent:
          type: string
          format: uuid
          nullable: true
        started_at:
          type: string
          format: date-time
          readOnly: true
        ended_at:
          type: string
          format: date-time
          nullable: true
        error:
          type: string
        metadata: {}
      required:
        - id
        - name
        - started_at
  securitySchemes:
    tokenAuth:
      type: apiKey
      in: header
      name: Authorization
      description: Token-based authentication with required prefix "Token"
    APIKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````