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

Fix initialization of the MetricProvider #5571

Merged
merged 1 commit into from
Jun 29, 2022

Conversation

bogdandrutu
Copy link
Member

@bogdandrutu bogdandrutu commented Jun 21, 2022

The problem was that the MetricProvider is initialized into the "service.telemetry.MetricProvider" after components were created, so all components will get a no-op implementation even if the feature gate is enabled. This change was not a trivial change because the process telemetry initialization requires the ballast size, which is available after the extensions are initialized, because of that I split the initialization of the MetricProvider/oc.Registry from the initialization of the process telemetry.

Signed-off-by: Bogdan Drutu [email protected]

@bogdandrutu bogdandrutu requested review from a team and dmitryax June 21, 2022 22:52
@codecov
Copy link

codecov bot commented Jun 21, 2022

Codecov Report

Merging #5571 (8255a54) into main (bb45d00) will decrease coverage by 0.00%.
The diff coverage is 69.69%.

@@            Coverage Diff             @@
##             main    #5571      +/-   ##
==========================================
- Coverage   91.28%   91.27%   -0.01%     
==========================================
  Files         191      191              
  Lines       11302    11304       +2     
==========================================
+ Hits        10317    10318       +1     
- Misses        784      785       +1     
  Partials      201      201              
Impacted Files Coverage Δ
service/service.go 56.52% <37.50%> (-2.81%) ⬇️
service/collector.go 76.22% <75.00%> (-0.33%) ⬇️
service/telemetry.go 82.73% <81.57%> (+5.49%) ⬆️
pdata/internal/common.go 91.85% <0.00%> (-0.75%) ⬇️

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 bb45d00...8255a54. 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.

I feel like telemetry initialization could use some refactoring. It is a bit difficult to understand and service also works with the internal fields of colTelemetry, violating its encapsulation and separation of concerns.
Can be done in a separate PR.

@@ -133,6 +133,7 @@ func TestCollectorReportError(t *testing.T) {
}

func TestCollectorFailedShutdown(t *testing.T) {
t.Skip("This test was using telemetry shutdown failure, switch to use a component that errors on shutdown.")
Copy link
Member

Choose a reason for hiding this comment

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

Is this unnecessary now? Maybe delete it?

Copy link
Member Author

Choose a reason for hiding this comment

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

As you can see it is a TODO, to use a different design, and re-enable. Not sure how to do this without blowing the size of this PR.

service/service.go Outdated Show resolved Hide resolved
service/service.go Outdated Show resolved Hide resolved
service/service.go Outdated Show resolved Hide resolved
if err = srv.colTelemetry.init(set.BuildInfo, srv.telemetry.Logger, set.Config.Service.Telemetry, set.AsyncErrorChannel); err != nil {
return nil, fmt.Errorf("failed to initialize telemetry: %w", err)
}
srv.telemetry.MeterProvider = srv.colTelemetry.mp
Copy link
Member

Choose a reason for hiding this comment

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

Can we return this from colTelemetry.init()? Generally, I think we should avoid working with the private fields of colTelemetry here. Perhaps to enforce it move colTelemetry to a separate package.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do that, when moving to service/telemetry package, in a soon followup PR.

@bogdandrutu bogdandrutu force-pushed the fixmetricproviderinit branch 4 times, most recently from 459f068 to e68ad80 Compare June 28, 2022 14:18
@bogdandrutu bogdandrutu force-pushed the fixmetricproviderinit branch from e68ad80 to e8005ac Compare June 29, 2022 10:18
The problem was that the MetricProvider is initialized into the "service.telemetry.MetricProvider" after components were created. This change was not a trivial change because the process telemetry initialization requires the ballast size, which is available after the extensions are initialized, because of that I split the initialization of the MetricProvider/oc.Registry from the initialization of the process telemetry.

Signed-off-by: Bogdan Drutu <[email protected]>
@bogdandrutu bogdandrutu force-pushed the fixmetricproviderinit branch from e8005ac to 8255a54 Compare June 29, 2022 10:35
@bogdandrutu bogdandrutu merged commit d63aea3 into open-telemetry:main Jun 29, 2022
@bogdandrutu bogdandrutu deleted the fixmetricproviderinit branch June 29, 2022 12:54
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.

2 participants