Module: NewRelic::Agent::DistributedTraceMetrics

Extended by:
DistributedTraceMetrics
Included in:
DistributedTraceMetrics
Defined in:
lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb

Constant Summary collapse

ALL_SUFFIX =
'all'
ALL_WEB_SUFFIX =
'allWeb'
ALL_OTHER_SUFFIX =
'allOther'
UNKNOWN_CALLER_PREFIX =
'%s/Unknown/Unknown/Unknown/%s'

Instance Method Summary collapse

Instance Method Details

#prefix_for_metric(name, transaction, payload) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb', line 35

def prefix_for_metric(name, transaction, payload)
  if payload
    "#{name}/" \
    "#{payload.parent_type}/" \
    "#{payload.}/" \
    "#{payload.parent_app_id}/" \
    "#{transaction.distributed_tracer.caller_transport_type}"
  else
    UNKNOWN_CALLER_PREFIX % [name, transaction.distributed_tracer.caller_transport_type]
  end
end

#record_caller_by_duration_metrics(transaction, payload) ⇒ Object



47
48
49
50
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb', line 47

def record_caller_by_duration_metrics(transaction, payload)
  prefix = prefix_for_metric('DurationByCaller', transaction, payload)
  record_unscoped_metric(transaction, prefix, transaction.duration)
end

#record_errors_by_caller_metrics(transaction, payload) ⇒ Object



60
61
62
63
64
65
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb', line 60

def record_errors_by_caller_metrics(transaction, payload)
  return unless transaction.exceptions.size > 0

  prefix = prefix_for_metric('ErrorsByCaller', transaction, payload)
  record_unscoped_metric(transaction, prefix, 1)
end

#record_metrics_for_transaction(transaction) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb', line 24

def record_metrics_for_transaction(transaction)
  return unless Agent.config[:'distributed_tracing.enabled']

  dt = transaction.distributed_tracer
  payload = dt.distributed_trace_payload || dt.trace_state_payload

  record_caller_by_duration_metrics(transaction, payload)
  record_transport_duration_metrics(transaction, payload)
  record_errors_by_caller_metrics(transaction, payload)
end

#record_transport_duration_metrics(transaction, payload) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb', line 52

def record_transport_duration_metrics(transaction, payload)
  return unless payload

  prefix = prefix_for_metric('TransportDuration', transaction, payload)
  duration = transaction.calculate_transport_duration(payload)
  record_unscoped_metric(transaction, prefix, duration)
end

#transaction_type_suffixObject



16
17
18
19
20
21
22
# File 'lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb', line 16

def transaction_type_suffix
  if Transaction.recording_web_transaction?
    ALL_WEB_SUFFIX
  else
    ALL_OTHER_SUFFIX
  end
end