Skip to content

Conversation

MrLotU
Copy link
Collaborator

@MrLotU MrLotU commented May 4, 2021

Fixes #48

SwiftPrometheus 1.0.0 Alpha 10 introduced a bug where MetricsSystem.prometheus() would no longer work, since it looks for a PrometheusClient instance, but since Alpha 10 it's a wrapper struct.

Introduced new with this PR is a PrometheusWrappedMetricsFactory protocol that should be used by any MetricsFactory wrapping PrometheusClient in any way.

MetricsSystem.prometheus() will now look for a PrometheusWrappedMetricsFactory and return the underlying client

Checklist

  • The provided tests still run.
  • I've created new tests where needed.
  • I've updated the documentation if necessary.

Copy link
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Looks fine to me, thanks for the ping!

Why do we do the extra dance with the factory wrapper (of: nowadays? AFAIR originally we'd just bootstrap with the client itself right?

func testGetPrometheus() {
MetricsSystem.bootstrapInternal(NOOPMetricsHandler.instance)
XCTAssertThrowsError(try MetricsSystem.prometheus())
MetricsSystem.bootstrapInternal(PrometheusMetricsFactory(client: self.prom))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I love that style but I guess this was introduced some time recently for some reason?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, see #46 and #44 for full context.

Using PrometheusClient directly limited some options :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, so it's for the configs etc. Thanks for the pointer; perhaps we can sugar the configuration-less case to just bootstrap with prometheus client as parameter but that's minor...

Thanks for the pointer :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No problem. And definitely open to add sugar here 👍🏻

@MrLotU MrLotU merged commit 42edfe0 into master May 4, 2021
@MrLotU MrLotU deleted the FixMetricsSystemPrometheus branch May 4, 2021 07:23
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.

Getting prometheusFactoryNotBootstrapped
2 participants