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

Refactor codebase for typed port parsers #2880

Closed
wants to merge 4 commits into from

Conversation

jaronoff97
Copy link
Contributor

Description: Refactors the codebase for allowing typed parsers. Removes the zipkin-scribe parser which has been deleted for a while

Link to tracking Issue(s):

Testing:

Documentation:

Comment on lines 96 to 106
func (c *Config) GetReceivers() []parser.ComponentPortParser {
var receiverList []parser.ComponentPortParser
for name, config := range c.Receivers.Object {
parser, err := receiver.For(name, config)
if err != nil {
continue
}
receiverList = append(receiverList, parser)
}
return receiverList
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking we could even introduce a full struct for "keys" or something... but that feels like maybe a slippery slope!

"flinkmetrics": {},
"couchdb": {},
}
genericReceivers = map[string][]parser.SinglePortOption{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pretty much all of our receivers can be done without any customization beyond what's here

@@ -71,36 +71,35 @@ func ConfigToComponentPorts(logger logr.Logger, cType ComponentType, config map[
}

ports := []corev1.ServicePort{}
for key, val := range components {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this function doesn't entirely work yet. I need to refactor this to be far simpler

return []monitoringv1.PodMetricsEndpoint{}
}
exporterPorts, err := adapters.ConfigToComponentPorts(logger, adapters.ComponentTypeExporter, config)
exporterPorts, err := adapters.ConfigToComponentPorts(logger, adapters.ComponentTypeExporter, otelcol.Spec.Config.Exporters.Object)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

also doesn't work yet

Comment on lines +28 to +33
func NewPrometheusExporterParser(name string, config interface{}) (parser.ComponentPortParser, error) {
return parser.CreateParser(
parser.WithSinglePort(defaultPrometheusPort,
parser.WithTargetPort(defaultPrometheusPort),
parser.WithProtocol(corev1.ProtocolTCP)),
)(name, config)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a million times cleaner :)

@@ -90,6 +114,62 @@ type Config struct {
Service Service `json:"service" yaml:"service"`
}

// GetEnabledComponents constructs a list of enabled components by component type.
func (c *Config) GetEnabledComponents() map[ComponentType]map[string]interface{} {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a pretty simple change to break out, it will trim a few hundred lines too!

@jaronoff97
Copy link
Contributor Author

closing this in favor of a much more broken up pr in #2896 and #2915

@jaronoff97 jaronoff97 closed this Apr 30, 2024
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.

Introduce intermediary structures for config handling
1 participant