Verified Commit 14c9ff5d authored by Hercules Merscher's avatar Hercules Merscher 🌴
Browse files

feat: OTel utilities

parent db574507
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ module Labkit
          def call(_worker_class, job, _queue, _redis_pool)
            Labkit::Tracing::TracingUtils.with_tracing(operation_name: "sidekiq:#{job_class(job)}", tags: tags_from_job(job, SPAN_KIND)) do |span|
              # Inject the details directly into the job
              Labkit::Tracing::TracingUtils.tracer.inject(span.context, OpenTracing::FORMAT_TEXT_MAP, job)
              Labkit::Tracing::TracingUtils.inject_context(span.context, OpenTracing::FORMAT_TEXT_MAP, job)

              yield
            end
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ module Labkit
          SPAN_KIND = "server"

          def call(_worker, job, _queue)
            context = Labkit::Tracing::TracingUtils.tracer.extract(OpenTracing::FORMAT_TEXT_MAP, job)
            context = Labkit::Tracing::TracingUtils.extract_context(OpenTracing::FORMAT_TEXT_MAP, job)

            Labkit::Tracing::TracingUtils.with_tracing(operation_name: "sidekiq:#{job_class(job)}", child_of: context, tags: tags_from_job(job, SPAN_KIND)) { |_span| yield }
          end
+4 −0
Original line number Diff line number Diff line
@@ -24,8 +24,12 @@ module Labkit
        Labkit::Tracing::TracingUtils.log_exception_on_span(span, exception)

        tags(payload).each do |k, v|
          if Labkit::Tracing::TracingUtils.opentelemetry_span?(span)
            span.set_attribute(k, v)
          else
            span.set_tag(k, v)
          end
        end

        scope.close
      end
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ module Labkit
          tags = { "component" => "grpc", "span.kind" => "client", "grpc.method" => method, "grpc.type" => grpc_type }

          TracingUtils.with_tracing(operation_name: "grpc:#{method}", tags: tags) do |span|
            OpenTracing.inject(span.context, OpenTracing::FORMAT_TEXT_MAP, metadata)
            TracingUtils.inject_context(span.context, OpenTracing::FORMAT_TEXT_MAP, metadata)

            yield
          end
+2 −2
Original line number Diff line number Diff line
@@ -42,13 +42,13 @@ module Labkit
        private

        def wrap_with_tracing(call, method, grpc_type)
          context = TracingUtils.tracer.extract(OpenTracing::FORMAT_TEXT_MAP, call.metadata)
          context = TracingUtils.extract_context(OpenTracing::FORMAT_TEXT_MAP, call.metadata)
          method_name = "/#{rpc_split(method).join("/")}"
          tags = {
            "component" => "grpc",
            "span.kind" => "server",
            "grpc.method" => method_name,
            "grpc.type" => grpc_type,
            "grpc.type" => grpc_type
          }

          TracingUtils.with_tracing(operation_name: "grpc:#{method_name}", child_of: context, tags: tags) do |_span|
Loading