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

Rework type structure #223

Open
beorn7 opened this issue Aug 16, 2016 · 0 comments
Open

Rework type structure #223

beorn7 opened this issue Aug 16, 2016 · 0 comments

Comments

@beorn7
Copy link
Member

beorn7 commented Aug 16, 2016

Current issues:

  • Some interfaces are identical (Untyped and Gauge; Histogram and Summary; all the XxxFunc metrics), they are the same for Go (you could assign a Histogram to a Summary variable). The number of interfaces can be reduced a lot here.
  • Metric can be way less exposed as it is essentially only used internally by the registry. It's probably used by normal using mostly for testing, but it is planned to provide some test tools to make that unnecessary.
  • Interfaces like Gauge and Counter should just have the methods to manipulate the metrics value in instrumentation. Collector and Metric should be separate, and then have a GaugeCollector to return by NewGauge and such.
  • Consider making the various XxxVec interfaces so that we can hide MetricVec.

Overall, the number of exported types should be reduced drastically.

@beorn7 beorn7 added this to the v0.10 milestone Aug 19, 2016
beorn7 pushed a commit that referenced this issue Nov 18, 2016
- Point from Inc and Dec to Add and Sub in doc comments.

- Deprecate Untyped for direct instrumentation.

- Add a SetToCurrentTime method to Gauge

Note that adding the SetToCurrentTime method is not really following
Go's principle of lean interfaces. However, the Gauge interface is
already quite fat. (The only methods really required are Set and
Add. Everything else could be expressed in terms of those two.) So we
have already quite a few "convenience" methods traditionally, so I
think we should stay consistent here.

The alternatives would be:

- Not support SetToCurrentTime at all (it's only a SHOULD in the
  guidelines).

- A top level function `SetToCurrentTime(Gauge)`.

- Just a helper `CurrentTime()` that returns the curent unix time in
  seconds as a float (which is pretty verbose using the standard
  library, see code in this commit). This would allow
  `myGauge.Set(CurrentTime)`.

Weighing all circumstances, I believe the way in this commit is the
least evil. Issue #223 could be used to rework interfaces more
fundamentally in a breaking change if feasible.
beorn7 pushed a commit that referenced this issue Nov 18, 2016
- Deprecate Untyped for direct instrumentation.

- Add a SetToCurrentTime method to Gauge

Note that adding the SetToCurrentTime method is not really following
Go's principle of lean interfaces. However, the Gauge interface is
already quite fat. (The only methods really required are Set and
Add. Everything else could be expressed in terms of those two.) So we
have already quite a few "convenience" methods traditionally, so I
think we should stay consistent here.

The alternatives would be:

- Not support SetToCurrentTime at all (it's only a SHOULD in the
  guidelines).

- A top level function `SetToCurrentTime(Gauge)`.

- Just a helper `CurrentTime()` that returns the curent unix time in
  seconds as a float (which is pretty verbose using the standard
  library, see code in this commit). This would allow
  `myGauge.Set(CurrentTime)`.

Weighing all circumstances, I believe the way in this commit is the
least evil. Issue #223 could be used to rework interfaces more
fundamentally in a breaking change if feasible.
@dosubot dosubot bot added the stale label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant