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

Automated way to expose configuration schema #5006

Open
yurishkuro opened this issue Oct 21, 2020 · 7 comments
Open

Automated way to expose configuration schema #5006

yurishkuro opened this issue Oct 21, 2020 · 7 comments
Assignees
Labels
comp:jaeger Jaeger related issues never stale Issues marked with this label will be never staled and automatically removed

Comments

@yurishkuro
Copy link
Member

Is your feature request related to a problem? Please describe.

Unless I am missing something, there is no authoritative way to generate documentation for the schema of configuration file. There is some manually maintained doc pages with examples, but the authoritative source is the source code of the config structs (e.g. pprof extension). This is pretty difficult for end-users.

For Jaeger binaries built on top of OTEL collector, we could like to do better than that. For example, the current Jaeger configuration can be inspected from the help sub-commands and/or auto-generated docs like https://www.jaegertracing.io/docs/1.20/cli/.

Describe the solution you'd like

A way to auto-generate readable documentation for configuration options, which means:

  • parseable authoritative source of the schema with inline documentation, such as .proto definition or even Go structs
  • a utility that can convert that source of schema to another format (preferable something structured like JSON or YAML), so that it can be included in the HTML docs on a website.
@jrcamp
Copy link
Contributor

jrcamp commented Oct 21, 2020

Definitely. We do this in the SignalFx agent by using the comment associated with the config property along with Go tags for things like default and validation. See https://github.com/signalfx/signalfx-agent/blob/master/pkg/monitors/ntp/ntp.go#L30 for example. I think a similar approach would work here.

@yurishkuro
Copy link
Member Author

@jrcamp +1, struct tags can be a viable way to provide some metadata, although including long description into the tags is pretty inconvenient, those are better as field comments. Did you implement some utility that can extract the schema from structs? To read both tags and comments the tool would be similar to godoc, working off the AST.

@jrcamp
Copy link
Contributor

jrcamp commented Oct 21, 2020

Did you implement some utility that can extract the schema from structs? To read both tags and comments the tool would be similar to godoc, working off the AST.

Correct, we use go/parser to parse the files into AST to pull out the comments to use as descriptions then I believe Go reflection for info about struct members. (🎩 -tip to @keitwb who did all this, I can't take any credit for it). The relevant code is in https://github.com/signalfx/signalfx-agent/tree/master/pkg/selfdescribe if you're curious.

@bogdandrutu
Copy link
Member

@jrcamp can we start configuring this for one of the component, and see how will look like?

@jrcamp
Copy link
Contributor

jrcamp commented Oct 27, 2020

I've filed a separate issue open-telemetry/opentelemetry-collector#2015 for config validation. Could have some impact on this but don't think it blocks anything, just something to be aware of.

bogdandrutu referenced this issue in open-telemetry/opentelemetry-collector Dec 24, 2020
* POC/Proposal for exposing configuration schemas

Issue: https://github.com/open-telemetry/opentelemetry-collector/issues/1995

This change proposes a way to generate metadata for the configuration structs
used by Collector components. The generated metadata could be used for
documentation and tooling.

The way it works is, given a component, its configuration struct is found, and
its field names, types, tags, default values, and comments are retrieved and
put into a struct. This is done recursively, but respecting "squashed" fields,
and any fields omitted with a "-" tag. The final struct is marshaled to a yaml
file in the directory of the configuration type.

Also included are a simple command line interface and an example metadata
file. The CLI lets users create a metadata file for either a given component or
for all registered components.

Tests have not been included as this change is meant to be exploratory.

* Use a map rather than an array for fields

* Expose component configuration schemas

Issue: https://github.com/open-telemetry/opentelemetry-collector/issues/1995

This change adds a command line utility to generate schema files for each of
the configuration structs used by Collector components. The intent is for these
generated files to be used by documentation utilities and tooling.

The way it works is, given a component, its default configuration struct is
retrieved and introspected, producing field names, types, default values, and
comments. Those are recursively put into a graph of structs, respecting
"squashed" fields and any fields omitted with a "-" tag. Finally, the struct is
marshaled to a yaml file in the directory of the configuration type.

The CLI lets users create a metadata file for either one component or for all
registered components.

For reference, preliminary feedback was gathered here #2169

* Create a local go module, don't panic on mapstructure errors

* Move code to internal, exclude cfgschema from Makefile

* Increase test coverage

* Increase test coverage

* Fix lint

* Reorg so schemagen can be used from contrib

* Don't export stuff that no longer needs to be exported
@bogdandrutu bogdandrutu transferred this issue from open-telemetry/opentelemetry-collector Aug 30, 2021
@alolita alolita added the comp:jaeger Jaeger related issues label Sep 8, 2021
hex1848 pushed a commit to hex1848/opentelemetry-collector-contrib that referenced this issue Jun 2, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2022

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

@github-actions github-actions bot added the Stale label Nov 4, 2022
@dmitryax dmitryax added never stale Issues marked with this label will be never staled and automatically removed and removed Stale labels Nov 4, 2022
@dmitryax
Copy link
Member

dmitryax commented Nov 4, 2022

This is currently in progress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:jaeger Jaeger related issues never stale Issues marked with this label will be never staled and automatically removed
Projects
None yet
Development

No branches or pull requests

6 participants