Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal API - Visibility System support #1314

Merged
merged 10 commits into from
Dec 21, 2024

Conversation

eyalbe4
Copy link
Contributor

@eyalbe4 eyalbe4 commented Dec 20, 2024

This pull request introduces enhancements to the usage reporting mechanism in the JFrog CLI by adding a new VisibilitySystemManager to log metrics and integrating it into existing commands

Depends on jfrog/jfrog-client-go#1060

@eyalbe4 eyalbe4 added the improvement Automatically generated release notes label Dec 20, 2024
common/commands/command.go Outdated Show resolved Hide resolved
common/commands/command.go Outdated Show resolved Hide resolved
common/commands/command.go Outdated Show resolved Hide resolved
Comment on lines +22 to +36
type labels struct {
ProductID string `json:"product_id"`
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"`
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without omitempty it will send here Value 0 for empty value for example. If its a possible value a believe that its not good. same goes with empty strings.

with omitempty , it won't but it won't send actual 0 value if needed.

so it's need to be decided according to context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sverdlov93.
Omit empty won't be good in the case for the following reasons:

  1. We'd like to send empty strings in the JSON payload, if no values are sent. I believe that the payload structure is expected to be consistent.
  2. The value that we sent is always 1, so it'll never be empty.

utils/usage/visibility_system_manager.go Outdated Show resolved Hide resolved
utils/usage/visibility_system_manager.go Outdated Show resolved Hide resolved
Labels labels `json:"labels"`
}

func (vsm *VisibilitySystemManager) createMetric(commandName string) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why dont we use VisibilityMetric as a return type, to enforce this type on the manager.LogMetric() func?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That indeed makes sense @sverdlov93. Thanks!
Let me implement this in a follow-up PR, after this upcoming initial release.

Co-authored-by: Michael Sverdlov <[email protected]>
Co-authored-by: Michael Sverdlov <[email protected]>
Co-authored-by: Michael Sverdlov <[email protected]>
@eyalbe4 eyalbe4 merged commit 75cba4a into jfrog:dev Dec 21, 2024
6 of 7 checks passed
@@ -747,6 +748,12 @@ func (serverDetails *ServerDetails) CreateAccessAuthConfig() (auth.ServiceDetail
return serverDetails.createAuthConfig(pAuth)
}

func (serverDetails *ServerDetails) CreateJfConnectAuthConfig() (auth.ServiceDetails, error) {
pAuth := accessAuth.NewAccessDetails()
pAuth.SetUrl(utils.AddTrailingSlashIfNeeded(serverDetails.Url) + "jfconnect/")
Copy link
Contributor

@sverdlov93 sverdlov93 Dec 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woudln't this cause double jfconnect/ on the URL?
because here you create the base URL ecosys.jfrog.io/access/jfconnect and on the PostMetric you add jfconnect/api/v1/backoffice/metrics/log

so wouldn't it become: ecosys.jfrog.io/access/jfconnect/jfconnect/api/v1/backoffice/metrics/log

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right @sverdlov93. Good catch 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Automatically generated release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants