Skip to content

Commit

Permalink
chore: update readme and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Jan 7, 2025
1 parent dec8178 commit a9c6e9d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
16 changes: 4 additions & 12 deletions packages/metrics-opentelemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,19 @@ const node = await createLibp2p({
# Install

```console
$ npm i @libp2p/simple-metrics
```

## Browser `<script>` tag

Loading this module through a script tag will make its exports available as `Libp2pSimpleMetrics` in the global namespace.

```html
<script src="https://unpkg.com/@libp2p/simple-metrics/dist/index.min.js"></script>
$ npm i @libp2p/opentelemetry-metrics
```

# API Docs

- <https://libp2p.github.io/js-libp2p/modules/_libp2p_simple_metrics.html>
- <https://libp2p.github.io/js-libp2p/modules/_libp2p_opentelemetry_metrics.html>

# License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](https://github.com/libp2p/js-libp2p/blob/main/packages/metrics-simple/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](https://github.com/libp2p/js-libp2p/blob/main/packages/metrics-simple/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
- Apache 2.0, ([LICENSE-APACHE](https://github.com/libp2p/js-libp2p/blob/main/packages/metrics-opentelemetry/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](https://github.com/libp2p/js-libp2p/blob/main/packages/metrics-opentelemetry/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

# Contribution

Expand Down
21 changes: 19 additions & 2 deletions packages/metrics-opentelemetry/test/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
import { expect } from 'aegir/chai'
import { openTelemetryMetrics } from '../src/index.js'

describe('opentelemetry-metrics', () => {
it('should wrap a method', async () => {
// TODO: tests
expect(true).to.be.true()
const metrics = openTelemetryMetrics()({
nodeInfo: {
name: 'test',
version: '1.0.0'
}
})

const target = {
wrapped: function () {

}

Check warning on line 16 in packages/metrics-opentelemetry/test/index.spec.ts

View check run for this annotation

Codecov / codecov/patch

packages/metrics-opentelemetry/test/index.spec.ts#L15-L16

Added lines #L15 - L16 were not covered by tests
}

const wrapped = metrics.traceFunction('target.wrapped', target.wrapped, {
optionsIndex: 0
})

expect(wrapped).to.not.equal(target.wrapped)
})
})

0 comments on commit a9c6e9d

Please sign in to comment.