Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

POC tracking job metrics calling DB Api #102

Closed
wants to merge 5 commits into from

Conversation

storey247
Copy link
Contributor

@storey247 storey247 commented Nov 1, 2019

  • Attempting to track extra metrics for prometheus
  • POC so not ready for review yet

Copy link
Contributor

@lawrencegripper lawrencegripper left a comment

Choose a reason for hiding this comment

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

This looks like a great start, awesome work.

Thinking out loud, may well be a bad plan, as we look to add more metrics to the other controllers I was maybe considering using something like the Azure Go SDK does with spans and defer to close out the call.

https://github.com/Azure/azure-sdk-for-go/blob/7a9d2769e4a581b0b1bc609c71b59af043e05c98/services/preview/portal/mgmt/2019-01-01-preview/portal/models.go#L175

// NextWithContext advances to the next page of values.  If there was an error making
// the request the page does not advance and the error is returned.
func (page *ResourceProviderOperationListPage) NextWithContext(ctx context.Context) (err error) {
	if tracing.IsEnabled() {
		ctx = tracing.StartSpan(ctx, fqdn+"/ResourceProviderOperationListPage.NextWithContext")
		defer func() {
			sc := -1
			if page.Response().Response.Response != nil {
				sc = page.Response().Response.Response.StatusCode
			}
			tracing.EndSpan(ctx, sc, err)
		}()
	}
	next, err := page.fn(ctx, page.rpol)
	if err != nil {
		return err
	}
	page.rpol = next
	return nil
}

controllers/djob_metrics.go Outdated Show resolved Hide resolved
}

func trackMetric(startTime time.Time, histogram prometheus.Histogram) {
endTime := float64(time.Now().Sub(startTime).Nanoseconds() / int64(time.Millisecond))
Copy link
Contributor

@lawrencegripper lawrencegripper Nov 11, 2019

Choose a reason for hiding this comment

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

nit: The sub method on time produces a duration which has the method Milliseconds. I'd favor using that over returning nanosec and dividing or I might have misunderstood what this is doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Finally got to the bottom of this, yes there is a Milliseconds method, but only in golang v1.13 and this project currently targets 1.12 in its dev container. https://golang.org/doc/go1.13#time

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: In time.Now().Sub(startTime).Nanoseconds() I think you can replace it with time.Now().Sub(startTime).
nit: I don't think the int64 conversion is needed if you don't call Nanoseconds
nit: the variable is called endTime but looks more like duration?
Also, is the float conversion designed to allow sub-millisecond resolution in the metrics? If so, I'm not sure that the conversion on the outside will achieve that.

Suggested change
endTime := float64(time.Now().Sub(startTime).Nanoseconds() / int64(time.Millisecond))
duration := float64(time.Now().Sub(startTime) / time.Millisecond)

controllers/djob_controller_databricks.go Outdated Show resolved Hide resolved
controllers/djob_controller_databricks.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@EliiseS EliiseS left a comment

Choose a reason for hiding this comment

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

Great job :)

controllers/djob_controller_databricks.go Outdated Show resolved Hide resolved
storey247 and others added 2 commits November 11, 2019 06:15
Co-Authored-By: Stuart Leeks <stuart@leeks.net>
@storey247 storey247 marked this pull request as ready for review November 11, 2019 15:49
@storey247
Copy link
Contributor Author

Closing this PR as it is a POC and want to extend for more metrics

@storey247 storey247 closed this Nov 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants