Class: GraphQL::Tracing::PrometheusTrace::GraphQLCollector
- Inherits:
-
PrometheusExporter::Server::TypeCollector
- Object
- PrometheusExporter::Server::TypeCollector
- GraphQL::Tracing::PrometheusTrace::GraphQLCollector
- Defined in:
- lib/graphql/tracing/prometheus_trace/graphql_collector.rb
Instance Method Summary collapse
- #collect(object) ⇒ Object
-
#initialize ⇒ GraphQLCollector
constructor
A new instance of GraphQLCollector.
- #metrics ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize ⇒ GraphQLCollector
Returns a new instance of GraphQLCollector.
9 10 11 12 13 14 |
# File 'lib/graphql/tracing/prometheus_trace/graphql_collector.rb', line 9 def initialize @graphql_gauge = PrometheusExporter::Metric::Base.default_aggregation.new( 'graphql_duration_seconds', 'Time spent in GraphQL operations, in seconds' ) end |
Instance Method Details
#collect(object) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/graphql/tracing/prometheus_trace/graphql_collector.rb', line 20 def collect(object) default_labels = { key: object['key'], platform_key: object['platform_key'] } custom = object['custom_labels'] labels = custom.nil? ? default_labels : default_labels.merge(custom) @graphql_gauge.observe object['duration'], labels end |
#metrics ⇒ Object
28 29 30 |
# File 'lib/graphql/tracing/prometheus_trace/graphql_collector.rb', line 28 def metrics [@graphql_gauge] end |
#type ⇒ Object
16 17 18 |
# File 'lib/graphql/tracing/prometheus_trace/graphql_collector.rb', line 16 def type 'graphql' end |