Skip to content

Commit d0223c7

Browse files
committed
chore: pre-publish cleanup — normalize env vars + package.json metadata
Env var renames (all now under ARGUS_ prefix, consistent with ARGUS_SLOW_QUERY_*): DIAGNOSTIC_AGENT_ENABLED → ARGUS_ENABLED DIAGNOSTIC_DEBUG → ARGUS_DEBUG DIAGNOSTIC_LICENSE_KEY → ARGUS_LICENSE_KEY RUNTIME_MONITOR_EVENT_LOOP_THRESHOLD_MS → ARGUS_EVENT_LOOP_THRESHOLD_MS RUNTIME_MONITOR_MEMORY_GROWTH_BYTES → ARGUS_MEMORY_GROWTH_BYTES RUNTIME_MONITOR_CPU_PROFILE_COOLDOWN_MS → ARGUS_CPU_PROFILE_COOLDOWN_MS RUNTIME_MONITOR_CHECK_INTERVAL_MS → ARGUS_MONITOR_CHECK_INTERVAL_MS RUNTIME_MONITOR_CPU_PROFILE_DURATION_MS → ARGUS_CPU_PROFILE_DURATION_MS RUNTIME_MONITOR_HEAP_USAGE_PCT_THRESHOLD → ARGUS_HEAP_USAGE_PCT_THRESHOLD package.json: - Add repository, homepage, bugs fields - Add "argus", "monitoring", "tracing" keywords - Set author: Sharon Alhazov Rebuild dist with renamed env vars baked in. 508/508 tests pass, 0 TS errors, 0 ESLint warnings.
1 parent 3c100cc commit d0223c7

11 files changed

Lines changed: 98 additions & 87 deletions

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4646
#### Core agent
4747
- `ArgusAgent` fluent builder with two entry points: `create()` (manual) and
4848
`createProfile()` (preset-based).
49-
- Zero-overhead global kill-switch via `DIAGNOSTIC_AGENT_ENABLED=false``.start()` becomes
49+
- Zero-overhead global kill-switch via `ARGUS_ENABLED=false``.start()` becomes
5050
a no-op with no timer, subscription, or memory overhead.
51-
- `DIAGNOSTIC_DEBUG=true` built-in console logger for all agent events.
51+
- `ARGUS_DEBUG=true` built-in console logger for all agent events.
5252

