pub fn new<S: Into<String>>(
        for_agent: S,
        listen_port: Option<u16>,
        registry: Arc<Registry>,
    ) -> prometheus::Result<CoreMetrics> {
        let metrics = CoreMetrics {
            agent_name: for_agent.into(),
            transactions: Box::new(IntGaugeVec::new(
                Opts::new(
                    "transactions_total",
                    "Number of transactions sent by this agent since boot",
                )
                .namespace("optics")
                .const_label("VERSION", env!("CARGO_PKG_VERSION")),
                &["chain", "wallet", "agent"],
            )?),
            wallet_balance: Box::new(IntGaugeVec::new(
                Opts::new(
                    "wallet_balance_total",
                    "Balance of the smart contract wallet",
                )
                .namespace("optics")
                .const_label("VERSION", env!("CARGO_PKG_VERSION")),
                &["chain", "wallet", "agent"],
            )?),
            rpc_latencies: Box::new(HistogramVec::new(
                HistogramOpts::new(
                    "rpc_duration_ms",
                    "Duration from dispatch to receipt-of-response for RPC calls",
                )
                .namespace("optics")
                .const_label("VERSION", env!("CARGO_PKG_VERSION")),
                &["chain", "method", "agent"],
            )?),
            span_durations: Box::new(HistogramVec::new(
                HistogramOpts::new(
                    "span_duration_sec",
                    "Duration from span creation to span destruction",
                )
                .namespace("optics")
                .const_label("VERSION", env!("CARGO_PKG_VERSION")),
                &["span_name", "target"],
            )?),
            registry,
            listen_port,
        };

        // TODO: only register these if they aren't already registered?

        metrics.registry.register(metrics.transactions.clone())?;
        metrics.registry.register(metrics.wallet_balance.clone())?;
        metrics.registry.register(metrics.rpc_latencies.clone())?;
        metrics.registry.register(metrics.span_durations.clone())?;

        Ok(metrics)
    }
/// Track metrics for a particular agent name.
Track metrics for a particular agent name.
Track metrics for a particular agent name .
pub fn new<S: Into<String>>(
        for_agent: S,
        listen_port: Option<u16>,
        registry: Arc<Registry>,
    ) -> prometheus::Result<CoreMetrics> {
        let metrics = CoreMetrics {
            agent_name: for_agent.into(),
            transactions: Box::new(IntGaugeVec::new(
                Opts::new(
                    "transactions_total",
                    "Number of transactions sent by this agent since boot",
                )
                .namespace("optics")
                .const_label("VERSION", env!("CARGO_PKG_VERSION")),
                &["chain", "wallet", "agent"],
            )?),
            wallet_balance: Box::new(IntGaugeVec::new(
                Opts::new(
                    "wallet_balance_total",
                    "Balance of the smart contract wallet",
                )
                .namespace("optics")
                .const_label("VERSION", env!("CARGO_PKG_VERSION")),
                &["chain", "wallet", "agent"],
            )?),
            rpc_latencies: Box::new(HistogramVec::new(
                HistogramOpts::new(
                    "rpc_duration_ms",
                    "Duration from dispatch to receipt-of-response for RPC calls",
                )
                .namespace("optics")
                .const_label("VERSION", env!("CARGO_PKG_VERSION")),
                &["chain", "method", "agent"],
            )?),
            span_durations: Box::new(HistogramVec::new(
                HistogramOpts::new(
                    "span_duration_sec",
                    "Duration from span creation to span destruction",
                )
                .namespace("optics")
                .const_label("VERSION", env!("CARGO_PKG_VERSION")),
                &["span_name", "target"],
            )?),
            registry,
            listen_port,
        };
        // TODO: only register these if they aren't already registered?
        metrics.registry.register(metrics.transactions.clone())?;
        metrics.registry.register(metrics.wallet_balance.clone())?;
        metrics.registry.register(metrics.rpc_latencies.clone())?;
        metrics.registry.register(metrics.span_durations.clone())?;
        Ok(metrics)
    }
pub fn new < S : Into < String > > ( for_agent : S , listen_port : Option < u16 > , registry : Arc < Registry > , ) -> prometheus :: Result < CoreMetrics > { let metrics = CoreMetrics { agent_name : for_agent . into ( ) , transactions : Box :: new ( IntGaugeVec :: new ( Opts :: new ( " " , " " , ) . namespace ( " " ) . const_label ( " " , env ! ( " " ) ) , & [ " " , " " , " " ] , ) ? ) , wallet_balance : Box :: new ( IntGaugeVec :: new ( Opts :: new ( " " , " " , ) . namespace ( " " ) . const_label ( " " , env ! ( " " ) ) , & [ " " , " " , " " ] , ) ? ) , rpc_latencies : Box :: new ( HistogramVec :: new ( HistogramOpts :: new ( " " , " " , ) . namespace ( " " ) . const_label ( " " , env ! ( " " ) ) , & [ " " , " " , " " ] , ) ? ) , span_durations : Box :: new ( HistogramVec :: new ( HistogramOpts :: new ( " " , " " , ) . namespace ( " " ) . const_label ( " " , env ! ( " " ) ) , & [ " " , " " ] , ) ? ) , registry , listen_port , } ; // TODO: only register these if they aren't already registered? metrics . registry . register ( metrics . transactions . clone ( ) ) ? ; metrics . registry . register ( metrics . wallet_balance . clone ( ) ) ? ; metrics . registry . register ( metrics . rpc_latencies . clone ( ) ) ? ; metrics . registry . register ( metrics . span_durations . clone ( ) ) ? ; Ok ( metrics ) }
Track metrics for a particular agent name.
Track metrics for a particular agent name .
for_agent
S
listen_port
Option<u16>
registry
Arc<Registry>
for_agent
S
listen_port
Option<u16>
registry
Arc<Registry>