Skip to content

Commit

Permalink
feat(si): Ensure we capture the name of the containe engine when trac…
Browse files Browse the repository at this point in the history
…king usage
  • Loading branch information
stack72 committed Aug 23, 2023
1 parent 8a42363 commit e6fac8a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/si-cli/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub mod podman_engine;

#[async_trait]
pub trait ContainerEngine {
fn get_engine_identifier(&self) -> String;
async fn ping(&self) -> CliResult<()>;
async fn missing_containers(&self) -> Result<Vec<String>, SiCliError>;
async fn download_missing_containers(&self, missing_containers: Vec<String>) -> CliResult<()>;
Expand Down
4 changes: 4 additions & 0 deletions lib/si-cli/src/engine/docker_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ impl DockerEngine {

#[async_trait]
impl ContainerEngine for DockerEngine {
fn get_engine_identifier(&self) -> String {
"docker".to_string()
}

async fn ping(&self) -> CliResult<()> {
self.docker.ping().await?;
Ok(())
Expand Down
4 changes: 4 additions & 0 deletions lib/si-cli/src/engine/podman_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ impl PodmanEngine {

#[async_trait]
impl ContainerEngine for PodmanEngine {
fn get_engine_identifier(&self) -> String {
"podman".to_string()
}

async fn ping(&self) -> CliResult<()> {
let ping_info = self.podman.ping().await?;
dbg!(&ping_info);
Expand Down
4 changes: 4 additions & 0 deletions lib/si-cli/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ impl AppState {
prop_map.insert("mode".to_string(), serde_json::json!(self.mode()));
prop_map.insert("os".to_string(), serde_json::json!(env::consts::OS));
prop_map.insert("arch".to_string(), serde_json::json!(env::consts::ARCH));
prop_map.insert(
"container_engine".to_string(),
serde_json::json!(self.container_engine().get_engine_identifier()),
);

ph_client
.capture("si-command", distinct_id, properties)
Expand Down

0 comments on commit e6fac8a

Please sign in to comment.