Strata - Observability

Observability stack for Zcash Stratum V2.

Components

Prometheus Metrics

use bedrock_strata::{PoolMetrics, start_metrics_server};
use std::sync::Arc;
use std::net::SocketAddr;

let metrics = Arc::new(PoolMetrics::new());
metrics.record_connection();
metrics.record_share_accepted();

// Start HTTP server on :9090/metrics
let addr: SocketAddr = "0.0.0.0:9090".parse().unwrap();
tokio::spawn(start_metrics_server(addr, metrics));

Structured Logging

use bedrock_strata::{init_logging, LogFormat};

// Development (pretty-printed)
init_logging(LogFormat::Pretty, "info");

// Production (JSON for log aggregation)
init_logging(LogFormat::Json, "info");

Distributed Tracing

use bedrock_strata::{init_tracing, TracingConfig};

let config = TracingConfig {
    service_name: "zcash-pool".into(),
    otlp_endpoint: Some("http://localhost:4317".into()),
    sampling_ratio: 0.1,
};
init_tracing(config)?;

Metrics Exposed

MetricTypeDescription
bedrock_pool_connections_totalCounterTotal miner connections
bedrock_pool_connections_activeGaugeActive miner connections
bedrock_pool_jd_connections_totalCounterTotal JD connections
bedrock_pool_jd_connections_activeGaugeActive JD connections
bedrock_pool_shares_submitted_totalCounterShares by difficulty tier
bedrock_pool_shares_accepted_totalCounterAccepted shares
bedrock_pool_shares_rejected_totalCounterRejected shares by reason
bedrock_pool_blocks_found_totalCounterBlocks found
bedrock_pool_blocks_submitted_totalCounterBlocks submitted
bedrock_pool_estimated_hashrateGaugePool hashrate (H/s)
bedrock_pool_share_validation_duration_secondsHistogramShare validation latency
bedrock_pool_template_fetch_duration_secondsHistogramTemplate fetch latency
bedrock_pool_noise_handshakes_totalCounterNoise handshakes initiated
bedrock_pool_noise_handshakes_failed_totalCounterFailed Noise handshakes

HTTP Endpoints

  • /metrics - Prometheus metrics in text format
  • /health - Health check endpoint returning JSON status

License

MIT OR Apache-2.0