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

Always pass fanout consumers to connector factory functions #7840

Merged
merged 3 commits into from
Jun 14, 2023

Conversation

mwear
Copy link
Member

@mwear mwear commented Jun 6, 2023

Description:
This is an implementation of #7673 (comment) which resolves some inconsistencies regarding fanout consumers and connectors. It updates the connector code to always pass a fanout consumer to connector factory functions (even if the connector emits to a single pipeline). This will likely pair with the work in #7673 to add helpers to construct connector routers (when needed) for tests.

Link to tracking Issue: #7672, #7673

Testing:
Unit testing

cc: @bogdandrutu @djaglowski

@mwear mwear requested review from a team and djaglowski June 6, 2023 23:11
@codecov
Copy link

codecov bot commented Jun 6, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.31 🎉

Comparison is base (897a316) 90.82% compared to head (66f15be) 91.14%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7840      +/-   ##
==========================================
+ Coverage   90.82%   91.14%   +0.31%     
==========================================
  Files         296      298       +2     
  Lines       14840    14912      +72     
==========================================
+ Hits        13478    13591     +113     
+ Misses       1087     1045      -42     
- Partials      275      276       +1     
Impacted Files Coverage Δ
service/internal/graph/nodes.go 97.18% <100.00%> (-0.04%) ⬇️

... and 18 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@djaglowski
Copy link
Member

Thanks for working this out @mwear.

the concrete type of the consumer passed in to the factory functions could differ from the real world if the helpers are not used

I may be overlooking something but ideally this is where we are able to lean on the interfaces (consumer.* and connector.*Router). I think it would be reasonable for a test scenario to provide its own implementation of either interface, which might behave differently that the fanout consumer. The most important thing is whether or not the interface is satisfied, but beyond that test expectations should generally be concerned with whether or not data was emitted to the correct consumer. Very few tests should specifically rely on the implementation details of the fanout consumer - I think maybe only integration tests, which may mutate the data after the connector has emitted it.

If the above makes sense, I am curious whether we need to make all these changes in one PR. In other words, is there anything technically that prevents us from only switching to always pass a fanout consumer into connector factory functions?

@mwear
Copy link
Member Author

mwear commented Jun 7, 2023

For this PR the only changes we really need are those made in graph to always pass in a fanout consumer. Separately we will need helpers create a fanout consumer (aka router) for connectors that need them. I am probably over doing (over thinking) things by worrying about connectors potentially being built with a consumer implementation that could differ from what the service will provide in the real world. I agree in most situations just relying on the regular consumer interfaces should be fine. Given that, we do not need to make the changes in the forward_connector_test and the changes made in the example_router_test are optional.

I think we can pare this PR down to just the changes to graph and omit the changes to the tests and we can work on the helpers separately in #7673 (I think I prefer the original naming).

@mwear mwear force-pushed the always_fanout branch 2 times, most recently from d331aa3 to b543fc6 Compare June 7, 2023 17:55
@bogdandrutu
Copy link
Member

overall I think this is a good PR, LGTM after fixing the comment.

@bogdandrutu bogdandrutu merged commit f919c67 into open-telemetry:main Jun 14, 2023
@github-actions github-actions bot added this to the next release milestone Jun 14, 2023
mwear added a commit to mwear/opentelemetry-collector that referenced this pull request Jun 14, 2023
the too few pipelines issue was resolved by open-telemetry#7840
mwear added a commit to mwear/opentelemetry-collector that referenced this pull request Jun 14, 2023
the too few pipelines issue was resolved by open-telemetry#7840
mwear added a commit to mwear/opentelemetry-collector-contrib that referenced this pull request Jul 5, 2023
Now that open-telemetry/opentelemetry-collector#7840
merged, we can expect a fanout consumer to be passed consistently to a
connector factory. We still check for an error casting the consumer
to a connector router, but this would only happen if a breaking change
was introduced to the connector internals.
djaglowski added a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Jul 6, 2023
**Description:** 

This PR introduces a connector version of the routing processor. It
currently supports routing based on resource attributes OTTL statements
only. Context based routing will be added later in a followup PR.

There are two issues regarding fanout consumers that are being addressed
in the core repo.
* The routing connector needs to be a consumer in multiple pipelines
(the routing processor can route to a single exporter).
* Will be resolved by:
open-telemetry/opentelemetry-collector#7840
* We need the ability to create connector routers to facilitate testing.
I had to temporarily copy the fanoutconsumer package into the routing
connector codebase due to package visibility issues.
* Will be resolved by:
open-telemetry/opentelemetry-collector#7673

We can address these issues as the relevant PRs land on the core repo.

cc: @djaglowski, @jpkrohling, @kovrus 

**Link to tracking Issue:** 
#19738

**Testing:** 
Unit / manual

**Documentation:**
The readme has been ported from the routing processor

---------

Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
Co-authored-by: Ruslan Kovalov <ruslan.kovalov@grafana.com>
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