class GraphQL::Tracing::PrometheusTracing
Constants
- DEFAULT_COLLECTOR_TYPE
- DEFAULT_WHITELIST
Public Class Methods
new(opts = {})
click to toggle source
Calls superclass method
GraphQL::Tracing::PlatformTracing::new
# File lib/graphql/tracing/prometheus_tracing.rb, line 22 def initialize(opts = {}) @client = opts[:client] || PrometheusExporter::Client.default @keys_whitelist = opts[:keys_whitelist] || DEFAULT_WHITELIST @collector_type = opts[:collector_type] || DEFAULT_COLLECTOR_TYPE super opts end
Public Instance Methods
platform_field_key(type, field)
click to toggle source
# File lib/graphql/tracing/prometheus_tracing.rb, line 35 def platform_field_key(type, field) "#{type.name}.#{field.name}" end
platform_trace(platform_key, key, data) { || ... }
click to toggle source
# File lib/graphql/tracing/prometheus_tracing.rb, line 30 def platform_trace(platform_key, key, data, &block) return yield unless @keys_whitelist.include?(key) instrument_execution(platform_key, key, data, &block) end
Private Instance Methods
instrument_execution(platform_key, key, data, &block)
click to toggle source
# File lib/graphql/tracing/prometheus_tracing.rb, line 41 def instrument_execution(platform_key, key, data, &block) start = ::Process.clock_gettime ::Process::CLOCK_MONOTONIC result = block.call duration = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start observe platform_key, key, duration result end
observe(platform_key, key, duration)
click to toggle source
# File lib/graphql/tracing/prometheus_tracing.rb, line 49 def observe(platform_key, key, duration) @client.send_json( type: @collector_type, duration: duration, platform_key: platform_key, key: key ) end