11// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
22// SPDX-License-Identifier: Apache-2.0
33
4- use std:: str:: FromStr ;
4+ use std:: { str:: FromStr , sync :: LazyLock } ;
55
66use async_graphql:: { Context , EmptyMutation , EmptySubscription , Object , Schema , SimpleObject } ;
7- use lazy_static:: lazy_static;
87use prometheus:: {
98 register_counter, register_counter_vec, register_histogram, register_histogram_vec, Counter ,
109 CounterVec , Histogram , HistogramVec ,
@@ -16,45 +15,57 @@ use thegraph_core::DeploymentId;
1615
1716use crate :: database:: cost_model:: { self , CostModel } ;
1817
19- lazy_static ! {
20- pub static ref COST_MODEL_METRIC : HistogramVec = register_histogram_vec!(
18+ pub static COST_MODEL_METRIC : LazyLock < HistogramVec > = LazyLock :: new ( || {
19+ register_histogram_vec ! (
2120 "indexer_cost_model_seconds" ,
2221 "Histogram metric for single cost model query" ,
2322 & [ "deployment" ]
2423 )
25- . unwrap( ) ;
26- pub static ref COST_MODEL_FAILED : CounterVec = register_counter_vec!(
24+ . unwrap ( )
25+ } ) ;
26+ pub static COST_MODEL_FAILED : LazyLock < CounterVec > = LazyLock :: new ( || {
27+ register_counter_vec ! (
2728 "indexer_cost_model_failed_total" ,
2829 "Total failed Cost Model query" ,
2930 & [ "deployment" ]
3031 )
31- . unwrap( ) ;
32- pub static ref COST_MODEL_INVALID : Counter = register_counter!(
32+ . unwrap ( )
33+ } ) ;
34+ pub static COST_MODEL_INVALID : LazyLock < Counter > = LazyLock :: new ( || {
35+ register_counter ! (
3336 "indexer_cost_model_invalid_total" ,
3437 "Cost model queries with invalid deployment id" ,
3538 )
36- . unwrap( ) ;
37- pub static ref COST_MODEL_BATCH_METRIC : Histogram = register_histogram!(
39+ . unwrap ( )
40+ } ) ;
41+ pub static COST_MODEL_BATCH_METRIC : LazyLock < Histogram > = LazyLock :: new ( || {
42+ register_histogram ! (
3843 "indexer_cost_model_batch_seconds" ,
3944 "Histogram metric for batch cost model query" ,
4045 )
41- . unwrap( ) ;
42- pub static ref COST_MODEL_BATCH_SIZE : Histogram = register_histogram!(
46+ . unwrap ( )
47+ } ) ;
48+ pub static COST_MODEL_BATCH_SIZE : LazyLock < Histogram > = LazyLock :: new ( || {
49+ register_histogram ! (
4350 "indexer_cost_model_batch_size" ,
4451 "This shows the size of deployment ids cost model batch queries got" ,
4552 )
46- . unwrap( ) ;
47- pub static ref COST_MODEL_BATCH_FAILED : Counter = register_counter!(
53+ . unwrap ( )
54+ } ) ;
55+ pub static COST_MODEL_BATCH_FAILED : LazyLock < Counter > = LazyLock :: new ( || {
56+ register_counter ! (
4857 "indexer_cost_model_batch_failed_total" ,
4958 "Total failed batch cost model queries" ,
5059 )
51- . unwrap( ) ;
52- pub static ref COST_MODEL_BATCH_INVALID : Counter = register_counter!(
60+ . unwrap ( )
61+ } ) ;
62+ pub static COST_MODEL_BATCH_INVALID : LazyLock < Counter > = LazyLock :: new ( || {
63+ register_counter ! (
5364 "indexer_cost_model_batch_invalid_total" ,
5465 "Batch cost model queries with invalid deployment ids" ,
5566 )
56- . unwrap( ) ;
57- }
67+ . unwrap ( )
68+ } ) ;
5869
5970#[ derive( Clone , Debug , Serialize , Deserialize , SimpleObject ) ]
6071pub struct GraphQlCostModel {
0 commit comments