Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    dmy-gh
    @dmy-gh
      def parent do
        Tracer.with_span "parent" do
          parent_ctx = Ctx.get_current()
    
          task =
            Task.async(fn ->
              Tracer.with_span parent_ctx, "child", %{} do
                Tracer.with_span "sub child" do
                  Process.sleep(2_000)
                end
    
                Process.sleep(1_000)
              end
            end)
    
          Task.await(task)
        end
      end

    Produces:

      InstrumentationLibrarySpans #0
     InstrumentationLibrary  
     Span #0
         Trace ID       : 3590104f363edf2915ab7dea675346f7
         Parent ID      : 
         ID             : d1b85fe9bb49f1a7
         Name           : parent
         Kind           : SPAN_KIND_INTERNAL
         Start time     : 2021-02-02 16:32:06.285669427 +0000 UTC
         End time       : 2021-02-02 16:32:09.28805425 +0000 UTC
         Status code    : STATUS_CODE_UNSET
         Status message : 
     Span #1
         Trace ID       : 3590104f363edf2915ab7dea675346f7
         Parent ID      : d1b85fe9bb49f1a7
         ID             : 7d04026e36f93266
         Name           : child
         Kind           : SPAN_KIND_INTERNAL
         Start time     : 2021-02-02 16:32:06.2857683 +0000 UTC
         End time       : 2021-02-02 16:32:09.287856878 +0000 UTC
         Status code    : STATUS_CODE_UNSET
         Status message : 
     Span #2
         Trace ID       : 3590104f363edf2915ab7dea675346f7
         Parent ID      : 7d04026e36f93266
         ID             : 7e3223982ba56037
         Name           : sub child
         Kind           : SPAN_KIND_INTERNAL
         Start time     : 2021-02-02 16:32:06.285813566 +0000 UTC
         End time       : 2021-02-02 16:32:08.286844333 +0000 UTC
         Status code    : STATUS_CODE_UNSET
         Status message :

    Which seems ok

    Is Ctx.get_current() what should be the first argument?
    The third and fourth args are inverted int the spec
    Tristan Sloughter
    @tsloughter
    yea, the first argument would be the ctx. using the one returned by get_current() would be the same as not passinga ctx tho, since it is the one from the pdict
    oh, thnaks, I see
    annoying that CI dialyzer passed
    dmy-gh
    @dmy-gh

    yea, the first argument would be the ctx. using the one returned by get_current() would be the same as not passinga ctx tho, since it is the one from the pdict

    If it was in the same process which is not the case here

    Tristan Sloughter
    @tsloughter
    right
    dmy-gh
    @dmy-gh
    What would you advise to create span in a GenServer?
    As the context referential is per process, passing the parent context as we did for the Task seems to work but with_span macro attaches it back at the end so any call to this GenServer with sub part containing a with_span will get the last set context as a parent
    Tristan Sloughter
    @tsloughter
    if you pass context as an argument to with_span then it'll go back to the previous context which was undefined
    dmy-gh
    @dmy-gh
    Tristan Sloughter
    @tsloughter
    the parent context, as in the Ctx variable passed in (or read in from the pdict if the user doesn't pass one), yes
    and that should be detach but it doesn't really have an effect on the outcome so I keep forgetting to fix that
    dmy-gh
    @dmy-gh
    In my case it has an effect as the GenServer process continues to live and further in the library I have an external service call using with_span which gets the context from the last call instead of nothing as it should
    So any new external service call increase the trace size, adding new span even minutes after

    I had to do:

    current_ctx = Ctx.attach(ctx)
    ...
    Span.end_span(child)
    Ctx.detach(current_ctx)

    In a similar example with a GenServer.call/3 instead of a Task.

    That's why I had to do this in the manually set span example

    Tristan Sloughter
    @tsloughter
    initial PR of some docs open-telemetry/opentelemetry.io#372
    Tristan Sloughter
    @tsloughter
    0.6.0 packages for the api, sdk and exporter finally published
    Ted Young
    @tedsuo
    Hi all. I just wanted to check in – we’re announcing v1.0 of the spec next tuesday, and I’d like to list all of the languages which beleieve they will have a release candidate available. Should I include Erlang on the list? https://docs.google.com/document/d/1lcNuU6JQI5ADElenSoyaZdDWVBc0Ahu9XaWkWESc0aI/edit#
    Tristan Sloughter
    @tsloughter
    @tedsuo yes, thanks
    Yuri Shkuro
    @yurishkuro
    I folks, I don't know Erlang and my brave attempts to just read the SDK code were not successful, but I do have potential users for it.
    The question I have is what kind of implementation style the SDK has - is it like many other langs where Span is an object that accumulates data until it ends, or is it a streaming style where events are sent to the exporter right away?
    Tristan Sloughter
    @tsloughter
    @yurishkuro note we have a slack channel now for erlang/elixir, where I think the conversations are "supposed" to go
    but it is like other languages, the span data is stored in shared in memory store called ETS and updated in place
    Yuri Shkuro
    @yurishkuro
    @tsloughter Thanks for confirming. FWIW, I was looking for otel-erlang Slack channel, but didn't find it, and the community/readme still points to gitter
    Tristan Sloughter
    @tsloughter
    oh, woops, thanks, I thought that got updated
    it is #otel-erlang-elixir