From e0554cba8537ec694aae85d3fafe06de3066fc06 Mon Sep 17 00:00:00 2001 From: eyalbe4 Date: Mon, 23 Dec 2024 18:59:51 +0200 Subject: [PATCH] Added product_id field to the visibility metric --- go.mod | 2 +- go.sum | 4 ++-- utils/usage/visibility_system_manager.go | 1 + utils/usage/visibility_system_manager_test.go | 9 +++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index ca3eae9a2..940b45df5 100644 --- a/go.mod +++ b/go.mod @@ -96,7 +96,7 @@ require ( gopkg.in/warnings.v0 v0.1.2 // indirect ) -// replace github.com/jfrog/jfrog-client-go => github.com/eyalbe4/jfrog-client-go v1.28.1-0.20241222155750-04d75d451f23 +replace github.com/jfrog/jfrog-client-go => github.com/eyalbe4/jfrog-client-go v1.28.1-0.20241223165051-2717483395bc // replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20241121100855-e7a75ceee2bd diff --git a/go.sum b/go.sum index 302de5215..4ad9a0961 100644 --- a/go.sum +++ b/go.sum @@ -51,6 +51,8 @@ github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcej github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +github.com/eyalbe4/jfrog-client-go v1.28.1-0.20241223165051-2717483395bc h1:VLvI2P75Fc8iJVrydKEMcmeBCcKeUHmB7lLEm5P8aYU= +github.com/eyalbe4/jfrog-client-go v1.28.1-0.20241223165051-2717483395bc/go.mod h1:2ySOMva54L3EYYIlCBYBTcTgqfrrQ19gtpA/MWfA/ec= github.com/forPelevin/gomoji v1.2.0 h1:9k4WVSSkE1ARO/BWywxgEUBvR/jMnao6EZzrql5nxJ8= github.com/forPelevin/gomoji v1.2.0/go.mod h1:8+Z3KNGkdslmeGZBC3tCrwMrcPy5GRzAD+gL9NAwMXg= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= @@ -93,8 +95,6 @@ github.com/jfrog/build-info-go v1.10.7 h1:10NVHYg0193gJpQft+S4WQfvYMtj5jlwwhJRvk github.com/jfrog/build-info-go v1.10.7/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE= github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s= github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4= -github.com/jfrog/jfrog-client-go v1.48.5 h1:q8v8oZ2HwwVw6+ZCwKbuIpUmxpWUeZzvTASQl/QKxKw= -github.com/jfrog/jfrog-client-go v1.48.5/go.mod h1:2ySOMva54L3EYYIlCBYBTcTgqfrrQ19gtpA/MWfA/ec= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= diff --git a/utils/usage/visibility_system_manager.go b/utils/usage/visibility_system_manager.go index e9053bf01..17fb6b6b6 100644 --- a/utils/usage/visibility_system_manager.go +++ b/utils/usage/visibility_system_manager.go @@ -22,6 +22,7 @@ func NewVisibilitySystemManager(serverDetails *config.ServerDetails) *Visibility func (vsm *VisibilitySystemManager) createMetric(commandName string) services.VisibilityMetric { metricLabels := services.Labels{ ProductID: coreutils.GetCliUserAgentName(), + ProductVersion: coreutils.GetCliUserAgentVersion(), FeatureID: commandName, OIDCUsed: os.Getenv("JFROG_CLI_USAGE_OIDC_USED"), JobID: os.Getenv("JFROG_CLI_USAGE_JOB_ID"), diff --git a/utils/usage/visibility_system_manager_test.go b/utils/usage/visibility_system_manager_test.go index bc27f4433..edcbbb62e 100644 --- a/utils/usage/visibility_system_manager_test.go +++ b/utils/usage/visibility_system_manager_test.go @@ -12,11 +12,11 @@ import ( func TestCreateMetric(t *testing.T) { // Set environment variables for the test using SetEnvWithCallbackAndAssert envVars := map[string]string{ - "JFROG_CLI_USAGE_OIDC_USED": "true", + "JFROG_CLI_USAGE_OIDC_USED": "TRUE", "JFROG_CLI_USAGE_JOB_ID": "job123", "JFROG_CLI_USAGE_RUN_ID": "run456", "JFROG_CLI_USAGE_GIT_REPO": "test-repo", - "JFROG_CLI_USAGE_GH_TOKEN_FOR_CODE_SCANNING_ALERTS_PROVIDED": "true", + "JFROG_CLI_USAGE_GH_TOKEN_FOR_CODE_SCANNING_ALERTS_PROVIDED": "TRUE", } cleanupFuncs := []func(){} for key, value := range envVars { @@ -40,12 +40,13 @@ func TestCreateMetric(t *testing.T) { "metrics_name": "jfcli_commands_count", "labels": { "product_id": "` + coreutils.GetCliUserAgentName() + `", + "product_version": "` + coreutils.GetCliUserAgentVersion() + `", "feature_id": "testCommand", - "oidc_used": "true", + "oidc_used": "TRUE", "job_id": "job123", "run_id": "run456", "git_repo": "test-repo", - "gh_token_for_code_scanning_alerts_provided": "true" + "gh_token_for_code_scanning_alerts_provided": "TRUE" } }`