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 metricsmd package #3

Merged
merged 8 commits into from
Mar 1, 2024
Merged

Add metricsmd package #3

merged 8 commits into from
Mar 1, 2024

Conversation

lambdanis
Copy link
Collaborator

@lambdanis lambdanis commented Feb 19, 2024

pkg/metricsmd is a utility for generating a metrics reference in the markdown format from initialized Prometheus registry. It's intended to be used as an add-on to applications that have a Cobra CLI and expose Prometheus metrics.

For example usage see cilium/tetragon#2164

Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
@lambdanis lambdanis force-pushed the ft/lambdanis/docs-generator branch 2 times, most recently from 8ee44dd to 5e19bd7 Compare February 19, 2024 23:18
chancez and others added 2 commits February 20, 2024 12:44
The metricsmd.Generate function reads a Prometheus registry and generates a
Markdown reference documentation listing metrics, their help texts and labels.

Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
It's intended to be used as an add-on to applications that have a Cobra CLI and
expose Prometheus metrics. The returned command generates a metrics reference
documentation.

Co-authored-by: Chance Zibolski <chance.zibolski@gmail.com>
Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
@lambdanis lambdanis force-pushed the ft/lambdanis/docs-generator branch from 5e19bd7 to 2858155 Compare February 20, 2024 12:47
Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
Move all configuration options into one Config struct, passed to NewCmd and
Generate functions.

Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
@lambdanis lambdanis force-pushed the ft/lambdanis/docs-generator branch from 4a9deeb to 8a3cd99 Compare March 1, 2024 00:59
Having such a comment in the final docs HTML might be undesirable, and this is
the case e.g. when the markdown is rendered with Hugo. Additionally, if metrics
from multiple targets are compiled into one reference file, then it would
include redundant comments.

The "autogenerated" comment can still be enabled with a config option.

Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
This is useful when the metrics reference is embedded in another markdown
document.

Requested here:
cilium/tetragon#2164 (comment)
cilium/tetragon#2164 (comment)

Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
Validating passed Config prevents a panic or rendering invalid markdown.

Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
@lambdanis lambdanis force-pushed the ft/lambdanis/docs-generator branch from 8a3cd99 to 23fc556 Compare March 1, 2024 01:14
@lambdanis lambdanis requested review from mtardy and chancez March 1, 2024 01:24
Copy link
Member

@mtardy mtardy left a comment

Choose a reason for hiding this comment

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

Thanks! I mostly checked the last commits with the options and it's a good addition :)

Copy link
Member

Choose a reason for hiding this comment

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

I think GitHub automatically does this appropriately?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh, does it? That's cool.

Copy link
Member

Choose a reason for hiding this comment

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

ah go.sum is always displayed but vendored stuff is redacted except for appropriate stuff like vendor/modules.txt. See your PR for example https://github.com/cilium/tetragon/pull/2164/files.

@lambdanis lambdanis merged commit 82e25f1 into main Mar 1, 2024
@lambdanis lambdanis deleted the ft/lambdanis/docs-generator branch March 1, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants