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