Sha256: 1a68ecc754054d59ea9547d94dbe60d970eb94a3fb0962624617d569e296a649
Contents?: true
Size: 1.19 KB
Versions: 8
Compression:
Stored size: 1.19 KB
Contents
module Datadog::Notifications::Plugins class GRPC < Base # Options: # # *<tt>:metric_name</tt> - the metric name, defaults to 'grpc.request' # *<tt>:tags</tt> - additional tags # # It expects ActiveSupport instrumented notifications named 'process_action.grpc'. # Notification payload should have :service (service name, string) and :action (service action/method name, string) keys. # # Compatible instrumentation is implemented in grpcx gem: https://github.com/bsm/grpcx (>= 0.2.0) def initialize(metric_name: 'grpc.request', **opts) super @metric_name = metric_name Datadog::Notifications.subscribe 'process_action.grpc' do |reporter, event| record reporter, event end end private def record(reporter, event) payload = event.payload service = payload[:service] action = payload[:action] status = payload[:exception] ? 'error' : 'ok' tags = self.tags + %W[service:#{service} action:#{action} status:#{status}] reporter.batch do reporter.increment @metric_name, tags: tags reporter.timing "#{@metric_name}.time", event.duration, tags: tags end end end end
Version data entries
8 entries across 8 versions & 1 rubygems