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
Conversation
apis/v1beta1/config.go
Outdated
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 | ||
} |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
func NewPrometheusExporterParser(name string, config interface{}) (parser.ComponentPortParser, error) { | ||
return parser.CreateParser( | ||
parser.WithSinglePort(defaultPrometheusPort, | ||
parser.WithTargetPort(defaultPrometheusPort), | ||
parser.WithProtocol(corev1.ProtocolTCP)), | ||
)(name, config) |
There was a problem hiding this comment.
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{} { |
There was a problem hiding this comment.
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!
Description: Refactors the codebase for allowing typed parsers. Removes the
zipkin-scribe
parser which has been deleted for a whileLink to tracking Issue(s):
Testing:
Documentation: