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

engine: report metrics to opentelemetry.tilt.dev, and give an example of how to report tilt cli commands #3749

Merged
merged 1 commit into from Sep 3, 2020

Conversation

nicks
Copy link
Member

@nicks nicks commented Sep 3, 2020

Hello @landism, @maiamcc,

Please review the following commits I made in branch nicks/ch9214:

dd45c78 (2020-09-03 12:21:54 -0400)
engine: report metrics to opentelemetry.tilt.dev, and give an example of how to report tilt cli commands

Code review reminders, by giving a LGTM you attest that:

  • Commits are adequately tested
  • Code is easy to understand and conforms to style guides
  • Incomplete code is marked with TODOs
  • Code is suitably instrumented with logging and metrics

@nicks
Copy link
Member Author

nicks commented Sep 3, 2020

Most of this should be pretty straightforward boilerplate:

  1. Wrapping the opencensus code so that metrics that come in before tiltfile execution eventually get reported
  2. standard store/Subscriber boilerplate that reacts to changes to MetricsSettings

The interesting bits are about the opencensus views. The state of the art for reporting metrics these days is pretty consistent across libraries I looked at (prometheus and statsd and opencensus and opentelemetry and openmetrics all look pretty much the same).

They ask you to "pre-index" how your metrics are going to look, and send a heartbeat to the server with a summary of the metrics as they're collected.

I think the idea is that the metrics are pre-indexed a bit, so that if a server request fails, we can re-send them without the risk of double-counting them

}
}

func (c *Controller) diff(rStore store.RStore) model.MetricsSettings {
Copy link
Member

Choose a reason for hiding this comment

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

should rename or pull the diff logic up into this method

Copy link
Member Author

Choose a reason for hiding this comment

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

done!

}

func (c *Controller) OnChange(ctx context.Context, rStore store.RStore) {
newMetrics := c.diff(rStore)
Copy link
Member

Choose a reason for hiding this comment

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

this name made me think it more directly contained to actual metrics / values - how about "settings" or "metricsSettings"?

Copy link
Member Author

Choose a reason for hiding this comment

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

done!

c.metrics = newMetrics
view.SetReportingPeriod(newMetrics.ReportingPeriod)

if !newMetrics.Enabled {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if !newMetrics.Enabled {
if oldMetrics.Enabled && !newMetrics.Enabled {

nit: so that we don't log "shutting down" when changing settings other than "enabled", or in case someone adds some non-idempotent code to this block thinking it's the "shut down" block that fails when it wasn't running in the first place

Copy link
Member Author

Choose a reason for hiding this comment

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

done!

f.mc.OnChange(f.ctx, f.st)
assert.NotSame(t, remote, f.exp.remote)

// Verify that disablingthe metrics settings nulls out the remote exporter.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Verify that disablingthe metrics settings nulls out the remote exporter.
// Verify that disabling the metrics settings nulls out the remote exporter.

Copy link
Member Author

Choose a reason for hiding this comment

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

done!

@nicks nicks merged commit 9a3c2bd into master Sep 3, 2020
@nicks nicks deleted the nicks/ch9214 branch September 3, 2020 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants