nestjs-otel 6.1.1 → 6.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,69 @@
1
+ # Contributing Guide
2
+
3
+ We'd love your help!
4
+
5
+ - [Contributing Guide](#contributing-guide)
6
+ - [Development Quick Start](#development-quick-start)
7
+ - [Report a bug or requesting feature](#report-a-bug-or-requesting-feature)
8
+ - [How to contribute](#how-to-contribute)
9
+ - [Conventional commit](#conventional-commit)
10
+ - [Fork](#fork)
11
+
12
+ ## Development Quick Start
13
+
14
+ To get the project started quickly, you can follow these steps. For more
15
+ detailed instructions, see [development](#development) below.
16
+
17
+ ```sh
18
+ git clone https://github.com/pragmaticivan/nestjs-otel.git
19
+ cd nestjs-otel
20
+ npm ci
21
+ npm run test
22
+ ```
23
+
24
+ ## Report a bug or requesting feature
25
+
26
+ Reporting bugs is an important contribution. Please make sure to include:
27
+
28
+ - expected and actual behavior.
29
+ - Node version that application is running.
30
+ - OpenTelemetry version that application is using.
31
+ - if possible - repro application and steps to reproduce.
32
+
33
+ ## How to contribute
34
+
35
+ #### Conventional commit
36
+
37
+ The Conventional Commits specification is a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of. This convention dovetails with SemVer, by describing the features, fixes, and breaking changes made in commit messages. You can see examples [here](https://www.conventionalcommits.org/en/v1.0.0-beta.4/#examples).
38
+ We use [commitlint](https://github.com/conventional-changelog/commitlint) and [husky](https://github.com/typicode/husky) to prevent bad commit message.
39
+ For example, you want to submit the following commit message `git commit -s -am "my bad commit"`.
40
+ You will receive the following error :
41
+
42
+ ```text
43
+ ✖ type must be one of [ci, feat, fix, docs, style, refactor, perf, test, revert, chore] [type-enum]
44
+ ```
45
+
46
+ Here an example that will pass the verification: `git commit -s -am "chore(opentelemetry): update deps"`
47
+
48
+ ### Fork
49
+
50
+ In the interest of keeping this repository clean and manageable, you should work from a fork. To create a fork, click the 'Fork' button at the top of the repository, then clone the fork locally using `git clone git@github.com:USERNAME/nestjs-otel.git`.
51
+
52
+ You should also add this repository as an "upstream" repo to your local copy, in order to keep it up to date. You can add this as a remote like so:
53
+
54
+ ```sh
55
+ git remote add upstream https://github.com/pragmaticivan/nestjs-otel.git
56
+
57
+ #verify that the upstream exists
58
+ git remote -v
59
+ ```
60
+
61
+ To update your fork, fetch the upstream repo's branches and commits, then merge your main with upstream's main:
62
+
63
+ ```sh
64
+ git fetch upstream
65
+ git checkout main
66
+ git merge upstream/main
67
+ ```
68
+
69
+ Remember to always work in a branch of your local copy, as you might otherwise have to contend with conflicts in main.
package/README.md CHANGED
@@ -1,6 +1,5 @@
1
- <p align="center">
2
- <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
3
- </p>
1
+ ![nestjs-otel](https://github.com/pragmaticivan/nestjs-otel/assets/301291/40aaad82-82f9-48e5-b204-0e3cef532813)
2
+
4
3
 
5
4
  # NestJS OpenTelemetry (OTEL)
6
5
 
@@ -186,7 +185,7 @@ export class BookService {
186
185
 
187
186
  ## Metric Service
188
187
 
189
- [OpenTelemetry Metrics](https://www.npmjs.com/package/@opentelemetry/api-metrics) allow a user to collect data and export it to metrics backend like Prometheus.
188
+ [OpenTelemetry Metrics](https://www.npmjs.com/package/@opentelemetry/api) allow a user to collect data and export it to metrics backend like Prometheus.
190
189
 
191
190
  ```ts
192
191
  import { MetricService } from 'nestjs-otel';
@@ -4,7 +4,9 @@ import { OtelMetricOptions } from '../../interfaces/metric-options.interface';
4
4
  *
5
5
  * @param originalClass
6
6
  */
7
- export declare const OtelInstanceCounter: (options?: OtelMetricOptions) => <T extends new (...args: any[]) => {}>(originalClass: T) => {
7
+ export declare const OtelInstanceCounter: (options?: OtelMetricOptions) => <T extends {
8
+ new (...args: any[]): {};
9
+ }>(originalClass: T) => {
8
10
  new (...args: any[]): {};
9
11
  } & T;
10
12
  /**
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InjectMetric = void 0;
3
+ exports.InjectMetric = InjectMetric;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const utils_1 = require("./utils");
6
6
  function InjectMetric(name) {
7
7
  const token = (0, utils_1.getToken)(name);
8
8
  return (0, common_1.Inject)(token);
9
9
  }
10
- exports.InjectMetric = InjectMetric;
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOrCreateObservableUpDownCounter = exports.getOrCreateObservableCounter = exports.getOrCreateObservableGauge = exports.getOrCreateUpDownCounter = exports.getOrCreateCounter = exports.getOrCreateHistogram = exports.meterData = exports.MetricType = void 0;
3
+ exports.meterData = exports.MetricType = void 0;
4
+ exports.getOrCreateHistogram = getOrCreateHistogram;
5
+ exports.getOrCreateCounter = getOrCreateCounter;
6
+ exports.getOrCreateUpDownCounter = getOrCreateUpDownCounter;
7
+ exports.getOrCreateObservableGauge = getOrCreateObservableGauge;
8
+ exports.getOrCreateObservableCounter = getOrCreateObservableCounter;
9
+ exports.getOrCreateObservableUpDownCounter = getOrCreateObservableUpDownCounter;
4
10
  const api_1 = require("@opentelemetry/api");
5
11
  const opentelemetry_constants_1 = require("../opentelemetry.constants");
6
12
  var MetricType;
@@ -26,24 +32,18 @@ function getOrCreate(name, options = {}, type) {
26
32
  function getOrCreateHistogram(name, options = {}) {
27
33
  return getOrCreate(name, options, MetricType.Histogram);
28
34
  }
29
- exports.getOrCreateHistogram = getOrCreateHistogram;
30
35
  function getOrCreateCounter(name, options = {}) {
31
36
  return getOrCreate(name, options, MetricType.Counter);
32
37
  }
33
- exports.getOrCreateCounter = getOrCreateCounter;
34
38
  function getOrCreateUpDownCounter(name, options = {}) {
35
39
  return getOrCreate(name, options, MetricType.UpDownCounter);
36
40
  }
37
- exports.getOrCreateUpDownCounter = getOrCreateUpDownCounter;
38
41
  function getOrCreateObservableGauge(name, options = {}) {
39
42
  return getOrCreate(name, options, MetricType.ObservableGauge);
40
43
  }
41
- exports.getOrCreateObservableGauge = getOrCreateObservableGauge;
42
44
  function getOrCreateObservableCounter(name, options = {}) {
43
45
  return getOrCreate(name, options, MetricType.ObservableCounter);
44
46
  }
45
- exports.getOrCreateObservableCounter = getOrCreateObservableCounter;
46
47
  function getOrCreateObservableUpDownCounter(name, options = {}) {
47
48
  return getOrCreate(name, options, MetricType.ObservableUpDownCounter);
48
49
  }
49
- exports.getOrCreateObservableUpDownCounter = getOrCreateObservableUpDownCounter;
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getToken = void 0;
3
+ exports.getToken = getToken;
4
4
  /**
5
5
  * @public
6
6
  */
7
7
  function getToken(name) {
8
8
  return `OTEL_METRIC_${name.toUpperCase()}`;
9
9
  }
10
- exports.getToken = getToken;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Span = void 0;
3
+ exports.Span = Span;
4
4
  const api_1 = require("@opentelemetry/api");
5
5
  const opentelemetry_utils_1 = require("../../opentelemetry.utils");
6
6
  const recordException = (span, error) => {
@@ -46,4 +46,3 @@ function Span(name, options = {}) {
46
46
  (0, opentelemetry_utils_1.copyMetadataFromFunctionToFunction)(originalFunction, wrappedFunction);
47
47
  };
48
48
  }
49
- exports.Span = Span;
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "nestjs-otel",
3
- "version": "6.1.1",
3
+ "version": "6.1.2",
4
4
  "description": "NestJS OpenTelemetry Library",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index",
7
7
  "scripts": {
8
8
  "prebuild": "rimraf lib",
9
- "prepare": "husky install",
10
9
  "build": "tsc",
11
10
  "lint": "prettier --check ./**/*.{js,json,ts}",
12
11
  "format": "prettier --write ./**/*.{js,json,ts}",
@@ -15,7 +14,8 @@
15
14
  "test:unit": "jest --passWithNoTests",
16
15
  "test:watch": "jest --watch",
17
16
  "test:e2e": "jest --config ./tests/jest-e2e.json --runInBand --forceExit",
18
- "test:e2e:watch": "jest --config ./tests/jest-e2e.json --runInBand --watch"
17
+ "test:e2e:watch": "jest --config ./tests/jest-e2e.json --runInBand --watch",
18
+ "prepare": "husky"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
@@ -36,40 +36,39 @@
36
36
  },
37
37
  "homepage": "https://github.com/pragmaticivan/nestjs-otel#readme",
38
38
  "dependencies": {
39
- "@opentelemetry/api": "^1.8.0",
40
- "@opentelemetry/host-metrics": "^0.35.1",
41
- "response-time": "^2.3.2"
39
+ "@opentelemetry/api": "^1.9.0",
40
+ "@opentelemetry/host-metrics": "^0.35.4",
41
+ "response-time": "^2.3.3"
42
42
  },
43
43
  "devDependencies": {
44
- "@commitlint/cli": "^19.3.0",
45
- "@commitlint/config-conventional": "^19.2.2",
46
- "@nestjs/common": "^10.3.8",
47
- "@nestjs/core": "^10.3.8",
48
- "@nestjs/platform-express": "^10.3.8",
49
- "@nestjs/platform-fastify": "^10.3.8",
50
- "@nestjs/testing": "^10.3.8",
51
- "@opentelemetry/exporter-prometheus": "^0.51.1",
52
- "@opentelemetry/sdk-metrics": "^1.24.1",
53
- "@opentelemetry/sdk-trace-node": "^1.24.1",
54
- "@types/jest": "^29.5.12",
55
- "@types/node": "^20.12.10",
44
+ "@commitlint/cli": "^19.5.0",
45
+ "@commitlint/config-conventional": "^19.5.0",
46
+ "@nestjs/common": "^10.4.8",
47
+ "@nestjs/core": "^10.4.8",
48
+ "@nestjs/platform-express": "^10.4.8",
49
+ "@nestjs/platform-fastify": "^10.4.8",
50
+ "@nestjs/testing": "^10.4.8",
51
+ "@opentelemetry/exporter-prometheus": "^0.54.2",
52
+ "@opentelemetry/sdk-metrics": "^1.27.0",
53
+ "@opentelemetry/sdk-trace-node": "^1.27.0",
54
+ "@types/jest": "^29.5.14",
55
+ "@types/node": "^22.9.0",
56
56
  "@types/response-time": "^2.3.8",
57
57
  "@types/supertest": "^6.0.2",
58
- "ansi-regex": "",
59
- "husky": "^9.0.11",
58
+ "husky": "^9.1.6",
60
59
  "jest": "^29.7.0",
61
- "lint-staged": "^15.2.2",
62
- "prettier": "^3.2.5",
60
+ "lint-staged": "^15.2.10",
61
+ "prettier": "^3.3.3",
63
62
  "reflect-metadata": "^0.2.2",
64
- "rimraf": "^5.0.5",
63
+ "rimraf": "^6.0.1",
65
64
  "rxjs": "^7.8.1",
66
65
  "supertest": "^7.0.0",
67
- "ts-jest": "^29.1.2",
68
- "typescript": "5.4.5"
66
+ "ts-jest": "^29.2.5",
67
+ "typescript": "5.6.3"
69
68
  },
70
69
  "peerDependencies": {
71
- "@nestjs/common": "^9.0.0 || ^10.0.0",
72
- "@nestjs/core": "^9.0.0 || ^10.0.0"
70
+ "@nestjs/common": "^9.0.0 || ^10.0.0 || ^11.0.0",
71
+ "@nestjs/core": "^9.0.0 || ^10.0.0 || ^11.0.0"
73
72
  },
74
73
  "jest": {
75
74
  "moduleFileExtensions": [
@@ -93,10 +92,5 @@
93
92
  "**/*.{js,ts,json}": [
94
93
  "prettier --write"
95
94
  ]
96
- },
97
- "commitlint": {
98
- "extends": [
99
- "@commitlint/config-conventional"
100
- ]
101
95
  }
102
96
  }