diff --git a/Dockerfile b/Dockerfile index 89d4ce1..9c719e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,11 +27,11 @@ COPY Cargo.toml build.rs ./ COPY src ./src ENV RUST_BACKTRACE=full -RUN cargo build +RUN cargo build --release --bins ## Pre-generate some configurations we can use # TOOD: consider doing something different here -RUN target/debug/setup_local_testnet +RUN target/release/setup_local_testnet ################################################################################# @@ -54,7 +54,12 @@ EOF WORKDIR /app COPY --from=builder /usr/src/app/src/proto /app/proto COPY --from=builder /usr/src/app/nodes /app/nodes -COPY --from=builder /usr/src/app/target/debug/snapchain /app/ +COPY --from=builder \ + /usr/src/app/target/release/snapchain \ + /usr/src/app/target/release/follow_blocks \ + /usr/src/app/target/release/setup_local_testnet \ + /usr/src/app/target/release/submit_message \ + /app/ ENV RUSTFLAGS="-Awarnings" CMD ["./snapchain", "--id", "1"] diff --git a/src/storage/store/engine.rs b/src/storage/store/engine.rs index 1117517..b1a109b 100644 --- a/src/storage/store/engine.rs +++ b/src/storage/store/engine.rs @@ -420,6 +420,18 @@ impl ShardEngine { self.events_tx.send(event); } self.trie.reload(&self.db).unwrap(); + + self.emit_commit_metrics(&shard_chunk); + + match self.shard_store.put_shard_chunk(shard_chunk) { + Err(err) => { + error!("Unable to write shard chunk to store {}", err) + } + Ok(()) => {} + } + } + + fn emit_commit_metrics(&mut self, shard_chunk: &&ShardChunk) -> Result<(), EngineError> { self.statsd_client .count_with_shard(self.shard_id, "commit", 1); @@ -430,14 +442,45 @@ impl ShardEngine { .height .unwrap() .block_number; + self.statsd_client .gauge_with_shard(self.shard_id, "block_height", *block_number); - match self.shard_store.put_shard_chunk(shard_chunk) { - Err(err) => { - error!("Unable to write shard chunk to store {}", err) - } - Ok(()) => {} - } + + let trie_size = self.trie.items()?; + + self.statsd_client + .gauge_with_shard(self.shard_id, "trie.num_items", trie_size as u64); + + let (user_count, system_count) = + shard_chunk + .transactions + .iter() + .fold((0, 0), |(user_count, system_count), tx| { + ( + user_count + tx.user_messages.len(), + system_count + tx.system_messages.len(), + ) + }); + + self.statsd_client.count_with_shard( + self.shard_id, + "committed_transactions", + shard_chunk.transactions.len() as u64, + ); + + self.statsd_client.count_with_shard( + self.shard_id, + "committed_user_messages", + user_count as u64, + ); + + self.statsd_client.count_with_shard( + self.shard_id, + "committed_system_messages", + system_count as u64, + ); + + Ok(()) } pub fn commit_shard_chunk(&mut self, shard_chunk: &ShardChunk) {