Skip to content

Conversation

@rafaelwestphal
Copy link
Contributor

Description

This moves the check for processors in prometheus pipeline to the validate stage.

Related issue

b/435217702

How has this been tested?

Checklist:

  • Unit tests
    • Unit tests do not apply.
    • Unit tests have been added/modified and passed for this PR.
  • Integration tests
    • Integration tests do not apply.
    • Integration tests have been added/modified and passed for this PR.
  • Documentation
    • This PR introduces no user visible changes.
    • This PR introduces user visible changes and the corresponding documentation change has been made.
  • Minor version bump
    • This PR introduces no new features.
    • This PR introduces new features, and there is a separate PR to bump the minor version since the last release already.
    • This PR bumps the version.

}
receiverPipelines, err := receiver.Pipelines(ctx)
if err != nil {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Why continue here instead of return err?

for _, receiverPipeline := range receiverPipelines {
// Check the Ops Agent receiver type.
if receiverPipeline.ExporterTypes[subagent] == otel.GMP {
fmt.Println("processorIDs", processorIDs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the println here?

return nil
}

func validatePrometheusReceiver(receivers metricsReceiverMap, receiverIDs, processorIDs []string, subagent string, ctx context.Context) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] naming is hard but we should either rename or add a comment about why we do this validation. Or do both.

maybe something like validateNoCustomGMPProcessors or sth idk. What we're validating here is that if we are sending to GMP, then Ops Agent users can't configure any processors in this pipeline

for _, ID := range receiverIDs {
receiver, ok := receivers[ID]
if !ok {
continue // Some receivers might not be used.
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually reading this again - this looks incorrect. If !ok, then it looks like a receiver is used in the pipeline but there is no such receiver in the map?

Does another validator catch this error already or must we also return an error here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like validateComponentKeys will catch this for us. I would call that out and also return an error here but this error would never actually happen. Maybe we can panic too

@rafaelwestphal rafaelwestphal merged commit 09d9460 into master Sep 4, 2025
59 of 62 checks passed
@rafaelwestphal rafaelwestphal deleted the westphalrafael-refactor-validation branch September 4, 2025 00:55
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.

3 participants