Skip to content

Commit

Permalink
feat: setup otlp prometheus exporter with correct invocation in node
Browse files Browse the repository at this point in the history
  • Loading branch information
Icarus131 committed Mar 7, 2025
1 parent 9cedb2a commit 8760186
Show file tree
Hide file tree
Showing 10 changed files with 377 additions and 107 deletions.
96 changes: 82 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions docker/compose/movement-full-node/docker-compose.telemetry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
services:
prometheus:
image: prom/prometheus:v2.49.1
container_name: movement-prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:9090/-/healthy || exit 1
interval: 5s
timeout: 3s
retries: 3

grafana:
image: grafana/grafana:10.2.3
container_name: movement-grafana
ports:
- "3000:3000"
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning
- ./grafana/dashboards:/var/lib/grafana/dashboards
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
depends_on:
- prometheus

movement-full-node:
environment:
- MOVEMENT_METRICS_ADDR=0.0.0.0:9464
- MOVEMENT_OTLP=http://otel-collector:4317
ports:
- "9464:9464"
depends_on:
- prometheus:
condition: service_healthy
- otel-collector:
condition: service_healthy

movement-celestia-da-light-node:
environment:
- MOVEMENT_METRICS_ADDR=0.0.0.0:9464
- MOVEMENT_OTLP=http://otel-collector:4317
ports:
- "9465:9464"
depends_on:
- prometheus:
condition: service_healthy
- otel-collector:
condition: service_healthy

otel-collector:
image: otel/opentelemetry-collector:0.96.0
container_name: movement-otel-collector
command: ["--config=/etc/otel-collector-config.yaml"]
volumes:
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
ports:
- "4317:4317" # OTLP gRPC
- "4318:4318" # OTLP HTTP
- "8888:8888" # Prometheus metrics exposed by the collector
- "8889:8889" # Prometheus exporter metrics
- "13133:13133" # Health check extension
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:13133 || exit 1
interval: 5s
timeout: 3s
retries: 3

volumes:
prometheus_data:
37 changes: 37 additions & 0 deletions docker/compose/movement-full-node/otel-collector-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318

processors:
batch:
timeout: 1s
send_batch_size: 1024

exporters:
prometheus:
endpoint: "0.0.0.0:8889"
namespace: "movement"
const_labels:
label1: value1
logging:
loglevel: debug

extensions:
health_check:
endpoint: 0.0.0.0:13133

service:
extensions: [health_check]
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [logging]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [prometheus, logging]
21 changes: 21 additions & 0 deletions docker/compose/movement-full-node/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
global:
scrape_interval: 15s
evaluation_interval: 15s

scrape_configs:
- job_name: 'movement-full-node'
static_configs:
- targets: ['movement-full-node:9464']
metrics_path: /
scheme: http

- job_name: 'movement-celestia-da-light-node'
static_configs:
- targets: ['movement-celestia-da-light-node:9464']
metrics_path: /
scheme: http

- job_name: 'otel-collector'
static_configs:
- targets: ['otel-collector:8889']
metrics_path: /metrics
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ use tokio::sync::RwLock;
use tracing::info;
use url::Url;

const TIMING_LOG_ENV: &str = "SUZUKA_TIMING_LOG";

pub fn get_movement_config(
dot_movement: &DotMovement,
) -> Result<movement_config::Config, anyhow::Error> {
Expand Down Expand Up @@ -393,22 +391,14 @@ pub async fn basic_coin_transfers(

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let tracing_config = movement_tracing::Config {
timing_log_path: std::env::var_os(TIMING_LOG_ENV).map(Into::into),
};
// Initialize metrics with a unique port for the test
let tracing_config = movement_tracing::Config::with_metrics_addr("0.0.0.0:9466");
let _guard = movement_tracing::init_tracing_subscriber(tracing_config);

// get the lead dot movement from the environment
let dot_movement = DotMovement::try_from_env()?;
let config = get_movement_config(&dot_movement)?;

// get the follower count from the first argument
let follower_count = std::env::args()
.nth(1)
.ok_or_else(|| anyhow::anyhow!("Expected follower count as first argument"))?;
let follower_count = u8::from_str(follower_count.as_str())?;

// run basic coin transfers
basic_coin_transfers(&dot_movement, follower_count).await?;
basic_coin_transfers(&dot_movement, 2).await?;

Ok(())
}
15 changes: 6 additions & 9 deletions networks/movement/movement-full-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

use clap::*;
use movement_full_node::MovementFullNode;
const TIMING_LOG_ENV: &str = "SUZUKA_TIMING_LOG";
use std::env;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let tracing_config =
movement_tracing::Config { timing_log_path: env::var_os(TIMING_LOG_ENV).map(Into::into) };
let _guard = movement_tracing::init_tracing_subscriber(tracing_config);
let tracing_config = movement_tracing::Config::with_metrics_addr("0.0.0.0:9464");
let _guard = movement_tracing::init_tracing_subscriber(tracing_config);

let suzuka_util = MovementFullNode::parse();
let suzuka_util = MovementFullNode::parse();
suzuka_util.execute().await?;

suzuka_util.execute().await?;

Ok(())
Ok(())
}

33 changes: 33 additions & 0 deletions process-compose/movement-full-node/process-compose.telemetry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: "3"

environment:

processes:
prometheus:
is_daemon: true
command: |
docker run -d --rm --name movement-prometheus \
-p 9090:9090 \
-v ${PWD}/docker/compose/movement-full-node/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus:v2.49.1
shutdown:
command: |
docker stop movement-prometheus
readiness_probe:
initial_delay_seconds: 3
exec:
command: wget --no-verbose --tries=1 --spider http://localhost:9090/-/healthy || exit 1

movement-full-node:
depends_on:
prometheus:
condition: process_started
environment:
- MOVEMENT_METRICS_ADDR=0.0.0.0:9464

movement-celestia-da-light-node:
depends_on:
prometheus:
condition: process_started
environment:
- MOVEMENT_METRICS_ADDR=0.0.0.0:9465
7 changes: 1 addition & 6 deletions protocol-units/da/movement/protocol/light-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ use movement_da_light_node_verifier::signed::InKnownSignersVerifier;
use movement_signer::cryptography::secp256k1::Secp256k1;
use movement_signer_loader::LoadedSigner;

use std::env;

const TIMING_LOG_ENV: &str = "MOVEMENT_DA_LIGHT_NODE_TIMING_LOG";

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let tracing_config =
movement_tracing::Config { timing_log_path: env::var_os(TIMING_LOG_ENV).map(Into::into) };
let tracing_config = movement_tracing::Config::with_metrics_addr("0.0.0.0:9464");
let _guard = movement_tracing::init_tracing_subscriber(tracing_config);

let dot_movement = dot_movement::DotMovement::try_from_env()?;
Expand Down
Loading

0 comments on commit 8760186

Please sign in to comment.