@monocle.sh/adonisjs-agent 1.0.0 → 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/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.0",
3
+ "version": "1.0.2",
4
4
  "description": "Monocle agent for AdonisJS - sends telemetry to Monocle cloud",
5
5
  "keywords": [
6
6
  "adonisjs",
@@ -9,6 +9,7 @@
9
9
  "opentelemetry",
10
10
  "tracing"
11
11
  ],
12
+ "homepage": "https://github.com/Julien-R44/monocle/tree/main/packages/agent",
12
13
  "license": "ISC",
13
14
  "author": "Julien Ripouteau <julien@ripouteau.com>",
14
15
  "repository": {
@@ -16,7 +17,6 @@
16
17
  "url": "git+https://github.com/Julien-R44/monocle.git",
17
18
  "directory": "packages/agent"
18
19
  },
19
- "homepage": "https://github.com/Julien-R44/monocle/tree/main/packages/agent",
20
20
  "files": [
21
21
  "dist"
22
22
  ],
@@ -38,7 +38,7 @@
38
38
  "tag": "latest"
39
39
  },
40
40
  "dependencies": {
41
- "@adonisjs/otel": "^1.2.1",
41
+ "@adonisjs/otel": "^1.2.3",
42
42
  "@bentocache/otel": "^0.1.2",
43
43
  "@opentelemetry/api": "^1.9.0",
44
44
  "@opentelemetry/core": "^2.6.0",
@@ -52,11 +52,11 @@
52
52
  "@sindresorhus/is": "^7.2.0",
53
53
  "error-stack-parser-es": "^1.0.5",
54
54
  "import-in-the-middle": "^3.0.0",
55
- "@monocle.sh/instrumentation-mcp": "1.0.0",
56
- "@monocle.sh/otel-utils": "1.0.0"
55
+ "@monocle.sh/instrumentation-mcp": "^1.0.0",
56
+ "@monocle.sh/otel-utils": "^1.0.0"
57
57
  },
58
58
  "devDependencies": {
59
- "@adonisjs/core": "^7.0.1",
59
+ "@adonisjs/core": "^7.1.1",
60
60
  "@adonisjs/tsconfig": "^2.0.0",
61
61
  "@japa/assert": "^4.2.0",
62
62
  "@japa/file-system": "^3.0.0",