DDTrace.Kind (dd_trace_ex v0.1.0)

Copy Markdown View Source

The five span.kind values, by name.

span.kind tells Datadog what part a span played in a call: whether the service received the work or sent it, produced a message or consumed one. The backend reads it to build the service map and to infer the services a trace touched but never entered — a database, a queue, an API nobody instrumented.

Integrations set it; so does hand-written instrumentation around a client call the library does not know about:

DDTrace.trace "stripe.charge", type: "http" do
  DDTrace.set_tag("span.kind", DDTrace.Kind.client())
  charge(order)
end

internal is the one you do not set

A span with no kind is internal already: it is the value the backend assumes, so writing it says nothing a reader could not infer. It has a name here because the closed set is worth spelling whole — reading a kind back off a span, or matching on one, needs the name that means "no kind at all".

The functions exist to spell the values without a typo; the raw strings are equally valid everywhere.

Examples

iex> DDTrace.Kind.server()
"server"

Summary

Functions

This service sent the work elsewhere: "client". An outbound call's span.

This service took a message off a queue: "consumer".

The work stayed inside this service: "internal".

This service put a message on a queue: "producer".

This service received the work: "server". An inbound request's span.

Functions

client()

@spec client() :: String.t()

This service sent the work elsewhere: "client". An outbound call's span.

consumer()

@spec consumer() :: String.t()

This service took a message off a queue: "consumer".

internal()

@spec internal() :: String.t()

The work stayed inside this service: "internal".

The value a span without a kind already has. Deliberately never set by this library — see the section above.

producer()

@spec producer() :: String.t()

This service put a message on a queue: "producer".

server()

@spec server() :: String.t()

This service received the work: "server". An inbound request's span.