Class: GrpcInterceptors::Server::OpenTelemetryTracingInstrument

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

Overview

Instance Method Summary collapse

Instance Method Details

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



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

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)
  kind = OpenTelemetry::Trace::SpanKind::SERVER

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