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

[otelcol] Allow passing confmap.Providers to otelcol.Collector #9228

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

evan-bradley
Copy link
Contributor

@evan-bradley evan-bradley commented Jan 5, 2024

Description:

One way to work toward #4759. This implements the second approach that I've outlined here: #4759 (comment).

I think the main advantage of this approach is that it cleans up the API for the package. otelcol.ConfigProvider is a fairly thin wrapper around confmap.Resolver, so I think we could ultimately remove the interface, and any custom functionality for config merging or unmarshaling could be exposed to users through settings rather through a custom implementation.

Link to tracking Issue:

Works toward #4759

Testing:

Unit tests

Documentation:

Added Godoc comments.

Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (f11c5bb) 90.70% compared to head (32ddd03) 90.74%.

Files Patch % Lines
otelcol/collector.go 92.85% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9228      +/-   ##
==========================================
+ Coverage   90.70%   90.74%   +0.03%     
==========================================
  Files         347      347              
  Lines       18199    18212      +13     
==========================================
+ Hits        16507    16526      +19     
+ Misses       1369     1365       -4     
+ Partials      323      321       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@evan-bradley evan-bradley force-pushed the pass-confmap-providers branch 9 times, most recently from 8a1ed54 to adae484 Compare January 18, 2024 21:56
@evan-bradley evan-bradley marked this pull request as ready for review January 18, 2024 22:47
@evan-bradley evan-bradley requested review from a team and codeboten January 18, 2024 22:47
@evan-bradley evan-bradley force-pushed the pass-confmap-providers branch from adae484 to 652dad4 Compare January 23, 2024 12:02
@evan-bradley
Copy link
Contributor Author

This should be ready for review.

cc @mx-psi

otelcol/collector.go Outdated Show resolved Hide resolved
@evan-bradley evan-bradley force-pushed the pass-confmap-providers branch 2 times, most recently from c783317 to c63397c Compare January 23, 2024 16:35
otelcol/collector.go Show resolved Hide resolved
@evan-bradley
Copy link
Contributor Author

@bogdandrutu Could you give this another look?

@evan-bradley
Copy link
Contributor Author

@bogdandrutu @mx-psi Any additional thoughts on this? I think this is good to go, and will pair well with #9516.

@mx-psi
Copy link
Member

mx-psi commented Feb 13, 2024

@bogdandrutu will merge this tomorrow unless you raise any objections by then

@mx-psi
Copy link
Member

mx-psi commented Feb 14, 2024

@evan-bradley can you fix the conflict?

@evan-bradley evan-bradley force-pushed the pass-confmap-providers branch from 733c62d to 5494cfb Compare February 16, 2024 00:06
@evan-bradley
Copy link
Contributor Author

Thanks @mx-psi. Should be good now.

@evan-bradley evan-bradley force-pushed the pass-confmap-providers branch from dc39b02 to 082a2b8 Compare February 16, 2024 13:08
@evan-bradley evan-bradley force-pushed the pass-confmap-providers branch from 082a2b8 to 32ddd03 Compare February 20, 2024 20:07
@mx-psi mx-psi merged commit df6f8fd into open-telemetry:main Feb 29, 2024
46 checks passed
@github-actions github-actions bot added this to the next release milestone Feb 29, 2024
kasia-kujawa added a commit to SumoLogic/sumologic-otel-collector that referenced this pull request Mar 7, 2024
changes which impacts update:
- httpforwarder: Remove extension named httpforwarder, use httpforwarderextension instead
  ref: open-telemetry/opentelemetry-collector-contrib#24171
- spanmetricsprocessor: Remove spanmetrics processor
  ref: open-telemetry/opentelemetry-collector-contrib#29567
- confighttp: Remove deprecated HTTPClientSettings, NewDefaultHTTPClientSettings, and CORSSettings.
  ref: open-telemetry/opentelemetry-collector#9625
- ConfigProvider is deprecated, use ConfigProviderSettings instead
  ref: open-telemetry/opentelemetry-collector#9228
kasia-kujawa added a commit to SumoLogic/sumologic-otel-collector that referenced this pull request Mar 7, 2024
changes which impacts update:
- httpforwarder: Remove extension named httpforwarder, use httpforwarderextension instead
  ref: open-telemetry/opentelemetry-collector-contrib#24171
- spanmetricsprocessor: Remove spanmetrics processor
  ref: open-telemetry/opentelemetry-collector-contrib#29567
- confighttp: Remove deprecated HTTPClientSettings, NewDefaultHTTPClientSettings, and CORSSettings.
  ref: open-telemetry/opentelemetry-collector#9625
- ConfigProvider is deprecated, use ConfigProviderSettings instead
  ref: open-telemetry/opentelemetry-collector#9228
mx-psi pushed a commit that referenced this pull request Apr 18, 2024
…ings (#9516)

**Description:**

Follows
#9443,
relates to
#9513.

This builds on
#9228 to
demonstrate the concept.

This shows one way of extending the otelcol APIs to allow passing
converters and providers from the builder with the new settings structs
for each type.

I think this approach has a few advantages:
1. This follows our pattern of passing in "factory" functions instead of
instances to the object that actually uses the instances.
2. Makes the API more declarative: the settings specify which modules to
instantiate and which settings to instantiate them with, but don't
require the caller to actually do this.
3. Compared to the current state, this allows us to update the config at
different layers. A distribution's `main.go` file can specify the
providers/converters it wants and leave the settings to be created by
`otelcol.Collector`.

The primary drawbacks I see here are:
1. This is a little more opinionated since you don't have access to the
converter/provider instances or control how they are instantiated. I
think this is acceptable and provides good encapsulation.
2. The scheme->provider map can now only be specified by the providers'
schemes, which is how it is currently done by default. I would want to
hear what use cases we see for more complex control here that
necessitates using schemes not specified by the providers.

cc @mx-psi

---------

Co-authored-by: Evan Bradley <evan-bradley@users.noreply.github.com>
@splunkericl
Copy link
Contributor

otelcol.ConfigProvider is a fairly thin wrapper around confmap.Resolver, so I think we could ultimately remove the interface, and any custom functionality for config merging or unmarshaling could be exposed to users through settings rather through a custom implementation.

Hey @evan-bradley, I just noticed this change today. We have a custom implementation of ConfigProvider mostly leveraging Watch() method to update our collector configurations dynamically. I don't see how the Watch method can be triggered with the new ResolverSettings?

@mx-psi
Copy link
Member

mx-psi commented Apr 19, 2024

@splunkericl can you file an issue for this?

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.

6 participants