-
Notifications
You must be signed in to change notification settings - Fork 278
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 OpenMetrics support #538
Conversation
Codecov Report
@@ Coverage Diff @@
## master #538 +/- ##
===========================================
+ Coverage 74.50% 86.95% +12.44%
===========================================
Files 4 4
Lines 102 138 +36
===========================================
+ Hits 76 120 +44
+ Misses 18 10 -8
Partials 8 8
Continue to review full report at Codecov.
|
f415755
to
3e31165
Compare
Hej @jhaals. This is ready for review, let me know what you'd like to see changed / where you'd prefer a different style or such. Happy to make any changes. |
Thanks a lot for the PR @grobie, I will happily accept these changes. Would you also be able to add some notes about metrics in the readme? |
bc1198d
to
b7415f0
Compare
Fantastic 👍 |
cmd/yopass/main.go
Outdated
@@ -18,6 +20,7 @@ var ( | |||
maxLength = pflag.Int("max-length", 10000, "max length of encrypted secret") | |||
memcached = pflag.String("memcached", "localhost:11211", "Memcached address") | |||
port = pflag.Int("port", 1337, "listen port") | |||
_ = pflag.Int("metrics-port", -1, "metrics server listen port") |
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 this supposed to be underscore?
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.
Hehe. So I realized that all these global variables are unused, as you use viper to access the flag values. I'll change it for consistency.
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.
Done. It might make sense to remove all these variables and only leave the pflag function invocations to make it clear that the global variables aren't used.
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.
@grobie I did not know that the variables where unused, it must have been a leftover from the time when I used flag
. It make sense to clean them up in a separate PR. I'm going to merge this one. Thanks a lot for adding metrics to yopass ❤️
Instrument Yopass' HTTP handler and record served HTTP requests by method, path and reponse code, and request duration by method and path. Metrics are optionally served in the [OpenMetrics][] text format on a separate HTTP server under /metrics. The metrics server can be enabled by setting the --metrics-port flag. For now listen IP address and TLS settings are used for both HTTP server instances. [OpenMetrics]: https://openmetrics.io/ Signed-off-by: Tobias Schmidt <[email protected]>
b7415f0
to
aa9f8e5
Compare
Instrument Yopass' HTTP handler and record served HTTP requests by
method, path and reponse code, and request duration by method and path.
Metrics are optionally served in the OpenMetrics text format on a
separate HTTP server under /metrics. The metrics server can be enabled
by setting the --metrics-port flag. For now listen IP address and TLS
settings are used for both HTTP server instances.
Resolves #536. Depends on #537.
Example /metrics output: