Skip to content

Conversation

@igorpeshansky
Copy link
Contributor

Extracted from #141 and rebased on top of the merged #142. Can split up further if needed.

@igorpeshansky igorpeshansky force-pushed the igorpeshansky-config-custom-unmarshaler branch from 84471f1 to 0472e6f Compare August 6, 2021 22:45
@igorpeshansky igorpeshansky changed the title Cleanup configuration representation and generation. Cleanup configuration representation. Aug 6, 2021
@quentinmit quentinmit force-pushed the igorpeshansky-config-custom-unmarshaler branch from d23609a to 12bf723 Compare August 11, 2021 18:17
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.

Some suggested comments to add. More to come.

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.

Some more config.go comments.

if err != nil {
t.Fatalf("ReadFile(%q) got: %v", userSpecifiedConfPath, err)
}
t.Logf("merged config:\n%s", data)
Copy link
Contributor

Choose a reason for hiding this comment

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

[Optional] Can we log the built-in config and user specified config as well? This helps with diagnosing old agent issues when the config might have been edited already, and customer might want to trace back to the config content at the time of incident.

Copy link
Member

Choose a reason for hiding this comment

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

This is a unit test... there's no old customer config in a unit test :P It's not easy to add logging of the pre-merge configs in the unit test for now. Hopefully will be possible when I do more refactoring.

As for logging these in the real daemon, yeah, we should do that but that will come later.

}
}
sort.Strings(supportedTypes)
return fmt.Errorf(`%s %s %q with type %q is not supported. Supported %s %s types: [%s].`,
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably need to remove the "???" part for now if receiver / processor / exporter ID is not available at this point.

Copy link
Member

Choose a reason for hiding this comment

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

These error messages are all going to get cleaned up later in a separate PR. But I removed the ??? for now so it's not as confusing.

@@ -1,2 +1 @@
the agent config file is not valid YAML. detailed error: yaml: unmarshal errors:
line 6: cannot unmarshal !!str `abc` into uint16 No newline at end of file
the agent config file is not valid. detailed error: cannot unmarshal string into Go struct field UnifiedConfig.Logging of type uint16 No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

This one looks a bit different from others as it does not print the config snippet. Is that expected?

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 know why it's missing the line number and snippet. Nor why it says unmarshal string into [...] uint16. Worth investigating later.

@@ -1 +1,9 @@
logging processor id "lib:processor_1" is not allowed because prefix 'lib:' is reserved for pre-defined processors.
the agent config file is not valid. detailed error: [9:20] Key: 'Logging.processors[lib:processor_1]' Error:Field validation for 'processors[lib:processor_1]' failed on the 'startsnotwith' tag
Copy link
Contributor

Choose a reason for hiding this comment

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

The new message does not mention what prefix is forbidden. Not too bad though as we could add a note to the troubleshooting guide.

Copy link
Member

Choose a reason for hiding this comment

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

Improving all of these error messages is a TODO. We can easily add that back and more, but I'm prioritizing getting a stable interface ready for BM first.

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.

Finished reviewing the remaining files.

@@ -1 +1,9 @@
parameter "transport_protocol" in "files" type logging receiver "receiver_1" is not supported. Supported parameters: [include_paths, exclude_paths].
the agent config file is not valid. detailed error: [8:7] unknown field "transport_protocol"
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove some of these validation tests as redundant. Follow-up work.

Copy link
Member

Choose a reason for hiding this comment

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

Which one(s) are redundant?

Copy link
Contributor

Choose a reason for hiding this comment

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

A bunch of these tests have the form "invalid field X for type Y", because we had to explicitly check each field in the old code.

Now with the validate tags, I think we can just have a single such test.

@quentinmit quentinmit merged commit 014c2da into master Aug 13, 2021
@igorpeshansky igorpeshansky deleted the igorpeshansky-config-custom-unmarshaler branch August 18, 2021 01:38
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.

5 participants