# SpandexTesla

<!-- MDOC !-->

Tracing integration between [tesla]( and [spandex](
It leverages telemetry to get the [tesla]( events and trace them with [spandex](

[![ Version](](
[![Coverage Status](](

## Installation

The package can be installed
by adding `spandex_tesla` to your list of dependencies in `mix.exs`:

def deps do
    {:spandex_tesla, "~> 1.5.0"}

[Checkout the documentation]( for more information.

## Usage

Configure the correct tracer to be used:

config :spandex_tesla
  service: :tesla, # Optional
  tracer: MyApp.Tracer, # Required

Include the [telemetry middleware]( in your tesla client:

defmodule MyClient do
  use Tesla

  plug Tesla.Middleware.Telemetry


Attach the telemetry handler:

# in application.ex

The docs can
be found at [](

## Resource grouping

You can pass a custom resource callback to `SpandexTesla.Telemetry.attach/1` with `:resource` key in the config. If none provided, resource name will default to `<METHOD> <REQ_URL>`.

The resource callback takes telemetry event metadata (map) as parameter and returns a string resource name.

See [Tesla.Middleware.Telemetry]( for metadata structure, and also usage of middleware for URL event scoping.

  resource: fn %{env: %{url: url, method: method}} ->
    upcased_method = method |> to_string() |> String.upcase()
    "#{upcased_method} #{Regex.replace(~r/item\/(\d+$)/, url, "item/:item_id")}"

## Changelog

See the [changelog](

<!-- MDOC !-->

## Contributing

See the [contributing file](

## License

Copyright 2021 (c) Thiago Santos.

spandex_tesla source code is released under Apache 2 License.

Check [LICENSE]( file for more information.