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

cfggen: recognize comments in the struct while generating output #4751

Closed
Dentrax opened this issue Oct 7, 2021 · 6 comments
Closed

cfggen: recognize comments in the struct while generating output #4751

Dentrax opened this issue Oct 7, 2021 · 6 comments
Labels

Comments

@Dentrax
Copy link

Dentrax commented Oct 7, 2021

Is your proposal related to a problem?

As we discussed with @saswatamcode at PR #4749, the problem simply identifies that we had better to improve the tracing configuration doc as we proposed at #4748.

(Write your answer here.)

Describe the solution you'd like

We have to do some enhancements in the scripts/cfggen to make that tool recognize the comments.

Let's assume we have the following config struct:

// Config - YAML configuration.
type Config struct {
  // Foo used for to store string
  Foo  string   `yaml:"foo"`
  // Bar used for to store bool
  // true by default
  Bar  bool     `yaml:"bar"`
  // Baz used for to store float64
  Baz  float64  `yaml:"baz"`
}

cfggen should generate the following yaml snippet:

type: JAEGER
config:
  # Foo used for to store string
  foo: ""
  # Bar used for to store bool
  # true by default
  bar: false
  # Baz used for to store float64
  baz: 0

Describe alternatives you've considered

We can add Markdown table in below for each configuration like the following:

Property Description
sampler_type The sampler type: remote , const , probabilistic , ratelimiting (default remote). More information
@matej-g
Copy link
Collaborator

matej-g commented Nov 12, 2021

I'm wondering if this is meaningful, given that here we copy verbatim from the documentation that we link to. For me personally this adds more noise, when users can find the same information under the linked details. Opinions?

@saswatamcode
Copy link
Member

Yes, in this particular case it doesn't make much sense to have as there are detailed docs regarding tracing config which we can link to.

But in the case of some Thanos-specific config (eg QueryAPI) or config without descriptive docs to link to, it can be nice to have. cfggen can then directly pull comments from source code and generate YAML (which is pasted into code blocks by mdox) and docs get updated automatically if there is some config change with relevant details. 🙂

Currently, mdox uses cfggen script using mdox-exec to generate YAML code blocks, but there's also an idea to downstream cfggen to mdox and generate YAML directly from Go struct, in which case cfggen support for comments and default values, might be beneficial to projects that use it!

@matej-g
Copy link
Collaborator

matej-g commented Nov 13, 2021

I see now, I missed the full context (that we want this for all configs). Sounds good! Maybe then you could consider having option to generate with or without comments included for cases like this?

@saswatamcode
Copy link
Member

Yes, plan to have certain flags/options to support this! :)

@stale
Copy link

stale bot commented Mar 2, 2022

Hello 👋 Looks like there was no activity on this issue for the last two months.
Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗
If there will be no activity in the next two weeks, this issue will be closed (we can always reopen an issue if we need!). Alternatively, use remind command if you wish to be reminded at some point in future.

@stale stale bot added the stale label Mar 2, 2022
@stale
Copy link

stale bot commented Apr 17, 2022

Closing for now as promised, let us know if you need this to be reopened! 🤗

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

No branches or pull requests

3 participants