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

feat!: configure metrics implementation as a module instead of shipping a built-in version #1471

Merged
merged 17 commits into from
Nov 5, 2022

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Nov 4, 2022

Instead of a built-in metrics object, allow the user to pass the metrics collection method of their choice.

Currenltly there's a @libp2p/prometheus-metrics implementation, there may be others in the future.

Before:

import { createLibp2p } from 'libp2p'

const node = createLibp2p({
  metrics: {
    enabled: true
  }
})

After:

import { createLibp2p } from 'libp2p'
import { prometheusMetrics } from '@libp2p/prometheus-metrics'

const node = createLibp2p({
  metrics: prometheusMetrics()
})

BREAKING CHANGE: the libp2p opts have changed to accept a metrics object factory function instead of a config object

Instead of a built-in metrics object, allow the user to pass the
metrics collection method of their choice.

Currenltly there's a `@libp2p/prometheus-metrics` implementation,
there may be others in the future.

Before:

```js
import { createLibp2p } from 'libp2p'

const node = createLibp2p({
  metrics: {
    enabled: true
  }
})
```

After:

```js
import { createLibp2p } from 'libp2p'
import { prometheusMetrics } from '@libp2p/prometheus-metrics'

const node = createLibp2p({
  metrics: prometheusMetrics()
})
```

BREAKING CHANGE: the libp2p opts have changed to accept a metrics object factory function instead of a config object
Removes the built in metrics object in favour of accepting a factory
that returns an object that implements the `Metrics` interface.

BREAKING CHANGE: node config now takes a `Metrics` factory instead of metrics configuration
@achingbrain achingbrain merged commit 5e9dcf3 into master Nov 5, 2022
@achingbrain achingbrain deleted the feat/make-metrics-a-config-module branch November 5, 2022 22:46
@p-shahi p-shahi mentioned this pull request Nov 7, 2022
2 tasks
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.

1 participant