Skip to content

Commit

Permalink
add label with mint status
Browse files Browse the repository at this point in the history
  • Loading branch information
mpwsh committed Sep 13, 2023
1 parent 7733455 commit 65e7901
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions api/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use hub_core::{
chrono::{DateTime, NaiveDateTime, Offset, Utc},
credits::{CreditsClient, TransactionId},
metrics::KeyValue,
prelude::*,
producer::Producer,
thiserror,
Expand Down Expand Up @@ -775,15 +776,6 @@ impl Processor {
let mut creation_status = NftCreationStatus::Completed;

if let MintResult::Success(MintTransaction { signature, address }) = payload {
let now = Utc::now();
let elapsed_millis = now
.signed_duration_since(collection_mint.created_at)
.num_milliseconds();

self.metrics
.mint_duration_ms_bucket
.record(elapsed_millis, &[]);

mint_history_am.status = Set(CreationStatus::Created);
mint_history_am.tx_signature = Set(Some(signature.clone()));
collection_mint_active_model.creation_status = Set(CreationStatus::Created);
Expand All @@ -803,6 +795,15 @@ impl Processor {
creation_status = NftCreationStatus::Failed;
}

let now = Utc::now();
let elapsed = now
.signed_duration_since(collection_mint.created_at)
.num_milliseconds();
self.metrics.mint_duration_ms_bucket.record(
elapsed,
&[KeyValue::new("status", creation_status.as_str_name())],
);

self.producer
.send(
Some(&NftEvents {
Expand Down

0 comments on commit 65e7901

Please sign in to comment.