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

Clean up configuration generation for otel configs. #145

Merged
merged 29 commits into from
Aug 18, 2021

Conversation

igorpeshansky
Copy link
Member

@igorpeshansky igorpeshansky commented Aug 6, 2021

Extracted from #141.

@quentinmit quentinmit force-pushed the igorpeshansky-config-cleanup-generation-otel branch from d2ffcfd to 903c862 Compare August 13, 2021 22:32
@quentinmit quentinmit changed the base branch from igorpeshansky-config-custom-unmarshaler to master August 13, 2021 22:33
@quentinmit
Copy link
Member

I rebased this on master now that #143 is merged. Still quite a bit of cleanup I'd like to do, but I guess we could split that into a separate PR if you'd like to review this so far.

@quentinmit
Copy link
Member

I finished the work from Friday to make otel config generation completely modular. The diff is now 12 files changed, 874 insertions(+), 1820 deletions(-), so a net decrease of almost 1,000 LOC.

Please review, @davidbtucker

@quentinmit quentinmit force-pushed the igorpeshansky-config-cleanup-generation-otel branch from c910356 to b24888f Compare August 16, 2021 20:29
@quentinmit quentinmit force-pushed the igorpeshansky-config-cleanup-generation-otel branch from b24888f to 1880902 Compare August 16, 2021 20:43
Copy link
Contributor

@davidbtucker davidbtucker left a comment

Choose a reason for hiding this comment

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

First round of comments.

Version string
}

func (r MetricsReceiverAgent) Pipeline() otel.Pipeline {
Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly *otel.Pipeline.

Copy link
Member

Choose a reason for hiding this comment

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

No, I don't think there's any reason to pass by reference (and if we do, that brings up the possibility of accidentally changing the struct)

confgenerator/agentmetrics.go Show resolved Hide resolved
confgenerator/metric_processors.go Outdated Show resolved Hide resolved
confgenerator/metric_processors.go Outdated Show resolved Hide resolved
confgenerator/agentmetrics.go Outdated Show resolved Hide resolved
confgenerator/otel/modular.go Outdated Show resolved Hide resolved
confgenerator/otel/modular.go Outdated Show resolved Hide resolved
confgenerator/otel/modular.go Show resolved Hide resolved
confgenerator/otel/modular.go Show resolved Hide resolved
confgenerator/confgenerator.go Show resolved Hide resolved
@quentinmit quentinmit force-pushed the igorpeshansky-config-cleanup-generation-otel branch from aac139d to 9d963e1 Compare August 17, 2021 21:14
@quentinmit
Copy link
Member

quentinmit commented Aug 17, 2021

I just pushed a couple commits to make the golden file diffs smaller. Here's a command you can use to diff them:

pip install yq
sudo apt install jq
for i in testdata/valid/*/*/golden_otel.conf; do echo "--- $i"; diff -U500 <(git cat-file blob origin/master:./$i | sed 's/metric_name:/include:/' | ~/.local/bin/yq -y -S | sed 's/null/{}/') <(git cat-file blob HEAD:./$i | ~/.local/bin/yq -y -S); done

type Metrics struct {
Receivers metricsReceiverMap `yaml:"receivers" validate:"dive,keys,startsnotwith=lib:"`
Processors metricsProcessorMap `yaml:"processors" validate:"dive,keys,startsnotwith=lib:"`
// Exporters are deprecated and ignored, so do not have any validation.
Exporters metricsExporterMap `yaml:"exporters,omitempty"`
Service *MetricsService `yaml:"service"`
Exporters map[string]interface{} `yaml:"exporters,omitempty"`
Copy link
Member Author

Choose a reason for hiding this comment

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

We will now allow arbitrary YAML in the exporters field, and it's completely unvalidated. Is this where we want to be with respect to customer configs? Or do we want to restrict what they put in there before we ignore it?

Copy link
Member

Choose a reason for hiding this comment

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

We already dropped validation on this field, both partially before and now even more. It's a lot of work to maintain validation on a field that's already ignored and deprecated. Anyone who is specifying this field has been doing it since pre-2.0, so they already had a chance to get the field validated. I don't think it's worth the effort to maintain unused validation.

Copy link
Member Author

@igorpeshansky igorpeshansky left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

@igorpeshansky igorpeshansky requested review from qingling128 and removed request for quentinmit August 17, 2021 22:34
Copy link
Contributor

@qingling128 qingling128 left a comment

Choose a reason for hiding this comment

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

LGTM. Integration tests passed: http://b/195762251#comment4

stackdriverList = append(stackdriverList, &stackdriver)
exportNameMap[eID] = "googlecloud/" + eID
for i, receiverPipeline := range receiver.Pipelines() {
prefix := fmt.Sprintf("%s_%s", strings.ReplaceAll(pID, "_", "__"), strings.ReplaceAll(rID, "_", "__"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious: what is the reason behind replacing _ with __? The resulting prefix looks like:

agentmetrics/default__pipeline_hostmetrics_0

If the purpose is to make them look grouped, shouldn't it be

agentmetrics/default_pipeline__hostmetrics__0

Copy link
Member

Choose a reason for hiding this comment

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

Replacing _ with __ prevents collisions between different pipelines. If we went the other direction, there would be no way to distinguish between (pipeline default__pipeline receiver hostmetrics) and (pipeline default receiver pipeline__hostmetrics).

We could certainly introduce smarter anti-collision logic though (e.g. default to the bare pipeline name and add suffixes only when there would be a collision). But I'd like to save that for later PRs.

@@ -44,7 +44,7 @@ func (c Component) name(suffix string) string {
return c.Type
}

// configToYaml converts a tree of structss into a YAML file.
// configToYaml converts a tree of structs into a YAML file.
Copy link
Contributor

Choose a reason for hiding this comment

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

LOL

Copy link
Member

Choose a reason for hiding this comment

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

My MBP keyboard introduces spurious s keypresses all over the place :(

@quentinmit quentinmit merged commit 8d6ed85 into master Aug 18, 2021
@quentinmit quentinmit deleted the igorpeshansky-config-cleanup-generation-otel branch August 18, 2021 03:46
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.

4 participants