Class: Datadog::Tracing::Contrib::GRPC::DatadogInterceptor::Server
- Inherits:
-
Base
- Object
- GRPC::Interceptor
- Base
- Datadog::Tracing::Contrib::GRPC::DatadogInterceptor::Server
- Defined in:
- lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb
Overview
The DatadogInterceptor::Server implements the tracing strategy for gRPC server-side endpoints. When the datadog fields have been added to the gRPC call metadata, this middleware component will extract any client-side tracing information, attempting to associate its tracing context with a parent client-side context
Instance Method Summary collapse
Methods inherited from Base
#bidi_streamer, #client_streamer, #initialize, #request_response, #server_streamer
Constructor Details
This class inherits a constructor from Datadog::Tracing::Contrib::GRPC::DatadogInterceptor::Base
Instance Method Details
#trace(keywords) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb', line 20 def trace(keywords) formatter = GRPC::Formatting::MethodObjectFormatter.new(keywords[:method]) = { span_type: Tracing::Metadata::Ext::HTTP::TYPE_INBOUND, service: service_name, # TODO: Remove server-side service name configuration resource: formatter.resource_name, on_error: error_handler } = keywords[:call]. set_distributed_context!() Tracing.trace(Ext::SPAN_SERVICE, **) do |span| annotate!(span, , formatter) begin yield rescue StandardError => e code = e.is_a?(::GRPC::BadStatus) ? e.code : ::GRPC::Core::StatusCodes::UNKNOWN span.set_tag(Contrib::Ext::RPC::GRPC::TAG_STATUS_CODE, code) raise else span.set_tag(Contrib::Ext::RPC::GRPC::TAG_STATUS_CODE, ::GRPC::Core::StatusCodes::OK) end end end |