@monocle.sh/adonisjs-agent 1.0.1 → 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2024-present, Julien Ripouteau
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/dist/init.mjs CHANGED
@@ -74,6 +74,19 @@ async function init(dirname) {
74
74
  await instrumentMail(mailConfig ?? { enabled: true }, dirname);
75
75
  }
76
76
  /**
77
+ * Queue Instrumentation
78
+ *
79
+ * Automatically instruments @boringnode/queue if installed.
80
+ * Creates PRODUCER spans for dispatch and CONSUMER spans for execution.
81
+ *
82
+ * @see ./instrumentations/queue/instrumentation.ts for implementation details
83
+ */
84
+ const queueConfig = config.queue;
85
+ if (queueConfig !== false) {
86
+ const { instrumentQueue } = await import("./src/instrumentations/queue/instrumentation.mjs");
87
+ await instrumentQueue(queueConfig ?? { enabled: true }, dirname);
88
+ }
89
+ /**
77
90
  * Cache Instrumentation
78
91
  *
79
92
  * Automatically instruments @adonisjs/cache (bentocache) if installed.
@@ -0,0 +1,32 @@
1
+ import { createRequire } from "node:module";
2
+ import { pathToFileURL } from "node:url";
3
+ //#region src/instrumentations/queue/instrumentation.ts
4
+ /**
5
+ * Auto-instruments @boringnode/queue with OpenTelemetry spans
6
+ * for job dispatch (PRODUCER) and execution (CONSUMER).
7
+ *
8
+ * Patches `QueueManager.init()` to auto-inject the OTel plugin,
9
+ * so users don't need to configure plugins in their queue config.
10
+ */
11
+ async function instrumentQueue(config, appRoot) {
12
+ if (config.enabled === false) return void 0;
13
+ const appRequire = createRequire(appRoot ? pathToFileURL(`${appRoot}/package.json`).href : import.meta.url);
14
+ try {
15
+ appRequire.resolve("@boringnode/queue");
16
+ } catch {
17
+ return;
18
+ }
19
+ const { QueueInstrumentation } = await import("@boringnode/queue/otel");
20
+ const instrumentation = new QueueInstrumentation({
21
+ executionSpanLinkMode: config.executionSpanLinkMode,
22
+ messagingSystem: config.messagingSystem
23
+ });
24
+ instrumentation.enable();
25
+ try {
26
+ const queueModule = await import("@boringnode/queue");
27
+ instrumentation.manuallyRegister(queueModule);
28
+ } catch {}
29
+ return instrumentation;
30
+ }
31
+ //#endregion
32
+ export { instrumentQueue };
@@ -6,6 +6,14 @@ import { DestinationMap, OtelConfig } from "@adonisjs/otel/types";
6
6
  * Configuration for cache instrumentation
7
7
  */
8
8
  interface CacheInstrumentationConfig extends BentoCacheInstrumentationConfig {}
9
+ /**
10
+ * Configuration for queue instrumentation
11
+ */
12
+ interface QueueInstrumentationConfig {
13
+ enabled?: boolean;
14
+ executionSpanLinkMode?: 'link' | 'parent';
15
+ messagingSystem?: string;
16
+ }
9
17
  /**
10
18
  * Configuration for mail instrumentation
11
19
  */
@@ -143,6 +151,13 @@ interface MonocleConfig extends Omit<OtelConfig, 'traceExporter' | 'metricExport
143
151
  * @default { enabled: true }
144
152
  */
145
153
  cache?: false | CacheInstrumentationConfig;
154
+ /**
155
+ * Queue instrumentation configuration.
156
+ * Automatically instruments @boringnode/queue if installed.
157
+ * Set to `false` to disable.
158
+ * @default { enabled: true }
159
+ */
160
+ queue?: false | QueueInstrumentationConfig;
146
161
  }
147
162
  //#endregion
148
163
  export { BatchConfig, CliTracingConfig, HostMetricsConfig, MonocleConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monocle.sh/adonisjs-agent",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Monocle agent for AdonisJS - sends telemetry to Monocle cloud",
5
5
  "keywords": [
6
6
  "adonisjs",
@@ -23,69 +23,23 @@
23
23
  "type": "module",
24
24
  "types": "./dist/index.d.mts",
25
25
  "exports": {
26
- ".": {
27
- "dev": "./index.ts",
28
- "default": "./dist/index.mjs"
29
- },
30
- "./decorators": {
31
- "dev": "./src/decorators.ts",
32
- "default": "./dist/decorators.mjs"
33
- },
34
- "./helpers": {
35
- "dev": "./src/helpers.ts",
36
- "default": "./dist/helpers.mjs"
37
- },
38
- "./init": {
39
- "dev": "./src/init.ts",
40
- "default": "./dist/init.mjs"
41
- },
42
- "./mcp": {
43
- "dev": "./src/mcp.ts",
44
- "default": "./dist/mcp.mjs"
45
- },
46
- "./monocle_middleware": {
47
- "dev": "./middleware/monocle_middleware.ts",
48
- "default": "./dist/monocle_middleware.mjs"
49
- },
50
- "./monocle_provider": {
51
- "dev": "./providers/monocle_provider.ts",
52
- "default": "./dist/monocle_provider.mjs"
53
- },
54
- "./types": {
55
- "dev": "./types.ts",
56
- "default": "./dist/types.mjs"
57
- },
26
+ ".": "./dist/index.mjs",
27
+ "./decorators": "./dist/decorators.mjs",
28
+ "./helpers": "./dist/helpers.mjs",
29
+ "./init": "./dist/init.mjs",
30
+ "./mcp": "./dist/mcp.mjs",
31
+ "./monocle_middleware": "./dist/monocle_middleware.mjs",
32
+ "./monocle_provider": "./dist/monocle_provider.mjs",
33
+ "./types": "./dist/types.mjs",
58
34
  "./package.json": "./package.json"
59
35
  },
60
36
  "publishConfig": {
61
37
  "access": "public",
62
- "exports": {
63
- ".": "./dist/index.mjs",
64
- "./decorators": "./dist/decorators.mjs",
65
- "./helpers": "./dist/helpers.mjs",
66
- "./init": "./dist/init.mjs",
67
- "./mcp": "./dist/mcp.mjs",
68
- "./monocle_middleware": "./dist/monocle_middleware.mjs",
69
- "./monocle_provider": "./dist/monocle_provider.mjs",
70
- "./types": "./dist/types.mjs",
71
- "./package.json": "./package.json"
72
- },
73
38
  "tag": "latest"
74
39
  },
75
- "scripts": {
76
- "build": "tsdown",
77
- "dev": "tsdown",
78
- "typecheck": "tsgo --noEmit",
79
- "test": "node --import @poppinss/ts-exec bin/test.ts",
80
- "quick:test": "node --import @poppinss/ts-exec bin/test.ts",
81
- "release": "release-it",
82
- "prepublishOnly": "pnpm run build"
83
- },
84
40
  "dependencies": {
85
41
  "@adonisjs/otel": "^1.2.3",
86
42
  "@bentocache/otel": "^0.1.2",
87
- "@monocle.sh/instrumentation-mcp": "workspace:*",
88
- "@monocle.sh/otel-utils": "workspace:*",
89
43
  "@opentelemetry/api": "^1.9.0",
90
44
  "@opentelemetry/core": "^2.6.0",
91
45
  "@opentelemetry/exporter-metrics-otlp-http": "^0.213.0",
@@ -97,17 +51,19 @@
97
51
  "@opentelemetry/semantic-conventions": "^1.40.0",
98
52
  "@sindresorhus/is": "^7.2.0",
99
53
  "error-stack-parser-es": "^1.0.5",
100
- "import-in-the-middle": "^3.0.0"
54
+ "import-in-the-middle": "^3.0.0",
55
+ "@monocle.sh/instrumentation-mcp": "^1.0.0",
56
+ "@monocle.sh/otel-utils": "^1.0.0"
101
57
  },
102
58
  "devDependencies": {
103
- "@adonisjs/core": "catalog:",
104
- "@adonisjs/tsconfig": "catalog:",
105
- "@japa/assert": "catalog:",
59
+ "@adonisjs/core": "^7.1.1",
60
+ "@adonisjs/tsconfig": "^2.0.0",
61
+ "@japa/assert": "^4.2.0",
106
62
  "@japa/file-system": "^3.0.0",
107
- "@japa/runner": "catalog:",
63
+ "@japa/runner": "^5.3.0",
108
64
  "@japa/snapshot": "^2.0.10",
109
- "@poppinss/ts-exec": "catalog:",
110
- "release-it": "catalog:"
65
+ "@poppinss/ts-exec": "^1.4.4",
66
+ "release-it": "^19.2.4"
111
67
  },
112
68
  "peerDependencies": {
113
69
  "@adonisjs/core": "^6.2.0 || ^7.0.0",
@@ -118,5 +74,12 @@
118
74
  "optional": true
119
75
  }
120
76
  },
121
- "packageManager": "pnpm@10.32.1"
122
- }
77
+ "scripts": {
78
+ "build": "tsdown",
79
+ "dev": "tsdown",
80
+ "typecheck": "tsgo --noEmit",
81
+ "test": "node --import @poppinss/ts-exec bin/test.ts",
82
+ "quick:test": "node --import @poppinss/ts-exec bin/test.ts",
83
+ "release": "release-it"
84
+ }
85
+ }