-
Notifications
You must be signed in to change notification settings - Fork 55
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
feat: New Metrics metadata #175
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5678649
feat: New Metrics metadata is included in client registration and cli…
chriswk f30fcdc
fix: added specVersion to Metrics
chriswk f78b2c5
Moved WithStarted into test code
chriswk 3459bb7
fix: apply gofmt and added Nunos suggested test for client data
chriswk e9a9dd3
revert back to just setting started directly
chriswk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |
"math" | ||
"net/http" | ||
"net/url" | ||
"runtime" | ||
"sync" | ||
"time" | ||
|
||
|
@@ -24,6 +25,18 @@ type MetricsData struct { | |
|
||
// Bucket is the payload data sent to the server. | ||
Bucket api.Bucket `json:"bucket"` | ||
|
||
// The runtime version of our Platform | ||
PlatformVersion string `json:"platformVersion"` | ||
|
||
// The runtime name of our Platform | ||
PlatformName string `json:"platformName"` | ||
|
||
// Which version of Yggdrasil is being used | ||
YggdrasilVersion *string `json:"yggdrasilVersion"` | ||
|
||
// Optional field that describes the sdk version (name:version) | ||
SDKVersion string `json:"sdkVersion"` | ||
} | ||
|
||
// ClientData represents the data sent to the unleash during registration. | ||
|
@@ -46,6 +59,12 @@ type ClientData struct { | |
// Interval specifies the time interval (in ms) that the client is using for refreshing | ||
// feature toggles. | ||
Interval int64 `json:"interval"` | ||
|
||
PlatformVersion string `json:"platformVersion"` | ||
|
||
PlatformName string `json:"platformName"` | ||
|
||
YggdrasilVersion *string `json:"yggdrasilVersion"` | ||
} | ||
|
||
type metric struct { | ||
|
@@ -73,10 +92,14 @@ type metrics struct { | |
} | ||
|
||
func newMetrics(options metricsOptions, channels metricsChannels) *metrics { | ||
started := time.Now() | ||
if options.started != nil { | ||
started = *options.started | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this can be reverted now, and we can set |
||
m := &metrics{ | ||
metricsChannels: channels, | ||
options: options, | ||
started: time.Now(), | ||
started: started, | ||
close: make(chan struct{}), | ||
closed: make(chan struct{}), | ||
maxSkips: 10, | ||
|
@@ -174,9 +197,13 @@ func (m *metrics) sendMetrics() { | |
} | ||
bucket.Stop = time.Now() | ||
payload := MetricsData{ | ||
AppName: m.options.appName, | ||
InstanceID: m.options.instanceId, | ||
Bucket: bucket, | ||
AppName: m.options.appName, | ||
InstanceID: m.options.instanceId, | ||
Bucket: bucket, | ||
SDKVersion: fmt.Sprintf("%s:%s", clientName, clientVersion), | ||
PlatformName: "go", | ||
PlatformVersion: runtime.Version(), | ||
YggdrasilVersion: nil, | ||
} | ||
|
||
u, _ := m.options.url.Parse("./client/metrics") | ||
|
@@ -305,5 +332,8 @@ func (m *metrics) getClientData() ClientData { | |
m.options.strategies, | ||
m.started, | ||
int64(m.options.metricsInterval.Seconds()), | ||
runtime.Version(), | ||
"go", | ||
nil, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
started
be configurable?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly for tests here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would've used #[cfg(test)] here, don't know what the same is in go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I've moved it into the test file where I used it instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't like that we're polluting our config options with something that shouldn't be user-configurable and I'm still not super convinced of its value. Maybe we can relax our tests instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this seems to work, but maybe there's a better way:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I added your suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And removed started from the options