Created
October 14, 2020 06:51
-
-
Save yatender-oktalk/1e163de89005ad84ece3e51f67831f1e to your computer and use it in GitHub Desktop.
setup-zipkin-random-open-telemetry
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 ZipkinRandom.Application do | |
# See https://hexdocs.pm/elixir/Application.html | |
# for more information on OTP Applications | |
@moduledoc false | |
use Application | |
def start(_type, _args) do | |
# register your tracer so that opentelemtry knows that | |
# it needs to start tracing the events | |
_ = OpenTelemetry.register_application_tracer(:zipkin_random) | |
children = [ | |
# Starts a worker by calling: ZipkinRandom.Worker.start_link(arg) | |
# {ZipkinRandom.Worker, arg} | |
] | |
... | |
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
import Config | |
config :opentelemetry, | |
:processors, | |
ot_batch_processor: %{ | |
exporter: | |
{:opentelemetry_zipkin, | |
%{ | |
address: 'http://localhost:9411/api/v2/spans', | |
local_endpoint: %{service_name: "zipkin_random"} | |
}} | |
} |
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 ZipkinRandom.MixProject do | |
use Mix.Project | |
... | |
# Run "mix help deps" to learn about dependencies. | |
defp deps do | |
[ | |
{:opentelemetry_api, "~> 0.3.2"}, | |
{:opentelemetry_zipkin, "~> 0.2.0"}, | |
{:opentelemetry, "~> 0.4.0"} | |
# {:dep_from_hexpm, "~> 0.3.0"}, | |
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} | |
] | |
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 ZipkinRandom do | |
@moduledoc """ | |
Documentation for `ZipkinRandom`. | |
""" | |
require OpenTelemetry.Tracer | |
@doc """ | |
Hello world. | |
## Examples | |
iex> ZipkinRandom.hello() | |
:world | |
""" | |
def hello do | |
# Here we are starting our new span | |
OpenTelemetry.Tracer.start_span("span_name_1") | |
# Mimic that some work is happening | |
Process.sleep(100) | |
# finish the span just before returning the response | |
OpenTelemetry.Tracer.end_span() | |
:world | |
end | |
end |
Nevermind, I see now it was renamed in the newer version
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey! Great article, thanks for that!
Could
ot_batch_processor
have a typo? I have found onlyotel_batch_processor
in the repo