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

[API EPIC 4/4] Fix tests and examples #2587

Merged
merged 21 commits into from Mar 2, 2022

Conversation

MadVikingGod
Copy link
Contributor

@MadVikingGod MadVikingGod commented Feb 7, 2022

This is a series of patches to update the metrics API. Here is the diff against the previous step

This final patch fixes tests and examples. Makes the SDK once again buildable.

@codecov
Copy link

codecov bot commented Feb 7, 2022

Codecov Report

Merging #2587 (4792a7c) into main (b66c902) will decrease coverage by 0.3%.
The diff coverage is 56.4%.

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #2587     +/-   ##
=======================================
- Coverage   76.0%   75.6%   -0.4%     
=======================================
  Files        174     171      -3     
  Lines      12286   11629    -657     
=======================================
- Hits        9339    8799    -540     
+ Misses      2704    2617     -87     
+ Partials     243     213     -30     
Impacted Files Coverage Δ
bridge/opencensus/aggregation.go 95.7% <ø> (ø)
exporters/otlp/otlpmetric/exporter.go 60.6% <ø> (ø)
...otlp/otlpmetric/internal/metrictransform/metric.go 78.1% <ø> (ø)
...rs/otlp/otlpmetric/internal/otlpmetrictest/data.go 0.0% <ø> (ø)
...tlp/otlpmetric/internal/otlpmetrictest/otlptest.go 0.0% <0.0%> (ø)
exporters/prometheus/prometheus.go 65.2% <ø> (ø)
exporters/stdout/stdoutmetric/metric.go 81.9% <ø> (ø)
metric/config.go 0.0% <0.0%> (-66.0%) ⬇️
metric/instrument/config.go 0.0% <0.0%> (ø)
metric/nonrecording/instruments.go 0.0% <0.0%> (ø)
... and 33 more

@MadVikingGod MadVikingGod changed the title [API EPIC 4/4] [API EPIC 4/4] Fix tests and examples Feb 7, 2022
Copy link
Contributor

@jmacd jmacd left a comment

Choose a reason for hiding this comment

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

🔢 🥇

@jmacd
Copy link
Contributor

jmacd commented Feb 7, 2022

There's a question of whether the new code in sdk/metric/sdkapi/wrap.go deserves a test, or whether it's considered "tested enough" by various other tests e.g., sdk/metric/correct_test.go for an end-of-life codebase? I say yes, approve. LGTM, thanks @MadVikingGod! 💥


histogram := metric.Must(meter).NewFloat64Histogram("ex.com.two")
counter := metric.Must(meter).NewFloat64Counter("ex.com.three")
histogram, err := meter.SyncFloat64().Histogram("ex.com.two")
Copy link
Contributor

Choose a reason for hiding this comment

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

I do really miss Must() for instrument initialization

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that the Must() forms tend to make the code read better, but they really don't make sense in this world. Both because this would either mean extra API surface, but also because our meter <-> instrument relation is different from both Prometheus and opencensus. Both had a static implementation of our meter, and it could create new instruments at init. That model doesn't work very well when you have to initialize your meter before you register instruments.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
exporters/otlp/otlpmetric/otlpmetricgrpc/example_test.go Outdated Show resolved Hide resolved
metric/noop.go Outdated Show resolved Hide resolved
Copy link
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

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

Should we deprecate the old packages we are moving to new locations instead of deleting them? Seems like just moving will create more work for us when we go to clean all the abandoned packages up.

@MadVikingGod
Copy link
Contributor Author

So we move the 4 packages because they are in use currently by the SDK. If were to keep them and add a deprecated then:

  1. We will still break current users because there are incompatible changes in the API.
  2. Every build with the SDK (our current state of the art) will complain that it is deprecated.

If the goal has shifted again to not break current users, then we should probably publish this as metric/v2 (the SDK changes can probably stay), and leave the current metric alone.

@MrAlias
Copy link
Contributor

MrAlias commented Feb 25, 2022

I'm not as concerned with breaking users of this experimental package. I am worried about this package indefinitely being listed on pkg.go.dev and having to field questions in the future because people are still importing the wrong, abandoned, package. As well as there being a large cognitive overhead for new users looking at the project trying to understand how these abandoned packages will fit into what they need to do without realizing they are not relevant.

Should we publish a patch release with a deprecation of all the packages we plan to remove prior to releasing this?

@MadVikingGod
Copy link
Contributor Author

I held off merging because I think that the deprecation deserves a response. Yes, this does create more work for us later, but I think that work can happen after this release. Any of these solutions only work if their respective tags (deprate/retract) exist in the @latest version of the module, so there would have to be changes in v0.28.0 (or the version we start with) and onwards.

We do have an issue that does overlap with this problem (#2328). There have been at different times 3 ways to solve this

  • Deprecate the package,
  • Retract the versions
  • Deprecate the modules

There are drawbacks to each, and none of them will fix builds failing to upgrade because of changes to the exported types. This is something that we will have to educate experimental users on until APIs become stable.

I will post a more detailed solution in the linked issue.

@MrAlias
Copy link
Contributor

MrAlias commented Feb 28, 2022

This is something that we will have to educate experimental users on until APIs become stable.

Adding a deprecation notice to a pkg/module is a great way to achieve this. It is included in the documentation for a package and either the first or second place a user going to look when they have issues.

You mentioned this in the linked issue:

Mods that have been removed. I detailed this above, I think publishing a version of each that is patch version bump with a deprecate for each can give users a hint of where these packages may have gone.

Why not do that here?

I'm not advocating deprecating things within experimental modules that are changing, that comes with the territory. I am say we should add deprecation notices to go.mod files that are being deleted in this PR and not delete them to address the solution you are describing above. Otherwise, this only adds the future burden resurrecting these deleted modules to deprecate them then.

@MadVikingGod
Copy link
Contributor Author

MadVikingGod commented Feb 28, 2022

In this process we only removed one module internal/metric, the rest were packages under the metric mod.

I could restore this, but it would still have to have breaking changes, or we restore more than just the one mod because it references the metric/sdkapi which doesn't exist anymore. Would that unblock this?

Or are you suggesting to accept the total breakage and just leave a go.mod and nothing else?

@Aneurysm9
Copy link
Member

Since the only module removed is internal I don't think we need to bother deprecating it. I think the rest fall into the same bucket of packages removed from modules that continue to exist. We should tackle that under #2328.

@MrAlias
Copy link
Contributor

MrAlias commented Mar 2, 2022

Since the only module removed is internal I don't think we need to bother deprecating it. I think the rest fall into the same bucket of packages removed from modules that continue to exist. We should tackle that under #2328.

sure 👍

@MadVikingGod MadVikingGod merged commit 18f4cb8 into open-telemetry:main Mar 2, 2022
@MadVikingGod MadVikingGod deleted the metrics-api/4-tests branch March 4, 2022 15:23
hanyuancheung pushed a commit to hanyuancheung/opentelemetry-go that referenced this pull request Mar 5, 2022
* Empty All of the metrics dir

* Add instrument api with documentation

* Add a NoOp implementation.

* Updated to the new config standard

* Address PR comments

* This change moves components to sdk/metrics

The Moved components are:
- metric/metrictest
- metric/number
- metric/internal/registry
- metric/sdkapi

* The SDK changes necessary to satasify the new api

* This fixes the remaing tests.

* Update changelog

* refactor the Noop meter and instruments into one package.

* Renamed pkg.Instruments to pkg.InstrumentProvider

Co-authored-by: Aaron Clawson <MadVikingGod@users.noreply.github.com>
@MrAlias MrAlias mentioned this pull request Mar 23, 2022
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.

None yet

5 participants