Skip to content

Commit

Permalink
chore: export named function (#125)
Browse files Browse the repository at this point in the history
* chore: export named function

This allows us greater flexibiltiy, if the named export does not exist, it will give immediate error when trying to run the module, making debugging simpler

* chore: remove NodeJS v19 from CI workflow
  • Loading branch information
saidsef authored Apr 13, 2024
1 parent c149930 commit 322f265
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
if: ${{ github.event_name == 'pull_request' }}
strategy:
matrix:
node: [ 19, 20, 21 ]
node: [ 20, 21 ]
name: Node ${{ matrix.node }} test
steps:
- name: Git Checkout
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ npm install @saidsef/tracing-node --save
## Usage

```
const setupTracing = require('@saidsef/tracing-node');
const { setupTracing } = require('@saidsef/tracing-node');
setupTracing('hostname', 'application_name', 'endpoint');
```

```
import setupTracing from '@saidsef/tracing-node';
import { setupTracing } from '@saidsef/tracing-node';
setupTracing('hostname', 'application_name', 'endpoint');
```

Expand Down
4 changes: 2 additions & 2 deletions libs/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
* be used to create and export spans for tracing various operations within
* the service.
*/
export default function setupTracing (serviceName, appName="application", endpoint=null) {
export async function setupTracing (serviceName, appName="application", endpoint=null) {
const provider = new NodeTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
Expand Down Expand Up @@ -112,5 +112,5 @@ export default function setupTracing (serviceName, appName="application", endpoi
})});

// Return the tracer for the service
return provider.getTracer(serviceName);
return await provider.getTracer(serviceName);
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@saidsef/tracing-node",
"version": "1.9.8",
"version": "1.10.0",
"description": "tracing NodeJS - This is a wrapper for OpenTelemetry instrumentation packages",
"main": "libs/index.mjs",
"scripts": {
"test": "node --trace-warnings --test --report-uncaught-exception --heap-prof --cpu-prof --track-heap-objects --report-dir=test/ --diagnostic-dir=test/ --heap-prof-dir=test/ libs/index.mjs",
"lint": "eslint libs -c .eslintrc.yml ",
"rebuild": "rm -rfv node_modules/ package-lock.json && NODE_ENV=production npm install"
"rebuild": "rm -rfv node_modules/ package-lock.json && npm install --prod --omit=dev"
},
"type": "module",
"private": false,
Expand All @@ -31,7 +31,7 @@
"author": "Said Sef <saidsef@gmail.com>",
"license": "Apache-2.0",
"engines": {
"node": ">= 19"
"node": ">= 20"
},
"bugs": {
"url": "https://github.com/saidsef/tracing-nodejs/issues"
Expand Down

0 comments on commit 322f265

Please sign in to comment.