Skip to content

Conversation

@pjanotti
Copy link
Contributor

Why

The lifetime of extensions shouldn't be tied to single creation and start. It should be possible to create multiple instances even if they are limited to having only one active instance. This allows changing the extensions without restarting the process.

What

Description:
Ensure that extensions can be created and started multiple times. This change adds a test to ensure all extension types can be created, started, and stopped multiple times and fixes the issues found during the test of the default extensions.

  1. Two extensions (healthcheckextension and zpagesextension) were being limited to be created only once per process. The artificial limitation was removed;
  2. pprofextension should only have one extension active since its settings are global to the process. The extension now controls for active instances, not the creation of instances, since it is more appropriate.

Testing:

  • Added a test helper to validate the life-cycle of extensions and enabled it for all default extensions.
  • Manual tests with a modified version of the collector that cycled the extensions and pipelines many times.

Adds a test to ensure all extension types can be created, started, and stopped multiple times. Fix the issues found with the test on the extensions.
@pjanotti pjanotti requested a review from a team March 11, 2021 23:31
@codecov
Copy link

codecov bot commented Mar 11, 2021

Codecov Report

Merging #2679 (c41e585) into main (4e7df02) will increase coverage by 0.05%.
The diff coverage is 92.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2679      +/-   ##
==========================================
+ Coverage   91.73%   91.79%   +0.05%     
==========================================
  Files         290      290              
  Lines       15614    15633      +19     
==========================================
+ Hits        14324    14350      +26     
+ Misses        892      886       -6     
+ Partials      398      397       -1     
Impacted Files Coverage Δ
extension/healthcheckextension/factory.go 100.00% <ø> (ø)
extension/pprofextension/factory.go 85.71% <ø> (-1.79%) ⬇️
extension/zpagesextension/factory.go 85.71% <ø> (-1.79%) ⬇️
extension/pprofextension/pprofextension.go 89.74% <88.88%> (+37.56%) ⬆️
...nsion/healthcheckextension/healthcheckextension.go 92.59% <100.00%> (+1.28%) ⬆️
extension/zpagesextension/zpagesextension.go 92.85% <100.00%> (+1.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e7df02...c41e585. Read the comment docs.

Copy link
Member

@tigrannajaryan tigrannajaryan left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, a couple minor comments. Also, the test failed on CI.

Comment on lines -57 to -64
// The runtime settings are global to the application, so while in principle it
// is possible to have more than one instance, running multiple does not bring
// any value to the service.
// In order to avoid this issue we will allow the creation of a single
// instance once per process while keeping the private function that allow
// the creation of multiple instances for unit tests. Summary: only a single
// instance can be created via the factory.
if !atomic.CompareAndSwapInt32(&instanceState, instanceNotCreated, instanceCreated) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this comment was explaining nicely the motivation, why do you need to do it differently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment applies to pprof since it is the one that has runtime settings for the whole process. The comments for pprof were moved to the start method.

@pjanotti
Copy link
Contributor Author

pjanotti commented Mar 12, 2021

test failed on CI.

I can't repro this locally so far, I will try some variations but may have to resort to attempting merges without certainty about the CI issue.

Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

As pointed in the other comment, let's try to limit the new public API.

@tigrannajaryan
Copy link
Member

@bogdandrutu are we good to merge this?

@bogdandrutu bogdandrutu merged commit 0215107 into open-telemetry:main Mar 17, 2021
@pjanotti pjanotti deleted the verify-lifecycle-for-extensions branch March 17, 2021 03:04
hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this pull request Apr 27, 2023
Troels51 pushed a commit to Troels51/opentelemetry-collector that referenced this pull request Jul 5, 2024
---------

Co-authored-by: Marc Alff <[email protected]>
Co-authored-by: Lalit Kumar Bhasin <[email protected]>
Co-authored-by: Tom Tan <[email protected]>
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