-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,114 additions
and
6 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,7 @@ | ||
--- | ||
'@totalsoft/opentelemetry-instrumentation-ws': major | ||
'@totalsoft/pino-opentelemetry': major | ||
'@totalsoft/pino-multitenancy': minor | ||
--- | ||
|
||
Added pino-opentelemetry package to include logs in opentelemetry tracing spans. Added tenantCodeMixin in pino-multitenancy to make the tenant code available as a log property. Added opentelemetry-instrumentation-ws package (instrumentation for "ws" library). |
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 @@ | ||
--- | ||
'@totalsoft/pino-multitenancy': minor | ||
'@totalsoft/pino-opentelemetry': patch | ||
--- | ||
|
||
Opentelemetry Pino Transport + TenantCode Mixin |
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
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 @@ | ||
version.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,5 @@ | ||
node_modules | ||
package-lock.json | ||
coverage | ||
__tests__ | ||
__mocks__ |
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 @@ | ||
# @totalsoft/opentelemetry-instrumentation-ws | ||
|
||
## 1.0.0 | ||
|
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,43 @@ | ||
# opentelemetry-instrumentation-ws | ||
|
||
This package provides opentelemetry instrumentation for ws library. | ||
|
||
## Installation | ||
|
||
```javascript | ||
npm i @totalsoft/opentelemetry-instrumentation-ws | ||
``` | ||
|
||
or | ||
|
||
```javascript | ||
yarn add @totalsoft/opentelemetry-instrumentation-ws | ||
``` | ||
## Usage | ||
```javascript | ||
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node'); | ||
const { registerInstrumentations } = require('@opentelemetry/instrumentation'); | ||
const { WSInstrumentation } = require('@totalsoft/opentelemetry-instrumentation-ws'); | ||
|
||
const provider = new NodeTracerProvider(); | ||
provider.register(); | ||
|
||
registerInstrumentations({ | ||
instrumentations: [ | ||
new WSInstrumentation(), | ||
], | ||
}); | ||
``` | ||
|
||
## Config | ||
|
||
The `ws` instrumentation has few options available to choose from. You can set the following: | ||
|
||
| Options | Type | Description | | ||
| ------------------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | ||
| `generateSendSpans` | boolean | should the tracing library add spans for each sent message. Default: false | | ||
| `generateReceiveSpans` | boolean | should the tracing library add spans for each incoming message. Default: false | | ||
| `sendHook` | (span: Span, hookInfo: HookInfo) => void | hook for adding custom attributes to the ws send span when a websocket sends a message | | ||
| `closeHook` | (span: Span, hookInfo: HookInfo) => void | hook for adding custom attributes to the ws close span when a websocket is imperatively closed | | ||
| `handleUpgradeHook` | (span: Span, hookInfo: HookInfo) => void | hook for adding custom attributes to the ws.Server handleUpgrade span when a socket is opened against a server | | ||
| `maxMessageLength` | number | max message length in the message attribute. "..." is added to the end when the message is truncated. Set 0 to omit the message attribute. Default: 1022. | |
7 changes: 7 additions & 0 deletions
7
packages/opentelemetry-instrumentation-ws/__tests__/readme.md
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,7 @@ | ||
<!-- | ||
Copyright (c) TotalSoft. | ||
This source code is licensed under the MIT license. | ||
--> | ||
|
||
# Issue when testing instrumentation with jest: | ||
https://github.com/facebook/jest/issues/11295 |
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,58 @@ | ||
{ | ||
"name": "@totalsoft/opentelemetry-instrumentation-ws", | ||
"description": "Opentelemetry instrumentation for ws", | ||
"version": "1.1.0", | ||
"author": "TotalSoft", | ||
"packageManager": "yarn@3.2.0", | ||
"type": "commonjs", | ||
"main": "dist/src/index.js", | ||
"types": "dist/src/index.d.ts", | ||
"composite": true, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/osstotalsoft/rocket-toolkit.git", | ||
"directory": "packages//opentelemetry-instrumentation-ws" | ||
}, | ||
"keywords": [ | ||
"correlation" | ||
], | ||
"scripts": { | ||
"build": "run version:update && run clean && tsc --project tsconfig.build.json", | ||
"lint": "eslint src/*.ts", | ||
"clean": "rimraf dist", | ||
"test": "jest --collectCoverage --passWithNoTests --verbose --silent=false --runInBand", | ||
"version:update": "node ./scripts/version-update.js" | ||
}, | ||
"devDependencies": { | ||
"@jest/types": "^28.1.0", | ||
"@opentelemetry/core": "^1.9.1", | ||
"@opentelemetry/instrumentation": "^0.34.0", | ||
"@opentelemetry/semantic-conventions": "^1.9.1", | ||
"@types/jest": "^27.5.1", | ||
"@types/node": "^17.0.32", | ||
"@types/uuid": "^8.3.4", | ||
"@types/ws": "^8.5.4", | ||
"jest": "^28.1.0", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^28.0.3", | ||
"typescript": "^4.7.2", | ||
"ws": "^8.5.0" | ||
}, | ||
"dependencies": { | ||
"@opentelemetry/api": "^1.4.0", | ||
"@opentelemetry/instrumentation-http": "^0.35.0", | ||
"is-promise": "^4.0.0" | ||
}, | ||
"peerDependencies": { | ||
"ws": "^8.5.0" | ||
}, | ||
"jest": { | ||
"preset": "ts-jest", | ||
"testEnvironment": "node", | ||
"verbose": true | ||
}, | ||
"license": "MIT" | ||
} |
22 changes: 22 additions & 0 deletions
22
packages/opentelemetry-instrumentation-ws/scripts/version-update.js
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 @@ | ||
// Copyright (c) TotalSoft. | ||
// This source code is licensed under the MIT license. | ||
|
||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const appRoot = process.cwd() | ||
|
||
const packageJsonUrl = path.resolve(`${appRoot}/package.json`) | ||
const pjson = require(packageJsonUrl) | ||
|
||
const content = ` | ||
// Copyright (c) TotalSoft. | ||
// This source code is licensed under the MIT license.mitations under the License. | ||
// this is autogenerated file, see scripts/version-update.js | ||
export const VERSION = '${pjson.version}' | ||
` | ||
|
||
const fileUrl = path.join(appRoot, 'src', 'version.ts') | ||
|
||
fs.writeFileSync(fileUrl, content) |
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,5 @@ | ||
// Copyright (c) TotalSoft. | ||
// This source code is licensed under the MIT license. | ||
|
||
export * from './instrumentation' | ||
export * from './types' |
Oops, something went wrong.