Skip to content

Instantly share code, notes, and snippets.

@jonatan-ivanov
Last active March 11, 2021 20:58
Show Gist options
  • Save jonatan-ivanov/5ca034a9dddd727b22c5e387e3157672 to your computer and use it in GitHub Desktop.
Save jonatan-ivanov/5ca034a9dddd727b22c5e387e3157672 to your computer and use it in GitHub Desktop.

Complicated API

  • As a user, it is somewhat complex and quite puzzling using the API
  • There are a lot of components
  • The components are doing different things as I would expect based on their names
  • I think it would worth a review and refactor to make it more usable.

Examples

  • GlobalMetricsProvider
    • Based on its name, it should provide Metrics instances
    • In fact, it provides two things neither of them are Metrics
      • get returns a MeterProvider
      • getMeter returns a Meter
  • MeterProvider
    • Based on its name, it should provide Meter instances
    • Its get method does return a Meter instance
    • But getDefault (means "get the default Meter") returns a MeterProvider
    • Should not getDefault be getDefaultInstance?
  • Meter
    • Its javadoc says: "Meter is a simple, interface that allows users to record measurements (metrics)."
    • In fact, Meter gives you builders
    • Isn't Meter something that you use to measure something?
    • Like a "thermometer" measures temperature a "barometer" measures pressure, etc.
  • Instrument
    • To me, this seems to be the component that should be called Meter
    • Its javadoc is a little confusing too: "Base interface for all metrics defined in this package."
  • LongCounterSdk
    • Based on its name, it is a special type of SDK not a special LongCounter
  • MetricProducer
    • It has one method: Collection<MetricData> collectAllMetrics();
    • Based on this, shouldn't it be called MetricCollector?
  • GlobalMetricsProvider and MetricProducer seems confusing next to each other
  • There are “missed” opportunities to use Java functional interfaces like Supplier for the Producer/Provider classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment