Class: GraphQL::Tracing::PrometheusTrace::PrometheusMonitor
- Inherits:
-
MonitorTrace::Monitor
- Object
- MonitorTrace::Monitor
- GraphQL::Tracing::PrometheusTrace::PrometheusMonitor
- Defined in:
- lib/graphql/tracing/prometheus_trace.rb
Defined Under Namespace
Classes: Event
Constant Summary
Constants included from MonitorTrace::Monitor::GraphQLPrefixNames
MonitorTrace::Monitor::GraphQLPrefixNames::ANALYZE_NAME, MonitorTrace::Monitor::GraphQLPrefixNames::EXECUTE_NAME, MonitorTrace::Monitor::GraphQLPrefixNames::LEX_NAME, MonitorTrace::Monitor::GraphQLPrefixNames::PARSE_NAME, MonitorTrace::Monitor::GraphQLPrefixNames::VALIDATE_NAME
Instance Method Summary collapse
-
#active?(keyword) ⇒ Boolean
-
#gettime ⇒ Object
-
#instrument(keyword, object) ⇒ Object
-
#send_json(duration, keyword, object) ⇒ Object
Methods included from MonitorTrace::Monitor::GraphQLPrefixNames
#platform_authorized_key, #platform_field_key, #platform_resolve_type_key, #platform_source_class_key
Methods inherited from MonitorTrace::Monitor
#fallback_transaction_name, #initialize, #name_for, #start_event, #transaction_name
Constructor Details
This class inherits a constructor from GraphQL::Tracing::MonitorTrace::Monitor
Instance Method Details
#active?(keyword) ⇒ Boolean
58 59 60 |
# File 'lib/graphql/tracing/prometheus_trace.rb', line 58 def active?(keyword) @trace.prometheus_keys_whitelist.include?(keyword) end |
#gettime ⇒ Object
62 63 64 |
# File 'lib/graphql/tracing/prometheus_trace.rb', line 62 def gettime ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) end |
#instrument(keyword, object) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/graphql/tracing/prometheus_trace.rb', line 46 def instrument(keyword, object) if active?(keyword) start = gettime result = yield duration = gettime - start send_json(duration, keyword, object) result else yield end end |
#send_json(duration, keyword, object) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/graphql/tracing/prometheus_trace.rb', line 66 def send_json(duration, keyword, object) event_name = name_for(keyword, object) @trace.prometheus_client.send_json( type: @trace.prometheus_collector_type, duration: duration, platform_key: event_name, key: keyword ) end |