-
Notifications
You must be signed in to change notification settings - Fork 29
collect metrics in a separate go routine #82
Conversation
79b9740
to
544cba2
Compare
metrics.go
Outdated
info, err := conn.getTCPInfo() | ||
if err != nil { | ||
if strings.Contains(err.Error(), "use of closed network connection") { | ||
c.closedConn(conn) | ||
continue | ||
} | ||
log.Errorf("Failed to get TCP info: %s", err) | ||
continue | ||
} |
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.
Is it a problem that if we conn.getTCPInfo()
errors differently from expected such that we'll never close the connection?
I've seen 2021-07-08T21:39:47.925-0400 ERROR tcp-tpt [email protected]/metrics.go:118 Failed to get TCP info: raw-control tcp 192.168.1.6:4001: getsockopt: not implemented
on Windows so I'm concerned this could cause us problems.
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 tried it in my Windows VM, and I'm getting the same error. Should we disable metrics collection on Windows?
Following up here, with the recent Slack conversations in mind.
That is the Prometheus idiomatic way. In other words, just-in-time (on scrape / on |
2851bff
to
43b076c
Compare
@marten-seemann : what are the next steps here? Who do we need a review from? |
43b076c
to
660cdd6
Compare
660cdd6
to
d611dc7
Compare
I wasn't done yet with my changes, that's why I didn't request any reviews. Now I am, and will do so. |
@aschmahmann @Stebalien I updated the PR. Now
|
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.
One small fix but it should work otherwise.
Fixes #81.
I really wish there was a way to pass a Prometheus struct to tcp-transport, and only collect metrics in case metrics are actually scraped. This PR introduces an eternal Go routine that periodically asks the kernel for metrics, and removes a connection from connection map when it is closed.