Skip to content

Commit 5573f66

Browse files
committed
Visibility - update commands count metric to correspond with client improvements
1 parent 66660ff commit 5573f66

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ require (
9696
gopkg.in/warnings.v0 v0.1.2 // indirect
9797
)
9898

99-
// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20241225183733-80a5e1ba7a2c
99+
replace github.com/jfrog/jfrog-client-go => github.com/omerzi/jfrog-client-go v1.13.2-0.20250114141023-3e8625108e2b
100100

101101
// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20241121100855-e7a75ceee2bd
102102

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ github.com/jfrog/build-info-go v1.10.8 h1:8D4wtvKzLS1hzfDWtfH4OliZLtLCgL62tXCnGW
9393
github.com/jfrog/build-info-go v1.10.8/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE=
9494
github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s=
9595
github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4=
96-
github.com/jfrog/jfrog-client-go v1.49.0 h1:NaTK6+LQBEJafL//6ntnS/eVx1dZMJnxydALwWHKORQ=
97-
github.com/jfrog/jfrog-client-go v1.49.0/go.mod h1:ohIfKpMBCQsE9kunrKQ1wvoExpqsPLaluRFO186B5EM=
9896
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
9997
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
10098
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
@@ -138,6 +136,8 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
138136
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
139137
github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9lEc=
140138
github.com/nwaples/rardecode v1.1.3/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
139+
github.com/omerzi/jfrog-client-go v1.13.2-0.20250114141023-3e8625108e2b h1:pUy1KFONlfsjunVBQTbXpyHR1TZPhIaM9rIhKPL2ZLE=
140+
github.com/omerzi/jfrog-client-go v1.13.2-0.20250114141023-3e8625108e2b/go.mod h1:ohIfKpMBCQsE9kunrKQ1wvoExpqsPLaluRFO186B5EM=
141141
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
142142
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
143143
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package usage
22

33
import (
4+
"github.com/jfrog/jfrog-client-go/jfconnect/services/metrics/jfrogcli"
45
"os"
56

67
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
78
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
89
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
9-
"github.com/jfrog/jfrog-client-go/jfconnect/services"
1010
)
1111

1212
type VisibilitySystemManager struct {
@@ -19,8 +19,9 @@ func NewVisibilitySystemManager(serverDetails *config.ServerDetails) *Visibility
1919
}
2020
}
2121

22-
func (vsm *VisibilitySystemManager) createMetric(commandName string) services.VisibilityMetric {
23-
metricLabels := services.Labels{
22+
func (vsm *VisibilitySystemManager) createCommandsCountMetric(commandName string) *jfrogcli.CommandsCountMetric {
23+
metricLabels := jfrogcli.NewCommandsCountMetric()
24+
metricLabels.Labels = jfrogcli.CommandsCountLabels{
2425
ProductID: coreutils.GetCliUserAgentName(),
2526
ProductVersion: coreutils.GetCliUserAgentVersion(),
2627
FeatureID: commandName,
@@ -30,18 +31,13 @@ func (vsm *VisibilitySystemManager) createMetric(commandName string) services.Vi
3031
GitRepo: os.Getenv("JFROG_CLI_USAGE_GIT_REPO"),
3132
GhTokenForCodeScanningAlertsProvided: os.Getenv("JFROG_CLI_USAGE_GH_TOKEN_FOR_CODE_SCANNING_ALERTS_PROVIDED"),
3233
}
33-
34-
return services.VisibilityMetric{
35-
Value: 1,
36-
MetricsName: "jfcli_commands_count",
37-
Labels: metricLabels,
38-
}
34+
return &metricLabels
3935
}
4036

4137
func (vsm *VisibilitySystemManager) SendUsage(commandName string) error {
4238
manager, err := utils.CreateJfConnectServiceManager(vsm.serverDetails, 0, 0)
4339
if err != nil {
4440
return err
4541
}
46-
return manager.PostVisibilityMetric(vsm.createMetric(commandName))
42+
return manager.PostVisibilityMetric(vsm.createCommandsCountMetric(commandName))
4743
}

utils/usage/visibility_system_manager_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/stretchr/testify/assert"
1010
)
1111

12-
func TestCreateMetric(t *testing.T) {
12+
func TestCreateCommandsCountMetric(t *testing.T) {
1313
// Set environment variables for the test using SetEnvWithCallbackAndAssert
1414
envVars := map[string]string{
1515
"JFROG_CLI_USAGE_OIDC_USED": "TRUE",
@@ -30,7 +30,7 @@ func TestCreateMetric(t *testing.T) {
3030
}()
3131

3232
commandName := "testCommand"
33-
metric := NewVisibilitySystemManager(nil).createMetric(commandName)
33+
metric := NewVisibilitySystemManager(nil).createCommandsCountMetric(commandName)
3434
metricJSON, err := json.Marshal(metric)
3535
assert.NoError(t, err)
3636

0 commit comments

Comments
 (0)