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

Introduce metric constructor errors, MeterMust wrapper #529

Merged
merged 12 commits into from
Mar 11, 2020

Conversation

jmacd
Copy link
Contributor

@jmacd jmacd commented Mar 7, 2020

This is a partial implementation for #514. It will be easier if we introduce the API change in one PR and implement error checking in a second PR.

This introduces metric.Must() to wrap a Meter so that its instrument constructors return an error.

Also, #174 is mentioned because there is a new requirement for the global package to handle errors that might occur during deferred constructors.

Note this retains some refactoring of the Meter API into Measure and Observer constructor sub-interfaces. This adopts the terminology that has been developed in open-telemetry/oteps#88, calling the new constructors either Measure or Observer type.

@jmacd jmacd added the area:metrics Part of OpenTelemetry Metrics label Mar 9, 2020
@jmacd
Copy link
Contributor Author

jmacd commented Mar 9, 2020

This is now a WIP having received feedback on Gitter, see https://gitter.im/open-telemetry/opentelemetry-go?at=5e66b07cff8bf14a54470408

@jmacd jmacd changed the title Introduce metric constructor errors, Must variations WIP: Introduce metric constructor errors, Must variations Mar 9, 2020
@jmacd jmacd force-pushed the jmacd/must_metric branch from 216bc8b to 3fc1244 Compare March 11, 2020 06:35
@jmacd jmacd changed the title WIP: Introduce metric constructor errors, Must variations Introduce metric constructor errors, Must wrapper Mar 11, 2020
@jmacd
Copy link
Contributor Author

jmacd commented Mar 11, 2020

@MrAlias I moved the Must behavior into a wrapper as discussed.

PTAL

Copy link
Member

@krnowak krnowak left a comment

Choose a reason for hiding this comment

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

Looks good, but I have some questions.

api/metric/api.go Outdated Show resolved Hide resolved
api/metric/api.go Outdated Show resolved Hide resolved
api/metric/must.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.

I think this is a positive approach in general, I have a few questions about the implementation though.

The breaking apart of the Meter interface seems a bit like it is bloating the API with interfaces that will not be used and seems a bit concerning. I'm interested in the answer to @krnowak's question about whether the *Must interfaces could just be concret type or not.

As for the changes to include the Must function, I think that looks like a positive move.

api/metric/api.go Outdated Show resolved Hide resolved
api/metric/api.go Outdated Show resolved Hide resolved
@jmacd
Copy link
Contributor Author

jmacd commented Mar 11, 2020

PTAL @MrAlias specifically at https://github.com/open-telemetry/opentelemetry-go/pull/529/files#diff-6c9b0408a918b95cf12e9ac087068873

api/metric/must.go Outdated Show resolved Hide resolved
api/metric/noop.go Outdated Show resolved Hide resolved
@jmacd jmacd changed the title Introduce metric constructor errors, Must wrapper Introduce metric constructor errors, MeterMust wrapper Mar 11, 2020
Copy link
Member

@krnowak krnowak left a comment

Choose a reason for hiding this comment

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

One nit found.

api/metric/must.go Outdated Show resolved Hide resolved
@jmacd jmacd dismissed krnowak’s stale review March 11, 2020 18:28

Removed a sentence that was no longer true.

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.

Awesome work, and thanks for putting up with my pestering! 😄

@jmacd
Copy link
Contributor Author

jmacd commented Mar 11, 2020

Thanks for putting up with my rushing. 😀

@jmacd jmacd merged commit 4047c08 into open-telemetry:master Mar 11, 2020
@jmacd jmacd deleted the jmacd/must_metric branch March 11, 2020 18:58
MikeGoldsmith pushed a commit to MikeGoldsmith/opentelemetry-go that referenced this pull request Mar 13, 2020
…try#529)

* Update api for Must constructors, with SDK helpers

* Update for Must constructors, leaving TODOs about global errors

* Add tests

* Move Must methods into metric.Must

* Apply the feedback

* Remove interfaces

* Remove more interfaces

* Again...

* Remove a sentence about a dead inteface
@pellared pellared added this to the untracked milestone Nov 8, 2024
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants