Sha256: 8e28d2006533c26af53499cb16bdca737244eae1e48b05baecffca88446d87c8
Contents?: true
Size: 1.44 KB
Versions: 16
Compression:
Stored size: 1.44 KB
Contents
# typed: true require_relative 'datadog_interceptor' module Datadog module Tracing module Contrib module GRPC # :nodoc: # The `#intercept!` method is implemented in gRPC; this module # will be prepended to the original class, effectively injecting # our tracing middleware into the head of the call chain. module InterceptWithDatadog def intercept!(type, args = {}) if should_prepend? datadog_interceptor = choose_datadog_interceptor(args) @interceptors.unshift(datadog_interceptor.new) if datadog_interceptor @trace_started = true end super end private def should_prepend? !trace_started? && !already_prepended? end def trace_started? defined?(@trace_started) && @trace_started end def already_prepended? @interceptors.any? do |interceptor| interceptor.class.ancestors.include?(Datadog::Tracing::Contrib::GRPC::DatadogInterceptor::Base) end end def choose_datadog_interceptor(args) if args.key?(:metadata) Datadog::Tracing::Contrib::GRPC::DatadogInterceptor::Client elsif args.key?(:call) Datadog::Tracing::Contrib::GRPC::DatadogInterceptor::Server end end end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems