Last active
February 22, 2019 08:30
-
-
Save yonkeltron/ceb500d5f3a19c1a9ce1bed4e6298817 to your computer and use it in GitHub Desktop.
OpenTracing in Elixir with Otter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Ot.Mixfile do | |
use Mix.Project | |
def project do | |
[app: :ot, | |
version: "0.1.0", | |
elixir: "~> 1.4", | |
build_embedded: Mix.env == :prod, | |
start_permanent: Mix.env == :prod, | |
deps: deps()] | |
end | |
def application do | |
# Specify extra applications you'll use from Erlang/Elixir | |
[extra_applications: [:logger]] | |
end | |
defp deps do | |
[{:otter, "~> 0.2.0"}, | |
{:ibrowse, "~> 4.4"}, | |
{:cowboy, "~> 1.1"}] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Ot do | |
@moduledoc "Basic OpenTracing demo using the otter library" | |
require Logger | |
alias :otter, as: Otter | |
@spec log_span_to_zipkin(String.t(), integer()) :: no_return() | |
@spec log_span_to_zipkin(String.t()) :: no_return() | |
def log_span_to_zipkin(span_name, sleep_time \\ 1000) do | |
Logger.info("Constructing OT span...") | |
span = span_name |> Otter.start() |> Otter.tag("OpenTracing", "Demo") |> Otter.log("Before sleep") | |
Logger.info("Sleeping...") | |
:timer.sleep(sleep_time) | |
Logger.info("Finishing up span...") | |
span |> Otter.log("After sleep") |> Otter.finish() | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If anyone stumbles upon this – the example it works perfectly with elixir 1.8, and jaeger: