Last active
June 3, 2020 03:54
-
-
Save yatender-oktalk/b8a7ef63874ca8d6391d689f131c0e88 to your computer and use it in GitHub Desktop.
OpenTelemetryDemo
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 OpenTelemetryDemo do | |
@moduledoc """ | |
Documentation for `OpenTelemetryDemo`. | |
""" | |
require OpenTelemetry.Tracer | |
require OpenTelemetry.Span | |
@doc """ | |
random function just to show the open-telemetry demo, | |
this function will mimic some working of the modules. | |
""" | |
def hello() do | |
# we can pass the span name into the below function | |
start_new_span("span-name-hello") | |
# add delay in the | |
add_delay(200) | |
# finish the span | |
end_span() | |
end | |
# Private functions | |
defp add_delay(delay) do | |
Process.sleep(delay) | |
end | |
defp start_new_span(span_name) do | |
OpenTelemetry.Tracer.start_span(span_name) | |
end | |
defp end_span() do | |
OpenTelemetry.Tracer.end_span | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment