-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial commit for goodmetrics nodejs client
- Loading branch information
1 parent
28acd5f
commit 92ac57d
Showing
28 changed files
with
9,226 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
dist | ||
generated | ||
**/*.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"root": true, | ||
"env": { | ||
"es2021": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
"plugin:import/recommended", | ||
"plugin:prettier/recommended", | ||
"plugin:node/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 12, | ||
"project": "./tsconfig.json" | ||
}, | ||
"plugins": ["@typescript-eslint"], | ||
"rules": { | ||
"semi": ["error", "always"], | ||
"import/no-extraneous-dependencies": ["error", {}], | ||
"node/no-unsupported-features/es-syntax": "off", | ||
"node/no-missing-import": ["error", { | ||
"tryExtensions": [".js", ".ts", ".json", ".node"] | ||
}], | ||
"prettier/prettier": "error", | ||
"block-scoped-var": "error", | ||
"eqeqeq": "error", | ||
"no-var": "error", | ||
"prefer-const": "error", | ||
"eol-last": "error", | ||
"prefer-arrow-callback": "error", | ||
"no-trailing-spaces": "error", | ||
"@typescript-eslint/switch-exhaustiveness-check": "error", | ||
"quotes": ["warn", "single", { "avoidEscape": true }], | ||
"no-restricted-properties": [ | ||
"error", | ||
{ | ||
"object": "describe", | ||
"property": "only" | ||
}, | ||
{ | ||
"object": "it", | ||
"property": "only" | ||
} | ||
], | ||
// async without await is often an error and in other uses it obfuscates | ||
// the intent of the developer. Functions are async when they want to await. | ||
"require-await": "error", | ||
"import/no-duplicates": "error" | ||
}, | ||
"settings": { | ||
"import/resolver": { | ||
"node": { | ||
"extensions": [".js", ".jsx", ".ts", ".tsx"] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | ||
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | ||
|
||
name: Build Node.js Package | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
- name: Install and Build | ||
if: ${{ steps.release.outputs.release_created }} | ||
run: | | ||
npm ci | ||
npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
name: release-please | ||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
release-type: node | ||
package-name: goodmetrics-nodejs | ||
bump-minor-pre-major: true | ||
prerelease: true | ||
# The logic below handles the npm publication: | ||
- uses: actions/checkout@v2 | ||
# these if statements ensure that a publication only occurs when | ||
# a new release is created: | ||
if: ${{ steps.release.outputs.release_created }} | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16 | ||
registry-url: 'https://registry.npmjs.org' | ||
if: ${{ steps.release.outputs.release_created }} | ||
- name: Install and Build | ||
if: ${{ steps.release.outputs.release_created }} | ||
run: | | ||
npm ci | ||
npm run build | ||
- run: npm publish | ||
name: Publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
if: ${{ steps.release.outputs.release_created }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.js | ||
!jest.config.js | ||
*.d.ts | ||
**/node_modules/**/* | ||
.idea | ||
dist/ | ||
.vscode/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"bracketSpacing": false, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"arrowParens": "avoid" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Goodmetrics Nodejs | ||
|
||
example usage | ||
```javascript | ||
import {MetricsSetups} from './goodmetrics/metricsSetups'; | ||
import {Dimension} from './goodmetrics/_Metrics'; | ||
import {TimestampAt} from './goodmetrics/metricsFactory'; | ||
|
||
const delay = async (ms: number): Promise<void> => { | ||
return await new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, ms); | ||
}); | ||
}; | ||
|
||
const main = async () => { | ||
const metrics = | ||
MetricsSetups.lightstepNativeOtlpButItSendsMetricsUponRecordingForLambda({ | ||
aggregationWidthMillis: 10 * 1000 * 1000, | ||
lightstepAccessToken: '<your lightstep api key>', | ||
prescientDimensions: new Map<string, Dimension>(), | ||
}); | ||
|
||
await metrics.record('my_metric', TimestampAt.Start, async metrics => { | ||
console.info('inside metrics block'); | ||
metrics.measure('runs', 1); | ||
await delay(100); | ||
metrics.dimension('result', 'success'); | ||
}); | ||
}; | ||
|
||
main().finally(); | ||
``` |
Oops, something went wrong.