Skip to content

Commit

Permalink
fix: metrics docker fix (#216)
Browse files Browse the repository at this point in the history
* fix: Expose ports instead of using host network mode

* fix: Decrement the concurrent request count on all exit points
  • Loading branch information
petarvujovic98 authored May 17, 2024
1 parent 57d7fa6 commit 86bbc55
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
6 changes: 4 additions & 2 deletions docker/docker-compose.metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ services:
volumes:
- './monitoring/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml'
- 'prometheus_storage:/prometheus'
network_mode: "host"
ports:
- "9090:9090"
extra_hosts:
- 'host.docker.internal:host-gateway'
grafana:
image: grafana/grafana:latest
container_name: grafana
restart: unless-stopped
network_mode: "host"
ports:
- "3000:3000"
volumes:
- 'grafana_storage:/var/lib/grafana'
volumes:
Expand Down
22 changes: 14 additions & 8 deletions host/src/server/api/v1/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ fn set_cached_input(
Ok(())
}

fn dec_concurrent_req_count(e: HostError) -> HostError {
dec_current_req();
e
}

#[utoipa::path(post, path = "/proof",
tag = "Proving",
request_body = ProofRequestOpt,
Expand All @@ -82,13 +87,10 @@ async fn proof_handler(
// Override the existing proof request config from the config file and command line
// options with the request from the client.
let mut config = opts.proof_request_opt.clone();
config.merge(&req)?;
config.merge(&req).map_err(dec_concurrent_req_count)?;

// Construct the actual proof request from the available configs.
let proof_request = ProofRequest::try_from(config).map_err(|e| {
dec_current_req();
e
})?;
let proof_request = ProofRequest::try_from(config).map_err(dec_concurrent_req_count)?;
inc_host_req_count(proof_request.block_number);

info!(
Expand Down Expand Up @@ -116,15 +118,19 @@ async fn proof_handler(
memory::reset_stats();
let measurement = Measurement::start("Generating input...", false);
let provider =
RpcBlockDataProvider::new(&proof_request.rpc.clone(), proof_request.block_number - 1)?;
let input = raiko.generate_input(provider).await?;
RpcBlockDataProvider::new(&proof_request.rpc.clone(), proof_request.block_number - 1)
.map_err(dec_concurrent_req_count)?;
let input = raiko
.generate_input(provider)
.await
.map_err(dec_concurrent_req_count)?;
let input_time = measurement.stop_with("=> Input generated");
observe_prepare_input_time(proof_request.block_number, input_time, true);
memory::print_stats("Input generation peak memory used: ");
input
};
memory::reset_stats();
let output = raiko.get_output(&input)?;
let output = raiko.get_output(&input).map_err(dec_concurrent_req_count)?;
memory::print_stats("Guest program peak memory used: ");

memory::reset_stats();
Expand Down

0 comments on commit 86bbc55

Please sign in to comment.