-
Notifications
You must be signed in to change notification settings - Fork 226
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
Conversation
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. |
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.
Make as much private as possible. There's already way too much global variable litter in the package. The GetType().String()
stuff is great.
Needs support for gx. |
Needs outbound message counting (much more interesting). |
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.
lots of work to get these metrics...
@vyzo LOC or #commits? |
CI failing because we don't have 0.19.2 in gx. |
ee043eb
to
dd49f0e
Compare
dd49f0e
to
e4666c5
Compare
Experimentation elsewhere has found it not to be useful in the way I expected.
I've rebased and removed message write latencies, as it was a rabbit hole. |
@lanzafame @frrist @vyzo @bigs I'd like to merge this, and add support for error counts etc. in future PRs. Please review. |
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.
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_" |
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.
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_" |
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.
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{{ |
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.
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) |
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.
Don't panic in library code.
|
||
stats.RecordWithTags( | ||
ctx, | ||
[]tag.Mutator{ |
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.
Use UpsertMessageType
function
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.
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.
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.
github snarfu...
I'll cannabalize anything here that was missed in #317. |
No description provided.