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

Support a global MeterProvider in go.opentelemetry.io/otel #3818

Merged
merged 9 commits into from
Mar 1, 2023

Conversation

MrAlias
Copy link
Contributor

@MrAlias MrAlias commented Feb 28, 2023

Fixes #3816

The current support of a global MeterProvider is provided by go.opentelemetry.io/otel/metric/global. In the process of releasing the go.opentelemetry.io/otel/metric as stable, this functionality is being moved to go.opentelemetry.io/otel.

  • Deprecate the existing go.opentelemetry.io/otel/metric/global. This will be removed in the v1.15.0 release after the release candidate phases publish this change.
  • Move the error handling of the otel package to otel/internal/global. This is done to resolve the import cycle of otel/internal/metric depending on this error handling functionality.
  • Copy the functionality from otel/metric/global into otel.
    • Note, the MeterProvider() function is renamed to GetMeterProvider() to match GetTracerProvider()
  • Update the project to not use the deprecated otel/metric/global package anymore.

This approach wraps the existing functionality in otel/metric/global with the added functionality in otel. The opposite (moving the functionality to otel and wrapping otel/metric/global with otel) cannot be implemented without an import cycle (otel imports otel/metric and the wrap would mean otel/metric/global would import otel). Also, otel cannot depend on the underlying implementation in otel/metric/internal/global because that internal package is a sub-directory of otel.

To avoid the import cycle, the otel/metric package needs to not import
otel. To achieve this, the error handling implementation is moved to the
otel/internal/global package where both can import the needed
functionality.
@MrAlias MrAlias added pkg:API Related to an API package area:metrics Part of OpenTelemetry Metrics labels Feb 28, 2023
@MrAlias MrAlias added this to the v1.15.0-RC1 milestone Feb 28, 2023
@MrAlias MrAlias changed the title Support a global MeterProvider in go.opentelemetry.io/otel Support a global MeterProvider in go.opentelemetry.io/otel Feb 28, 2023
@codecov
Copy link

codecov bot commented Feb 28, 2023

Codecov Report

Merging #3818 (b51e31f) into main (c39e625) will decrease coverage by 0.1%.
The diff coverage is 63.0%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #3818     +/-   ##
=======================================
- Coverage   81.7%   81.7%   -0.1%     
=======================================
  Files        167     170      +3     
  Lines      12453   12474     +21     
=======================================
+ Hits       10175   10192     +17     
- Misses      2063    2067      +4     
  Partials     215     215             
Impacted Files Coverage Δ
metric/global/global.go 66.6% <ø> (ø)
metric/internal/global/instruments.go 60.8% <0.0%> (ø)
metric/internal/global/meter.go 93.8% <0.0%> (ø)
metric.go 66.6% <66.6%> (ø)
handler.go 100.0% <100.0%> (ø)
internal/global/handler.go 100.0% <100.0%> (ø)
sdk/trace/batch_span_processor.go 81.9% <0.0%> (+0.8%) ⬆️

@MrAlias
Copy link
Contributor Author

MrAlias commented Feb 28, 2023

Follow up to this PR: #3819

@MrAlias MrAlias merged commit 8139361 into open-telemetry:main Mar 1, 2023
@MrAlias MrAlias deleted the dep-global-metric branch March 1, 2023 19:16
@MrAlias MrAlias mentioned this pull request Mar 1, 2023
MrAlias added a commit to MrAlias/opentelemetry-go that referenced this pull request Apr 11, 2023
MrAlias added a commit that referenced this pull request Apr 13, 2023
)

* Revert "Remove the deprecated `otel/metric/global` pkg (#3829)"

This reverts commit 60f7d42.

* Revert "Support a global MeterProvider in `go.opentelemetry.io/otel` (#3818)"

This reverts commit 8139361.

* Remove top level metric global

* Add change to changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metrics Part of OpenTelemetry Metrics pkg:API Related to an API package
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Deprecate the otel/metric/global package by moving its functionality to otel
3 participants