Class: GrpcInterceptors::Server::OpenTelemetryTracingInterceptor

Inherits:
GRPC::ServerInterceptor
  • Object
show all
Defined in:
lib/grpc_interceptors/server/opentelemetry_tracing_interceptor.rb

Overview

Instance Method Summary collapse

Instance Method Details

#request_response(request: nil, call: nil, method: nil, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/grpc_interceptors/server/opentelemetry_tracing_interceptor.rb', line 11

def request_response(request: nil, call: nil, method: nil, &block)
  context = OpenTelemetry.propagation.extract(call.)
  route_name = Common::GrpcHelper.route_name(method)
  attributes = Common::OpenTelemetryHelper.tracing_attributes(method)

  OpenTelemetry::Context.with_current(context) do
    Common::OpenTelemetryHelper.tracer.in_span(
      route_name,
      attributes: attributes,
      kind: GrpcInterceptors::Server::KIND,
      &block
    )
  end
end