पाठ 5 / 25

Attributes, Events and Status

Make spans useful.

Describe what happened

Attributes are key-value pairs on a span (http.request.method="POST", http.response.status_code=502, db.system="postgresql", or your own such as app.order.id). Events are timestamped annotations within a span, and exceptions are recorded as events with type, message and stack trace. Status is Unset (the default), Ok or Error; instrumentation sets Error for failures such as 5xx server responses. Links connect spans across traces, for example a batch job processing messages from many requests.

One span in detail

How a backend might display a failed payment call.

span: POST /charge     kind: CLIENT     duration: 700 ms     status: ERROR
attributes:
  http.request.method      = POST
  url.full                 = https://gateway.example.com/charge
  http.response.status_code = 504
  server.address           = gateway.example.com
  app.payment.provider     = "acme-pay"
events:
  +698 ms  exception  type=TimeoutError  message="gateway timeout after 700 ms"
resource:
  service.name=payment-service  service.version=2.8.1  deployment.environment.name=prod

Prefer semantic convention names

Using standard attribute names lets backends build service maps and dashboards automatically.

त्वरित जाँच: How is an exception usually recorded on a span?

  • As a new trace
  • As a span event with exception details, plus an Error status
  • As a metric only
  • By deleting the span
Answer

As a span event with exception details, plus an Error status — record_exception adds an event.