5353
#### Preset system
5454
- Three environment presets: `prod`, `dev`, `test`.

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ const agent = await ArgusAgent.createProfile({
165165
```
166166

167167
> [!NOTE]
168-
> **Zero-overhead kill-switch** — set `DIAGNOSTIC_AGENT_ENABLED=false` (or `0`) in any environment and the agent skips all initialisation with no CPU cost. Useful for gradual rollouts, incident response, or staging overrides without a code deploy.
168+
> **Zero-overhead kill-switch** — set `ARGUS_ENABLED=false` (or `0`) in any environment and the agent skips all initialisation with no CPU cost. Useful for gradual rollouts, incident response, or staging overrides without a code deploy.
169169
170170
---
171171

@@ -198,7 +198,7 @@ See [`quotes-demo-app/README.md`](quotes-demo-app/README.md) for the full setup
198198
const agent = await ArgusAgent.createProfile({
199199
environment: 'prod', // 'dev' | 'test' | 'prod'
200200
appType: ['web', 'db'], // single string or array — modules are unioned
201-
enabled: true, // overridden by DIAGNOSTIC_AGENT_ENABLED env-var
201+
enabled: true, // overridden by ARGUS_ENABLED env-var
202202
workspaceDir: process.cwd(), // dev/test only — enables StaticScanner, AuditScanner, SourceMaps
203203
}).start();
204204
```
@@ -537,14 +537,14 @@ All thresholds can be overridden without code changes, making the agent CI/CD an
537537

538538
| Variable | Default | Controls |
539539
|---|---|---|
540-
| `DIAGNOSTIC_AGENT_ENABLED` | `true` | Set to `false` or `0` for a zero-CPU-overhead global kill-switch |
541-
| `DIAGNOSTIC_DEBUG` | `false` | Set to `true` to enable the built-in console logger for all agent events |
542-
| `RUNTIME_MONITOR_EVENT_LOOP_THRESHOLD_MS` | `50` | Minimum lag (ms) before an event-loop anomaly fires |
543-
| `RUNTIME_MONITOR_MEMORY_GROWTH_BYTES` | `10485760` (10 MB) | Minimum heap growth before a memory-leak anomaly fires |
544-
| `RUNTIME_MONITOR_CPU_PROFILE_COOLDOWN_MS` | `60000` | Minimum ms between back-to-back CPU profiles |
545-
| `RUNTIME_MONITOR_CHECK_INTERVAL_MS` | `1000` | How often thresholds are polled |
546-
| `RUNTIME_MONITOR_CPU_PROFILE_DURATION_MS` | `500` | Duration of each CPU profile capture |
547-
| `RUNTIME_MONITOR_HEAP_USAGE_PCT_THRESHOLD` | `90` | Heap usage % of `heapTotal` before a memory anomaly fires |
540+
| `ARGUS_ENABLED` | `true` | Set to `false` or `0` for a zero-CPU-overhead global kill-switch |
541+
| `ARGUS_DEBUG` | `false` | Set to `true` to enable the built-in console logger for all agent events |
542+
| `ARGUS_EVENT_LOOP_THRESHOLD_MS` | `50` | Minimum lag (ms) before an event-loop anomaly fires |
543+
| `ARGUS_MEMORY_GROWTH_BYTES` | `10485760` (10 MB) | Minimum heap growth before a memory-leak anomaly fires |
544+
| `ARGUS_CPU_PROFILE_COOLDOWN_MS` | `60000` | Minimum ms between back-to-back CPU profiles |
545+
| `ARGUS_MONITOR_CHECK_INTERVAL_MS` | `1000` | How often thresholds are polled |
546+
| `ARGUS_CPU_PROFILE_DURATION_MS` | `500` | Duration of each CPU profile capture |
547+
| `ARGUS_HEAP_USAGE_PCT_THRESHOLD` | `90` | Heap usage % of `heapTotal` before a memory anomaly fires |
548548
| `ARGUS_SLOW_QUERY_THRESHOLD_MS` | `1000` | Global slow query threshold used when no per-driver default applies |
549549
| `ARGUS_SLOW_QUERY_THRESHOLD_<DRIVER>` | (per-driver) | Per-driver threshold override. Key is the driver name uppercased with non-alphanumeric runs replaced by `_` — e.g. `ARGUS_SLOW_QUERY_THRESHOLD_PG=500`, `ARGUS_SLOW_QUERY_THRESHOLD_REDIS=50`, `ARGUS_SLOW_QUERY_THRESHOLD_ELASTIC_ELASTICSEARCH=300` |
550550

@@ -652,7 +652,7 @@ packages/agent/
652652
internal/
653653
profile-factory.ts → buildAgentProfile() — preset resolution for createProfile()
654654
query-handler.ts → createQueryHandler() — per-query sampling/analysis/slow-log closure
655-
console-logger.ts → installConsoleLogger() — DIAGNOSTIC_DEBUG event formatting
655+
console-logger.ts → installConsoleLogger() — ARGUS_DEBUG event formatting
656656
657657
profiling/
658658
app-type-detector.ts → package.json fingerprint scanner
@@ -769,14 +769,14 @@ runWithContext(agent.createContext('WORKER', '/process-job'), async () => {
769769

770770
> [!IMPORTANT]
771771
> **OTLP export requires a paid Self-Hosted Pro or Enterprise license.**
772-
> In free mode the agent emits events locally via `EventEmitter` only — `.withExporter()` has no effect without a valid `DIAGNOSTIC_LICENSE_KEY`.
772+
> In free mode the agent emits events locally via `EventEmitter` only — `.withExporter()` has no effect without a valid `ARGUS_LICENSE_KEY`.
773773
> To get notified when Self-Hosted Pro licenses go on sale: open [this GitHub issue](https://github.com/sharon77242/Argus/issues) or email [sharon10vp614@gmail.com](mailto:sharon10vp614@gmail.com).
774774
775775
The Self-Hosted Pro tier exports standard OTLP JSON directly to your own collector — no data ever leaves your infrastructure. Any OTLP-compatible collector works. Below is the quickest local setup using Jaeger's all-in-one image.
776776

777777
```bash
778778
# Set your license key (Self-Hosted Pro or Enterprise)
779-
export DIAGNOSTIC_LICENSE_KEY="your-license-key"
779+
export ARGUS_LICENSE_KEY="your-license-key"
780780
```
781781

782782
### Jaeger (quickest local setup)

packages/agent/package.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,27 @@
4141
"validate": "pnpm run typecheck && pnpm run lint && pnpm run format:check && pnpm run test:coverage"
4242
},
4343
"keywords": [
44+
"argus",
4445
"node",
4546
"diagnostics",
4647
"performance",
4748
"profiling",
4849
"apm",
4950
"observability",
50-
"privacy"
51+
"privacy",
52+
"monitoring",
53+
"tracing"
5154
],
52-
"author": "",
55+
"author": "Sharon Alhazov (https://github.com/sharon77242)",
5356
"license": "MIT",
57+
"homepage": "https://github.com/sharon77242/Argus#readme",
58+
"repository": {
59+
"type": "git",
60+
"url": "https://github.com/sharon77242/Argus.git"
61+
},
62+
"bugs": {
63+
"url": "https://github.com/sharon77242/Argus/issues"
64+
},
5465
"devDependencies": {
5566
"@types/node": "^22.15.29",
5667
"@types/source-map": "^0.5.7",

packages/agent/src/argus-agent.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export class ArgusAgent extends EventEmitter {
189189

190190
// Globally kill-switch the agent; .start() and .stop() will become 0-overhead.
191191
// Environment variables take precedence over the config object.
192-
const envEnabled = process.env.DIAGNOSTIC_AGENT_ENABLED;
192+
const envEnabled = process.env.ARGUS_ENABLED;
193193
const isGloballyDisabled =
194194
envEnabled !== undefined
195195
? envEnabled === "false" || envEnabled === "0"
@@ -471,7 +471,7 @@ export class ArgusAgent extends EventEmitter {
471471
public async start(): Promise<this> {
472472
if (this.globallyDisabled || this.running) return this;
473473

474-
if (process.env.DIAGNOSTIC_DEBUG === "true") {
474+
if (process.env.ARGUS_DEBUG === "true") {
475475
this.useConsoleLogger();
476476
}
477477

@@ -492,7 +492,7 @@ export class ArgusAgent extends EventEmitter {
492492

493493
/** Step 0 — Validate license; fall back to free mode on any failure (never crash). */
494494
private validateLicenseKey(): void {
495-
const licenseKey = process.env.DIAGNOSTIC_LICENSE_KEY;
495+
const licenseKey = process.env.ARGUS_LICENSE_KEY;
496496
if (!licenseKey) return;
497497

498498
try {
@@ -834,7 +834,7 @@ export class ArgusAgent extends EventEmitter {
834834
// ── built-in console logger ───────────────────────────────────
835835

836836
/**
837-
* Internal only — called automatically when DIAGNOSTIC_DEBUG=true.
837+
* Internal only — called automatically when ARGUS_DEBUG=true.
838838
*
839839
* @param prefix Log prefix (default: `[DiagAgent]`)
840840
* @param level `'warn'` — anomalies/crashes/errors only (default)

packages/agent/src/internal/console-logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Console debug logger for ArgusAgent.
33
*
44
* Extracted from ArgusAgent to keep the main class focused on lifecycle.
5-
* When DIAGNOSTIC_DEBUG=true the agent calls installConsoleLogger() once during
5+
* When ARGUS_DEBUG=true the agent calls installConsoleLogger() once during
66
* start() — all registered listeners are returned so the agent can remove them
77
* on stop() without leaking event subscriptions.
88
*/

packages/agent/src/profiling/runtime-monitor.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,22 @@ export class RuntimeMonitor extends EventEmitter {
6363
this.options = {
6464
eventLoopThresholdMs:
6565
options.eventLoopThresholdMs ??
66-
safePositiveInt(process.env.RUNTIME_MONITOR_EVENT_LOOP_THRESHOLD_MS, 50),
66+
safePositiveInt(process.env.ARGUS_EVENT_LOOP_THRESHOLD_MS, 50),
6767
memoryGrowthThresholdBytes:
6868
options.memoryGrowthThresholdBytes ??
69-
safePositiveInt(process.env.RUNTIME_MONITOR_MEMORY_GROWTH_BYTES, 10 * 1024 * 1024),
69+
safePositiveInt(process.env.ARGUS_MEMORY_GROWTH_BYTES, 10 * 1024 * 1024),
7070
cpuProfileCooldownMs:
7171
options.cpuProfileCooldownMs ??
72-
safePositiveInt(process.env.RUNTIME_MONITOR_CPU_PROFILE_COOLDOWN_MS, 60000),
72+
safePositiveInt(process.env.ARGUS_CPU_PROFILE_COOLDOWN_MS, 60000),
7373
checkIntervalMs:
7474
options.checkIntervalMs ??
75-
safePositiveInt(process.env.RUNTIME_MONITOR_CHECK_INTERVAL_MS, 1000),
75+
safePositiveInt(process.env.ARGUS_MONITOR_CHECK_INTERVAL_MS, 1000),
7676
cpuProfileDurationMs:
7777
options.cpuProfileDurationMs ??
78-
safePositiveInt(process.env.RUNTIME_MONITOR_CPU_PROFILE_DURATION_MS, 500),
78+
safePositiveInt(process.env.ARGUS_CPU_PROFILE_DURATION_MS, 500),
7979
heapUsagePctThreshold:
8080
options.heapUsagePctThreshold ??
81-
safePositiveInt(process.env.RUNTIME_MONITOR_HEAP_USAGE_PCT_THRESHOLD, 90),
81+
safePositiveInt(process.env.ARGUS_HEAP_USAGE_PCT_THRESHOLD, 90),
8282
};
8383

8484
this.elMonitor = monitorEventLoopDelay({ resolution: 10 });

packages/agent/tests/argus-agent-coverage.test.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* - 520: resolvePosition delegating to resolver
1515
*
1616
* Also:
17-
* - DIAGNOSTIC_AGENT_ENABLED='false' / '0' env-var kill-switch
17+
* - ARGUS_ENABLED='false' / '0' env-var kill-switch
1818
* - withEntropyThreshold override on logTracingOptions
1919
*/
2020
import { describe, it, afterEach } from "node:test";
@@ -68,42 +68,42 @@ describe("ArgusAgent (extended coverage)", () => {
6868
agent = null;
6969
});
7070

71-
// ── env-var kill-switch: DIAGNOSTIC_AGENT_ENABLED=false ──────────────────
72-
it("should be disabled via DIAGNOSTIC_AGENT_ENABLED=false", async () => {
73-
const orig = process.env.DIAGNOSTIC_AGENT_ENABLED;
74-
process.env.DIAGNOSTIC_AGENT_ENABLED = "false";
71+
// ── env-var kill-switch: ARGUS_ENABLED=false ──────────────────
72+
it("should be disabled via ARGUS_ENABLED=false", async () => {
73+
const orig = process.env.ARGUS_ENABLED;
74+
process.env.ARGUS_ENABLED = "false";
7575
try {
7676
agent = ArgusAgent.createProfile({ enabled: true }); // config says enabled but env overrides
7777
await agent.start();
7878
assert.strictEqual(agent.isRunning, false);
7979
} finally {
80-
if (orig === undefined) delete process.env.DIAGNOSTIC_AGENT_ENABLED;
81-
else process.env.DIAGNOSTIC_AGENT_ENABLED = orig;
80+
if (orig === undefined) delete process.env.ARGUS_ENABLED;
81+
else process.env.ARGUS_ENABLED = orig;
8282
}
8383
});
8484

85-
it("should be disabled via DIAGNOSTIC_AGENT_ENABLED=0", async () => {
86-
const orig = process.env.DIAGNOSTIC_AGENT_ENABLED;
87-
process.env.DIAGNOSTIC_AGENT_ENABLED = "0";
85+
it("should be disabled via ARGUS_ENABLED=0", async () => {
86+
const orig = process.env.ARGUS_ENABLED;
87+
process.env.ARGUS_ENABLED = "0";
8888
try {
8989
agent = ArgusAgent.createProfile({});
9090
await agent.start();
9191
assert.strictEqual(agent.isRunning, false);
9292
} finally {
93-
if (orig === undefined) delete process.env.DIAGNOSTIC_AGENT_ENABLED;
94-
else process.env.DIAGNOSTIC_AGENT_ENABLED = orig;
93+
if (orig === undefined) delete process.env.ARGUS_ENABLED;
94+
else process.env.ARGUS_ENABLED = orig;
9595
}
9696
});
9797

98-
it("should be enabled when DIAGNOSTIC_AGENT_ENABLED=true", async () => {
99-
const orig = process.env.DIAGNOSTIC_AGENT_ENABLED;
100-
process.env.DIAGNOSTIC_AGENT_ENABLED = "true";
98+
it("should be enabled when ARGUS_ENABLED=true", async () => {
99+
const orig = process.env.ARGUS_ENABLED;
100+
process.env.ARGUS_ENABLED = "true";
101101
try {
102102
agent = await ArgusAgent.createProfile({ environment: "prod", appType: "web" }).start();
103103
assert.strictEqual(agent.isRunning, true);
104104
} finally {
105-
if (orig === undefined) delete process.env.DIAGNOSTIC_AGENT_ENABLED;
106-
else process.env.DIAGNOSTIC_AGENT_ENABLED = orig;
105+
if (orig === undefined) delete process.env.ARGUS_ENABLED;
106+
else process.env.ARGUS_ENABLED = orig;
107107
}
108108
});
109109

@@ -326,7 +326,7 @@ describe("ArgusAgent (extended coverage)", () => {
326326
// ── Exporter wired to aggregator flush ────────────────────────────────────
327327
it("should emit error when exporter fails during aggregator flush", async () => {
328328
// shouldExport() requires a valid license — use dev-k1 with 'test-metric' allowed
329-
process.env.DIAGNOSTIC_LICENSE_KEY = makeDevLicense(["test-metric"]);
329+
process.env.ARGUS_LICENSE_KEY = makeDevLicense(["test-metric"]);
330330
try {
331331
agent = await ArgusAgent.create()
332332
.withExporter({
@@ -355,7 +355,7 @@ describe("ArgusAgent (extended coverage)", () => {
355355
const [err] = await Promise.race([errorPromise, timeout]);
356356
assert.ok(err instanceof Error, "Should emit an Error");
357357
} finally {
358-
delete process.env.DIAGNOSTIC_LICENSE_KEY;
358+
delete process.env.ARGUS_LICENSE_KEY;
359359
}
360360
});
361361

packages/agent/tests/argus-agent-debug.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Coverage tests for ArgusAgent — DIAGNOSTIC_DEBUG, useConsoleLogger,
2+
* Coverage tests for ArgusAgent — ARGUS_DEBUG, useConsoleLogger,
33
* and remaining uncovered start/stop branches.
44
*/
55
import { describe, it, afterEach } from "node:test";
@@ -14,11 +14,11 @@ describe("ArgusAgent (debug & logger coverage)", () => {
1414
agent.stop();
1515
agent = null;
1616
}
17-
delete process.env.DIAGNOSTIC_DEBUG;
17+
delete process.env.ARGUS_DEBUG;
1818
});
1919

20-
it("DIAGNOSTIC_DEBUG=true should activate console logger and not throw", async () => {
21-
process.env.DIAGNOSTIC_DEBUG = "true";
20+
it("ARGUS_DEBUG=true should activate console logger and not throw", async () => {
21+
process.env.ARGUS_DEBUG = "true";
2222
agent = await ArgusAgent.create()
2323
.withInstrumentation()
2424
.withHttpTracing()
@@ -47,7 +47,7 @@ describe("ArgusAgent (debug & logger coverage)", () => {
4747
});
4848

4949
it("crash event with no error.message should use the event itself", async () => {
50-
process.env.DIAGNOSTIC_DEBUG = "true";
50+
process.env.ARGUS_DEBUG = "true";
5151
agent = await ArgusAgent.create().withCrashGuard().start();
5252

5353
// Emit crash with no error object

packages/agent/tests/argus-agent.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe("ArgusAgent (builder pattern)", () => {
3636
afterEach(async () => {
3737
await agent?.stop();
3838
agent = null;
39-
delete process.env.DIAGNOSTIC_LICENSE_KEY;
39+
delete process.env.ARGUS_LICENSE_KEY;
4040
});
4141

4242
it("should start and stop with minimal configuration", async () => {
@@ -112,12 +112,12 @@ describe("ArgusAgent (builder pattern)", () => {
112112
result.withGracefulShutdown({ timeoutMs: 3000 }); // accepts options
113113
});
114114

115-
it("valid DIAGNOSTIC_LICENSE_KEY emits info with tier and exp", async () => {
115+
it("valid ARGUS_LICENSE_KEY emits info with tier and exp", async () => {
116116
const jwt = buildJwt({
117117
...BASE_CLAIMS,
118118
exp: Math.floor(Date.now() / 1000) + 3600,
119119
});
120-
process.env.DIAGNOSTIC_LICENSE_KEY = jwt;
120+
process.env.ARGUS_LICENSE_KEY = jwt;
121121

122122
const messages: string[] = [];
123123
agent = ArgusAgent.create();
@@ -130,12 +130,12 @@ describe("ArgusAgent (builder pattern)", () => {
130130
);
131131
});
132132

133-
it("expired DIAGNOSTIC_LICENSE_KEY emits info about expiry without crashing", async () => {
133+
it("expired ARGUS_LICENSE_KEY emits info about expiry without crashing", async () => {
134134
const jwt = buildJwt({
135135
...BASE_CLAIMS,
136136
exp: Math.floor(Date.now() / 1000) - 3600, // already expired
137137
});
138-
process.env.DIAGNOSTIC_LICENSE_KEY = jwt;
138+
process.env.ARGUS_LICENSE_KEY = jwt;
139139

140140
const messages: string[] = [];
141141
agent = ArgusAgent.create();
@@ -150,8 +150,8 @@ describe("ArgusAgent (builder pattern)", () => {
150150
assert.strictEqual(agent.isRunning, true, "Agent should still be running in free mode");
151151
});
152152

153-
it("invalid DIAGNOSTIC_LICENSE_KEY emits error without crashing", async () => {
154-
process.env.DIAGNOSTIC_LICENSE_KEY = "not.a.valid.jwt.atall";
153+
it("invalid ARGUS_LICENSE_KEY emits error without crashing", async () => {
154+
process.env.ARGUS_LICENSE_KEY = "not.a.valid.jwt.atall";
155155

156156
const errors: unknown[] = [];
157157
agent = ArgusAgent.create();

0 commit comments

Comments
 (0)