8000 GitHub - reachfh/spandex_tesla: Middleware for Tesla HTTP client library that creates trace spans using Spandex
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Middleware for Tesla HTTP client library that creates trace spans using Spandex

License

Notifications You must be signed in to change notification settings

reachfh/spandex_tesla

Repository files navigation

test workflow Contributor Covenant

Tesla.Middleware.Spandex

Middleware for the Tesla HTTP client library that supports Datadog tracing using Spandex.

It creates a span for the client HTTP call, setting metadata:

[
  http: [
    status_code: status_code,
    method: method,
    url: url,
    path: path,
    query_string: URI.encode_query(query),
    host: uri.host,
    port: uri.port,
    scheme: uri.scheme,
  ],
  type: :web,
  resource: "#{method} #{path}",
  tags: [
    span: [kind: "client"]
  ]
]

See https://docs.datadoghq.com/tracing/trace_collection/tracing_naming_convention/

Installation

Add spandex_tesla to the list of dependencies in mix.exs:

def deps do
  [
    {:spandex_tesla, "~> 0.1.0"}
  ]
end

Configuration

Add this middleware as a plug in your client.

defmodule GitHub do
  use Tesla

  plug Tesla.Middleware.Spandex
  plug Tesla.Middleware.BaseUrl, "https://api.github.com"
  plug Tesla.Middleware.Headers, [{"authorization", "token xyz"}]
  plug Tesla.Middleware.JSON

  def user_repos(login) do
    get("/users/" <> login <> "/repos")
  end
end

Configure the Spandex tracer in config/config.exs:

config :spandex_tesla,
  tracer: Foo.Tracer

Code of Conduct

This project Contributor Covenant version 2.1. Check CODE_OF_CONDUCT.md file for more information.

About

Middleware for Tesla HTTP client library that creates trace spans using Spandex

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0