chore: adds org lookup type to instrumentation data#609
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This comment has been minimized.
This comment has been minimized.
2381e2f to
a48fa86
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| orgId, err = apiClient.GetOrgIdFromSlug(context.Background(), existingString) | ||
| if err != nil { | ||
| logger.Print("Failed to determine default value for \"ORGANIZATION\":", err) | ||
| addLookupType("invalid") |
There was a problem hiding this comment.
Suggestion: maybe be a bit more explicit and self explaining in the data. Consider a case that someone will just have the instrumentation data, will it be self explaining?
There was a problem hiding this comment.
thinking of the more complete picture (name: value)
- organization-id-origin: defaultid-failed-slugname-lookup
- organization-id-origin: defaultid-not-user-supplied
- organization-id-origin: slugname-lookup
- organization-id-origin: user-supplied
I don't like my proposal but maybe still food for thought?
There was a problem hiding this comment.
made an opinionated change, let me know if it works
a48fa86 to
c692c0f
Compare
This comment has been minimized.
This comment has been minimized.
c692c0f to
64b7ff4
Compare
This comment has been minimized.
This comment has been minimized.
| slugName, err := apiClient.GetSlugFromOrgId(context.Background(), orgId) | ||
| if err != nil { | ||
| logger.Print("Failed to determine default value for \"ORGANIZATION_SLUG\":", err) | ||
| recorder.addExtension(orgLookupKey, "invalid") |
There was a problem hiding this comment.
context: a command like snyk test --org=<INVALID_UUID> will result in the orgLookupkey value being orgid instead of invalid
07ab378 to
d0060e0
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| a := analytics.New() | ||
| a.SetIntegration(e.config.GetString(configuration.INTEGRATION_NAME), e.config.GetString(configuration.INTEGRATION_VERSION)) | ||
| a.SetApiUrl(e.config.GetString(configuration.API_URL)) | ||
| a.SetOrg(e.config.GetString(configuration.ORGANIZATION)) |
There was a problem hiding this comment.
context: calling this before we finish initialising our engine means our analytics is not initialised and will lead to it being nil when trying to use it in our config.DefaultValueFunction.
The consequence is that we have to set this where we use GAF (e.g. CLI) instead.
Possibly a controversial change but, without this, we won't get analytics implemented in the rest of the PR. Additionally, the argument could be made that none of these "Sets" should be a GAF concern.
5fae914 to
fc5e2f6
Compare
PR Reviewer Guide 🔍
|
PR Reviewer Guide 🔍
|
This comment has been minimized.
This comment has been minimized.
fc5e2f6 to
d62b09f
Compare
This comment has been minimized.
This comment has been minimized.
2355c76 to
2926e93
Compare
This comment has been minimized.
This comment has been minimized.
2926e93 to
c125106
Compare
|
|
||
| const ( | ||
| // orgLookupSourceKey records how the ORGANIZATION value was resolved. | ||
| orgLookupSourceKey = "gaf.app.defaultfunc.organization.lookup" |
There was a problem hiding this comment.
context: key tries to define the kind of data we're assessing in OTel standard dot . notation.
The idea is to break it down as follows: <project>.<package|scope>.<method>.<property>.<detail>.
PR Reviewer Guide 🔍
|
Description
This PR adds some extra instrumentation data to how we perform org lookups.
Checklist
make test)make generate)make lint)go get github.com/snyk/go-application-framework@YOUR_LATEST_GAF_COMMITin thecliv2directory.go.modto point to your local GAF code.go mod tidyin thecliv2directory.go.modandgo.sumchanges.