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

Add basic opencensus metrics to message handlers #297

Closed
wants to merge 4 commits into from

Conversation

lanzafame
Copy link
Contributor

No description provided.

@ghost ghost assigned lanzafame Mar 12, 2019
@ghost ghost added the status/in-progress In progress label Mar 12, 2019
@anacrolix
Copy link
Contributor

I would hook the messages just once, and use the Type String as the label. I think the views should be returned directly from the IpfsDHT type, MetricViews() or something. Store them together in a struct on the IpfsDHT type. There's got to be a better default way to handle the distributions (prometheus infers them automatically). I think this change should expose publicly at most one new type, a struct that aggregates the views.

Copy link
Contributor

@anacrolix anacrolix left a comment

Choose a reason for hiding this comment

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

Make as much private as possible. There's already way too much global variable litter in the package. The GetType().String() stuff is great.

metrics.go Outdated Show resolved Hide resolved
metrics.go Outdated Show resolved Hide resolved
metrics.go Outdated Show resolved Hide resolved
@ghost ghost assigned anacrolix Mar 13, 2019
metrics/opencensus.go Outdated Show resolved Hide resolved
@anacrolix
Copy link
Contributor

Needs support for gx.

@anacrolix
Copy link
Contributor

Needs outbound message counting (much more interesting).

Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

lots of work to get these metrics...

@anacrolix
Copy link
Contributor

@vyzo LOC or #commits?

@anacrolix
Copy link
Contributor

CI failing because we don't have 0.19.2 in gx.

Experimentation elsewhere has found it not to be useful in the way I expected.
@anacrolix
Copy link
Contributor

I've rebased and removed message write latencies, as it was a rabbit hole.

@anacrolix
Copy link
Contributor

@lanzafame @frrist @vyzo @bigs I'd like to merge this, and add support for error counts etc. in future PRs. Please review.

Copy link
Contributor Author

@lanzafame lanzafame left a comment

Choose a reason for hiding this comment

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

These comments are 'Request changes' comments, but since I originally authored this PR, I can't actually request changes.

Most of the things I commented on have been fixed in #317.

return tag.Upsert(KeyMessageType, m.Type.String())
}

const namePrefix = "libp2p_dht_kad_"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Incorrect format of name prefix. OC converts to the appropriate format for the configured backend.

return tag.Upsert(KeyMessageType, m.Type.String())
}

const namePrefix = "libp2p_dht_kad_"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Variable not required, as this won't change and if it ever does, find-replace will be perfectly acceptable.

KeyLocalPeerID.Name(), KeyInstanceID.Name())
)

var Views = []*view.View{{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move views to individual views, that are exported. This way they will appear in godocs and users will be able to register the ones that they want by name, instead of either always having to register all of them, register them by index (potentially getting the wrong metrics if the order of the slice is ever changed), or copying them over to their own code just so they can make the choice.

dht.tagMutators()...,
)
if err != nil {
panic(err)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't panic in library code.


stats.RecordWithTags(
ctx,
[]tag.Mutator{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use UpsertMessageType function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Better yet, move upserting of the message type to a tag.New so that the ctx has the message type and then remove the upsert of message type from the latency record statement at the end of the function.

Copy link
Contributor Author

@lanzafame lanzafame left a comment

Choose a reason for hiding this comment

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

github snarfu...

@anacrolix
Copy link
Contributor

I'll cannabalize anything here that was missed in #317.

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

Successfully merging this pull request may close these issues.

3 participants