diff --git a/client/pkg/clickhouse/db_client.go b/client/pkg/clickhouse/db_client.go index 1c156a5d..b532d7d8 100644 --- a/client/pkg/clickhouse/db_client.go +++ b/client/pkg/clickhouse/db_client.go @@ -1035,85 +1035,6 @@ func (c *DBClient) InsertTrivySbomMetrics(metrics model.Sbom) { stmt.Close() } -// func (c *DBClient) InsertTrivySbomMetrics(metrics model.Sbom) { -// //opentelemetry -// opentelconfig, err := opentelemetry.GetConfigurations() -// if err != nil { -// log.Println("Unable to read open telemetry configurations") -// } -// if opentelconfig.IsEnabled { -// ctx := context.Background() -// tracer := otel.Tracer("insert-trivy-sbom") -// _, span := tracer.Start(opentelemetry.BuildContext(ctx), "InsertTrivySbomMetrics") -// defer span.End() -// } - -// tx, err := c.conn.Begin() -// if err != nil { -// log.Fatalf("error beginning transaction, clickhouse connection not available: %v", err) -// } -// stmt, err := tx.Prepare(InsertTrivySbom) -// if err != nil { -// log.Fatalf("error preparing statement: %v", err) -// } - -// data := metrics.Report -// bomComponents, ok := data["components"].([]interface{}) -// if !ok { -// log.Println("error: components not found or not in expected format") -// } -// var componentName, bomRef, serialNumber, bomFormat, purl, componentType string -// var version int32 -// // Iterate over the components to find the desired name -// for _, component := range bomComponents { -// componentMap, ok := component.(map[string]interface{}) -// if !ok { -// log.Println("error: component not in expected format") -// continue -// } -// if name, ok := componentMap["name"].(string); ok { -// componentName = name -// break -// } -// } -// metadata, ok := data["metadata"].(map[string]interface{}) -// if !ok { -// log.Println("error: metadata not found or not in expected format") -// return -// } - -// component, ok := metadata["component"].(map[string]interface{}) -// if !ok { -// log.Println("error: component not found or not in expected format") -// return -// } - -// bomRef, _ = component["bom-ref"].(string) -// purl, _ = component["purl"].(string) -// componentType, _ = component["type"].(string) - -// serialNumber, _ = data["serialNumber"].(string) -// version, _ = data["version"].(int32) -// bomFormat, _ = data["bomFormat"].(string) - -// if _, err := stmt.Exec( -// metrics.ID, -// metrics.ClusterName, -// componentName, -// componentType, -// purl, -// bomRef, -// serialNumber, -// int32(version), -// bomFormat, -// ); err != nil { -// log.Fatal(err) -// } -// if err := tx.Commit(); err != nil { -// log.Fatal(err) -// } -// stmt.Close() -// } func (c *DBClient) Close() { _ = c.conn.Close() }