From a3e981c875d73a3b7e92650ba0128608e4b2bc7d Mon Sep 17 00:00:00 2001 From: Omer Zidkoni <50792403+omerzi@users.noreply.github.com> Date: Tue, 21 Jan 2025 11:35:04 +0200 Subject: [PATCH] Restructure visibility metrics (#1073) --- jfconnect/services/metrics.go | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/jfconnect/services/metrics.go b/jfconnect/services/metrics.go index 847656755..2930e705a 100644 --- a/jfconnect/services/metrics.go +++ b/jfconnect/services/metrics.go @@ -2,16 +2,21 @@ package services import ( "encoding/json" - "net/http" - "github.com/jfrog/jfrog-client-go/auth" "github.com/jfrog/jfrog-client-go/http/jfroghttpclient" clientutils "github.com/jfrog/jfrog-client-go/utils" "github.com/jfrog/jfrog-client-go/utils/errorutils" + "net/http" ) const LogMetricApiEndpoint = "api/v1/backoffice/metrics/log" +type VisibilityMetric struct { + Value int `json:"value"` + Name string `json:"metrics_name"` + Labels any `json:"labels"` +} + type JfConnectService struct { client *jfroghttpclient.JfrogHttpClient serviceDetails *auth.ServiceDetails @@ -42,20 +47,3 @@ func (jcs *JfConnectService) PostVisibilityMetric(metric VisibilityMetric) error } return errorutils.CheckResponseStatusWithBody(resp, body, http.StatusCreated, http.StatusOK) } - -type Labels struct { - ProductID string `json:"product_id"` - ProductVersion string `json:"product_version"` - FeatureID string `json:"feature_id"` - OIDCUsed string `json:"oidc_used"` - JobID string `json:"job_id"` - RunID string `json:"run_id"` - GitRepo string `json:"git_repo"` - GhTokenForCodeScanningAlertsProvided string `json:"gh_token_for_code_scanning_alerts_provided"` -} - -type VisibilityMetric struct { - Value int `json:"value"` - MetricsName string `json:"metrics_name"` - Labels Labels `json:"labels"` -}