Config Default Values Dynamic Lookup #26072
Replies: 2 comments
-
If anyone with knowledge of this repo knows of a way to get these defaults it would be very helpful. Even getting confirmation that this doesn't exist would be great. I've looked through the codebase, but I still don't understand the mechanism that determines which config fields are required(I'm a Go novice, so that's part of my lack of understanding). |
Beta Was this translation helpful? Give feedback.
-
In case anyone else stumbles across this discussion topic I found the solution now that I have gotten more familiar with this repo. There is a tool in cmd/configschema/cfgmetadatagen which generates yaml metadata files for each component. Here is an example of the output for a single component. The tool only needs to be run against the contrib repo and it will generate metadata for all components(from what I can tell) including those in the core repo. Each of the metadata files are named for the component as it appears in the collector config(e.g. OTLP receiver is otlp.yaml, even though the name of the package for that component is otlpreceiver). The metadata includes data types for each field as well as defaults where they exist. Edit: to install the component, run |
Beta Was this translation helpful? Give feedback.
-
I am building a tool to aid users who are brand new to OTEL to build a
config.yaml
for a collector. I am making good progress.When a user selects an individual component to configure, let's use the awsxrayexporter for this example, I want to display which fields are required, which are optional, and what the default values are for each field. So the awsxrayexporter would provide the following:
num_workers
: Default[8]endpoint
: Optionalrequest_timeout_seconds
: Default[30]...etc.
I got the above information from the README.md for that component, but I'm hoping that it is defined in a structured format somewhere across components, the same way that certain information is provided in the metadata.yaml for each component. If these required attrs/defaults are defined in Go code, that's ok. I'm already parsing the Config struct for each component, along with the
mapstructure
tag for each attr in the struct(and recursing into nested structs). I just need a reliable, programmatic way to get the information about which fields are required, and what default values exist.Currently, I am marking fields as optional when they use the
,omitempty
tag in themapsructure
tag, but there are other attrs in the config struct which have default values that don't use this tag. Where can I find which Config struct attrs are required for any given component?Beta Was this translation helpful? Give feedback.
All reactions