Skip to content

Commit

Permalink
fix: CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Sep 22, 2024
1 parent 9128ff0 commit 6f159ec
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
6 changes: 5 additions & 1 deletion src/cli/tc/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ pub async fn run() -> Result<()> {
.await;

// Dispatch the command as an event
let _ = TRACKER.dispatch(tailcall_tracker::EventKind::Run).await;
let _ = TRACKER
.dispatch(tailcall_tracker::EventKind::Command(
cli.command.to_string(),
))
.await;

run_command(cli, config_reader, runtime).await
}
Expand Down
11 changes: 7 additions & 4 deletions tailcall-tracker/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct Event {
pub cores: usize,
pub client_id: String,
pub os_name: String,
pub up_time: Option<String>,
pub up_time: i64,
pub path: Option<String>,
pub cwd: Option<String>,
pub user: String,
Expand All @@ -20,11 +20,14 @@ pub struct Event {
#[derive(Clone, IntoStaticStr)]
pub enum EventKind {
Ping,
Run,
Command(String),
}

impl EventKind {
pub fn as_str(&self) -> &'static str {
self.into()
pub fn to_string(&self) -> String {

Check failure on line 27 in tailcall-tracker/src/event.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

implementation of inherent method `to_string(&self) -> String` for type `event::EventKind`
match self {
Self::Ping => "ping".to_string(),
Self::Command(name) => name.clone(),
}
}
}
20 changes: 5 additions & 15 deletions tailcall-tracker/src/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ impl Tracker {
if self.is_tracking {
// Create a new event
let event = Event {
event_name: event_kind.as_str().to_string(),
event_name: event_kind.to_string().to_string(),
start_time: self.start_time,
cores: cores(),
client_id: client_id(),
os_name: os_name(),
up_time: self.up_time(event_kind),
up_time: up_time(self.start_time),
args: args(),
path: path(),
cwd: cwd(),
Expand All @@ -87,13 +87,6 @@ impl Tracker {

Ok(())
}

fn up_time(&self, event_kind: EventKind) -> Option<String> {
match event_kind {
EventKind::Ping => Some(get_uptime(self.start_time)),
_ => None,
}
}
}

// Generates a random client ID
Expand All @@ -114,12 +107,9 @@ fn cores() -> usize {
}

// Get the uptime in minutes
fn get_uptime(start_time: DateTime<Utc>) -> String {
fn up_time(start_time: DateTime<Utc>) -> i64 {
let current_time = Utc::now();
format!(
"{} minutes",
current_time.signed_duration_since(start_time).num_minutes()
)
current_time.signed_duration_since(start_time).num_minutes()
}

fn version() -> String {
Expand Down Expand Up @@ -162,7 +152,7 @@ mod tests {

Check warning on line 152 in tailcall-tracker/src/tracker.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/tailcall-tracker/src/tracker.rs
#[tokio::test]
async fn test_tracker() {
if let Err(e) = TRACKER.dispatch(EventKind::Run).await {
if let Err(e) = TRACKER.dispatch(EventKind::Command("ping".to_string())).await {
panic!("Tracker dispatch error: {:?}", e);
}
}
Expand Down

1 comment on commit 6f159ec

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running 30s test @ http://localhost:8000/graphql

4 threads and 100 connections

Thread Stats Avg Stdev Max +/- Stdev
Latency 11.56ms 4.38ms 122.33ms 86.71%
Req/Sec 2.19k 261.35 2.97k 82.00%

262016 requests in 30.03s, 1.31GB read

Requests/sec: 8725.31

Transfer/sec: 44.78MB

Please sign in to comment.