this repo has no description
1# PlugOpenTracing
2
3[](https://travis-ci.org/nmohoric/plug_opentracing)
4[](https://hex.pm/packages/plug_opentracing)
5[](http://hexdocs.pm/plug_opentracing)
6
7An Elixir Plug for adding OpenTracing instrumentation.
8
9## Usage
10
11Update your `mix.exs` file and run `mix deps.get`.
12```elixir
13defp deps do
14 [{:plug_opentracing, "~> 0.1"}]
15end
16```
17
18Add the plug to a pipeline. In this case we will look for the
19`uber-trace-id` header to exist. If so, it is split on `:` and
20the first and second values are used as the trace_id and parent_id
21when creating the span.
22
23```elixir
24defmodule MyPhoenixApp.MyController do
25 use MyPhoenixApp.Web, :controller
26 alias Plug.Conn.Status
27
28 plug PlugOpenTracing, trace_id: 'uber-trace-id'
29 plug :action
30
31 def index(conn, _params) do
32 conn
33 |> put_status(Status.code :ok)
34 end
35end
36
37```
38The created span can be accessed using `conn.assigns[:trace_span]`. This is useful
39when you want to use this span as the parent of another span in your request, or
40if you want to add tags/logs to the span before it is finished.
41
42The request span will be finished at the end of your request using a callback,
43which will send it to the Jaeger or Zipkin endpoint you've set up in your config.