View Source Spandex.Span (Spandex v3.2.0)

A container for all span data and metadata.

Link to this section Summary

Link to this section Types

@type t() :: %Spandex.Span{
  completion_time: Spandex.timestamp() | nil,
  env: String.t() | nil,
  error: Keyword.t() | nil,
  http: Keyword.t() | nil,
  id: Spandex.id(),
  name: String.t(),
  parent_id: Spandex.id() | nil,
  private: Keyword.t(),
  resource: atom() | String.t(),
  service: atom(),
  service_version: String.t() | nil,
  services: Keyword.t() | nil,
  sql_query: Keyword.t() | nil,
  start: Spandex.timestamp(),
  tags: Keyword.t() | nil,
  trace_id: Spandex.id(),
  type: atom()
}

Link to this section Functions

Link to this function

child_of(parent_span, name, id, start, opts)

View Source
@spec child_of(t(), String.t(), Spandex.id(), Spandex.timestamp(), Keyword.t()) ::
  {:ok, t()} | {:error, [Optimal.error()]}
@spec new(Keyword.t()) :: {:ok, t()} | {:error, [Optimal.error()]}

Create a new span.


opts

Opts

  • id(:any) Required
  • name(:string) Required
  • service(:atom) Required
  • start(:integer) Required
  • trace_id(:any) Required
  • completion_time(:integer)
  • env(:string)
  • error(:keyword)
  • http(:keyword)
  • parent_id(:any)
  • private(:keyword) - Default: []
  • resource([:atom, :string])
  • service_version(:string)
  • services(:keyword) - Default: []
  • sql_query(:keyword)
  • tags(:keyword) - Default: []
  • type(:atom)

Also accepts extra opts that are not named here.


Link to this function

update(span, opts, schema \\ Map.put(%{__struct__: Optimal.Schema, annotations: [], custom: [], defaults: [private: [], services: [], tags: []], describe: [], extra_keys?: true, opts: [:completion_time, :env, :error, :http, :id, :name, :parent_id, :private, :resource, :service, :service_version, :services, :sql_query, :start, :tags, :trace_id, :type], required: [:id, :name, :service, :start, :trace_id], types: [completion_time: :integer, env: :string, error: :keyword, http: :keyword, id: :any, name: :string, parent_id: :any, private: :keyword, resource: [:atom, :string], service: :atom, service_version: :string, services: :keyword, sql_query: :keyword, start: :integer, tags: :keyword, trace_id: :any, type: :atom]}, :required, []))

View Source
@spec update(t() | nil, Keyword.t(), Optimal.Schema.t()) ::
  {:ok, t()} | {:error, [Optimal.error()]}

Update an existing span.


opts

Opts

  • completion_time(:integer)
  • env(:string)
  • error(:keyword)
  • http(:keyword)
  • id(:any)
  • name(:string)
  • parent_id(:any)
  • private(:keyword) - Default: []
  • resource([:atom, :string])
  • service(:atom)
  • service_version(:string)
  • services(:keyword) - Default: []
  • sql_query(:keyword)
  • start(:integer)
  • tags(:keyword) - Default: []
  • trace_id(:any)
  • type(:atom)

Also accepts extra opts that are not named here.


special-meta

Special Meta

[
  http: [
    url: "my_website.com?foo=bar",
    status_code: "400",
    method: "GET",
    query_string: "foo=bar",
    user_agent: "Mozilla/5.0...",
    request_id: "special_id"
  ],
  error: [
    exception: ArgumentError.exception("foo"),
    stacktrace: __STACKTRACE__,
    error?: true # Used for specifying that a span is an error when there is no exception or stacktrace.
  ],
  sql_query: [
    rows: 100,
    db: "my_database",
    query: "SELECT * FROM users;"
  ],
  # Private has the same structure as the outer meta structure, but private metadata does not
  # transfer from parent span to child span.
  private: [
    ...
  ]
]