securenow 5.0.0 → 5.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.
@@ -0,0 +1,652 @@
1
+ # SecureNow Environment Variables Reference
2
+
3
+ Complete reference for all environment variables supported by SecureNow.
4
+
5
+ ---
6
+
7
+ ## Quick Reference Table
8
+
9
+ | Variable | Type | Default | Description |
10
+ |----------|------|---------|-------------|
11
+ | **SECURENOW_APPID** | Required | - | Application identifier / service name |
12
+ | **SECURENOW_INSTANCE** | Required | `http://46.62.173.237:4318` | OTLP collector base URL |
13
+ | **SECURENOW_LOGGING_ENABLED** | Optional | `1` | Enable/disable logging |
14
+ | **SECURENOW_NO_UUID** | Optional | `0` | Disable UUID suffix on service name |
15
+ | **SECURENOW_STRICT** | Optional | `0` | Exit if APPID missing in cluster mode |
16
+ | **SECURENOW_CAPTURE_BODY** | Optional | `0` | Enable request body capture |
17
+ | **SECURENOW_MAX_BODY_SIZE** | Optional | `10240` | Max body size in bytes |
18
+ | **SECURENOW_SENSITIVE_FIELDS** | Optional | - | Comma-separated list of fields to redact |
19
+ | **SECURENOW_DISABLE_INSTRUMENTATIONS** | Optional | - | Comma-separated list of packages to disable |
20
+ | **SECURENOW_TEST_SPAN** | Optional | `0` | Emit test span on startup |
21
+ | **OTEL_SERVICE_NAME** | Optional | - | Alternative to SECURENOW_APPID |
22
+ | **OTEL_EXPORTER_OTLP_ENDPOINT** | Optional | - | Alternative to SECURENOW_INSTANCE |
23
+ | **OTEL_EXPORTER_OTLP_HEADERS** | Optional | - | Headers for OTLP requests |
24
+ | **OTEL_EXPORTER_OTLP_TRACES_ENDPOINT** | Optional | - | Override traces endpoint |
25
+ | **OTEL_EXPORTER_OTLP_LOGS_ENDPOINT** | Optional | - | Override logs endpoint |
26
+ | **OTEL_LOG_LEVEL** | Optional | `none` | SDK log level |
27
+ | **NODE_ENV** | Optional | `production` | Environment name |
28
+
29
+ ---
30
+
31
+ ## Required Variables
32
+
33
+ ### SECURENOW_APPID
34
+
35
+ **Description:** Your application identifier. Used as the service name in traces and logs.
36
+
37
+ **Format:** String (alphanumeric, hyphens, underscores)
38
+
39
+ **Examples:**
40
+ ```bash
41
+ export SECURENOW_APPID=my-express-app
42
+ export SECURENOW_APPID=api-gateway
43
+ export SECURENOW_APPID=user-service
44
+ ```
45
+
46
+ **Notes:**
47
+ - If not set, SecureNow will use a fallback name with UUID
48
+ - In cluster mode with `SECURENOW_STRICT=1`, missing APPID will cause process exit
49
+ - Alternative: Use `OTEL_SERVICE_NAME` (OpenTelemetry standard)
50
+
51
+ **Behavior:**
52
+ - Without `SECURENOW_NO_UUID=1`: Service name becomes `{APPID}-{UUID}`
53
+ - With `SECURENOW_NO_UUID=1`: Service name is exactly `{APPID}`
54
+
55
+ ---
56
+
57
+ ### SECURENOW_INSTANCE
58
+
59
+ **Description:** Base URL of your OTLP collector endpoint.
60
+
61
+ **Format:** URL (http/https)
62
+
63
+ **Examples:**
64
+ ```bash
65
+ # Local collector
66
+ export SECURENOW_INSTANCE=http://localhost:4318
67
+
68
+ # Remote collector
69
+ export SECURENOW_INSTANCE=http://collector.example.com:4318
70
+
71
+ # HTTPS
72
+ export SECURENOW_INSTANCE=https://collector.example.com:4318
73
+ ```
74
+
75
+ **Default:** `http://46.62.173.237:4318` (if not set)
76
+
77
+ **Notes:**
78
+ - Used to construct traces and logs endpoints
79
+ - Traces sent to: `{SECURENOW_INSTANCE}/v1/traces`
80
+ - Logs sent to: `{SECURENOW_INSTANCE}/v1/logs`
81
+ - Alternative: Use `OTEL_EXPORTER_OTLP_ENDPOINT`
82
+
83
+ ---
84
+
85
+ ## Service Naming
86
+
87
+ ### OTEL_SERVICE_NAME
88
+
89
+ **Description:** Standard OpenTelemetry variable for service name. Alternative to `SECURENOW_APPID`.
90
+
91
+ **Format:** String
92
+
93
+ **Example:**
94
+ ```bash
95
+ export OTEL_SERVICE_NAME=my-app
96
+ ```
97
+
98
+ **Priority:** If both are set, `OTEL_SERVICE_NAME` takes precedence.
99
+
100
+ ---
101
+
102
+ ### SECURENOW_NO_UUID
103
+
104
+ **Description:** Disable automatic UUID suffix on service name.
105
+
106
+ **Format:** `1` (enabled) or `0` (disabled)
107
+
108
+ **Default:** `0`
109
+
110
+ **Example:**
111
+ ```bash
112
+ export SECURENOW_NO_UUID=1
113
+ ```
114
+
115
+ **Use case:**
116
+ - PM2 cluster mode - use same service name for all workers
117
+ - Docker containers with replica sets
118
+ - Kubernetes pods in a deployment
119
+
120
+ **Behavior:**
121
+ - `0`: Service name = `my-app-a1b2c3d4`
122
+ - `1`: Service name = `my-app`
123
+
124
+ ---
125
+
126
+ ### SECURENOW_STRICT
127
+
128
+ **Description:** Exit process if `SECURENOW_APPID` is not set in cluster mode.
129
+
130
+ **Format:** `1` (enabled) or `0` (disabled)
131
+
132
+ **Default:** `0`
133
+
134
+ **Example:**
135
+ ```bash
136
+ export SECURENOW_STRICT=1
137
+ ```
138
+
139
+ **Use case:**
140
+ - Production environments where service name must be explicit
141
+ - Prevent "free" or auto-generated service names
142
+ - Ensure proper configuration before starting
143
+
144
+ **Detection:**
145
+ Cluster mode is detected when any of these exist:
146
+ - `NODE_APP_INSTANCE` (PM2)
147
+ - `pm_id` (PM2)
148
+
149
+ ---
150
+
151
+ ## Connection Settings
152
+
153
+ ### OTEL_EXPORTER_OTLP_ENDPOINT
154
+
155
+ **Description:** Standard OpenTelemetry variable for OTLP endpoint. Alternative to `SECURENOW_INSTANCE`.
156
+
157
+ **Format:** URL
158
+
159
+ **Example:**
160
+ ```bash
161
+ export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
162
+ ```
163
+
164
+ **Priority:** If both are set, `OTEL_EXPORTER_OTLP_ENDPOINT` takes precedence.
165
+
166
+ ---
167
+
168
+ ### OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
169
+
170
+ **Description:** Override the traces endpoint specifically.
171
+
172
+ **Format:** Full URL including `/v1/traces`
173
+
174
+ **Example:**
175
+ ```bash
176
+ export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://traces-collector:4318/v1/traces
177
+ ```
178
+
179
+ **Use case:**
180
+ - Separate collectors for traces and logs
181
+ - Different routing for traces
182
+
183
+ ---
184
+
185
+ ### OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
186
+
187
+ **Description:** Override the logs endpoint specifically.
188
+
189
+ **Format:** Full URL including `/v1/logs`
190
+
191
+ **Example:**
192
+ ```bash
193
+ export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://logs-collector:4318/v1/logs
194
+ ```
195
+
196
+ **Use case:**
197
+ - Separate collectors for traces and logs
198
+ - Different routing for logs
199
+
200
+ ---
201
+
202
+ ### OTEL_EXPORTER_OTLP_HEADERS
203
+
204
+ **Description:** Headers to include in OTLP export requests.
205
+
206
+ **Format:** Comma-separated `key=value` pairs
207
+
208
+ **Examples:**
209
+ ```bash
210
+ # Single header
211
+ export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-api-key"
212
+
213
+ # Multiple headers
214
+ export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=key123,x-tenant-id=tenant456"
215
+
216
+ # Authentication
217
+ export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer token123"
218
+ ```
219
+
220
+ **Use case:**
221
+ - API authentication
222
+ - Multi-tenancy headers
223
+ - Custom routing headers
224
+
225
+ **Notes:**
226
+ - Header names are case-insensitive
227
+ - Trailing/leading spaces are trimmed
228
+
229
+ ---
230
+
231
+ ## Logging
232
+
233
+ ### SECURENOW_LOGGING_ENABLED
234
+
235
+ **Description:** Enable or disable automatic logging to OTLP backend.
236
+
237
+ **Format:** `1` (enabled) or `0` (disabled)
238
+
239
+ **Default:** `1` (enabled by default)
240
+
241
+ **Examples:**
242
+ ```bash
243
+ # Enable logging
244
+ export SECURENOW_LOGGING_ENABLED=1
245
+
246
+ # Disable logging
247
+ export SECURENOW_LOGGING_ENABLED=0
248
+ ```
249
+
250
+ **When enabled:**
251
+ - Logs are sent to `{SECURENOW_INSTANCE}/v1/logs`
252
+ - Console instrumentation can capture logs
253
+ - Direct logger API is available
254
+
255
+ **When disabled:**
256
+ - No logs sent to backend
257
+ - `getLogger()` returns `null`
258
+ - Console instrumentation shows warning
259
+
260
+ ---
261
+
262
+ ## Request Body Capture
263
+
264
+ ### SECURENOW_CAPTURE_BODY
265
+
266
+ **Description:** Enable capture of HTTP request bodies in traces.
267
+
268
+ **Format:** `1` (enabled) or `0` (disabled)
269
+
270
+ **Default:** `0` (disabled)
271
+
272
+ **Example:**
273
+ ```bash
274
+ export SECURENOW_CAPTURE_BODY=1
275
+ ```
276
+
277
+ **Supported content types:**
278
+ - `application/json`
279
+ - `application/x-www-form-urlencoded`
280
+ - `application/graphql`
281
+
282
+ **Not captured:**
283
+ - `multipart/form-data` (file uploads)
284
+ - Bodies larger than `SECURENOW_MAX_BODY_SIZE`
285
+
286
+ **Security:**
287
+ All captured bodies are automatically scanned for sensitive fields and redacted.
288
+
289
+ ---
290
+
291
+ ### SECURENOW_MAX_BODY_SIZE
292
+
293
+ **Description:** Maximum request body size to capture (in bytes).
294
+
295
+ **Format:** Number (bytes)
296
+
297
+ **Default:** `10240` (10 KB)
298
+
299
+ **Examples:**
300
+ ```bash
301
+ # 10 KB (default)
302
+ export SECURENOW_MAX_BODY_SIZE=10240
303
+
304
+ # 20 KB
305
+ export SECURENOW_MAX_BODY_SIZE=20480
306
+
307
+ # 5 KB
308
+ export SECURENOW_MAX_BODY_SIZE=5120
309
+ ```
310
+
311
+ **Behavior:**
312
+ - Bodies larger than this are not captured
313
+ - Span attribute shows: `[TOO LARGE: {size} bytes]`
314
+
315
+ ---
316
+
317
+ ### SECURENOW_SENSITIVE_FIELDS
318
+
319
+ **Description:** Additional field names to redact from request bodies (comma-separated).
320
+
321
+ **Format:** Comma-separated list of field names
322
+
323
+ **Default:** (see below for auto-redacted fields)
324
+
325
+ **Examples:**
326
+ ```bash
327
+ # Additional custom fields
328
+ export SECURENOW_SENSITIVE_FIELDS="internal_token,session_key"
329
+
330
+ # Multiple fields
331
+ export SECURENOW_SENSITIVE_FIELDS="custom_secret,private_data,internal_id"
332
+ ```
333
+
334
+ **Auto-redacted fields (built-in):**
335
+ - `password`, `passwd`, `pwd`
336
+ - `secret`, `token`, `api_key`, `apikey`, `access_token`
337
+ - `auth`, `credentials`, `mysql_pwd`
338
+ - `stripeToken`, `card`, `cardnumber`
339
+ - `ccv`, `cvc`, `cvv`
340
+ - `ssn`, `pin`
341
+
342
+ **Matching:**
343
+ - Case-insensitive
344
+ - Substring match (e.g., `password` matches `user_password`, `PASSWORD`, `passwordField`)
345
+ - Works recursively in nested objects
346
+
347
+ ---
348
+
349
+ ## Instrumentation Control
350
+
351
+ ### SECURENOW_DISABLE_INSTRUMENTATIONS
352
+
353
+ **Description:** Disable specific OpenTelemetry instrumentations.
354
+
355
+ **Format:** Comma-separated list of package names
356
+
357
+ **Example:**
358
+ ```bash
359
+ # Disable file system and DNS instrumentations
360
+ export SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns
361
+
362
+ # Disable multiple
363
+ export SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns,net,http2
364
+ ```
365
+
366
+ **Common packages you might disable:**
367
+ - `fs` - File system operations
368
+ - `dns` - DNS lookups
369
+ - `net` - Network operations
370
+ - `http2` - HTTP/2 client/server
371
+ - `grpc` - gRPC client/server
372
+
373
+ **Use case:**
374
+ - Reduce overhead by disabling unused instrumentations
375
+ - Avoid noisy traces from certain operations
376
+ - Debug issues with specific instrumentations
377
+
378
+ ---
379
+
380
+ ## Debugging
381
+
382
+ ### OTEL_LOG_LEVEL
383
+
384
+ **Description:** OpenTelemetry SDK internal log level.
385
+
386
+ **Format:** `none`, `error`, `warn`, `info`, `debug`
387
+
388
+ **Default:** `none`
389
+
390
+ **Examples:**
391
+ ```bash
392
+ # See all debug information
393
+ export OTEL_LOG_LEVEL=debug
394
+
395
+ # Only errors
396
+ export OTEL_LOG_LEVEL=error
397
+
398
+ # No SDK logs
399
+ export OTEL_LOG_LEVEL=none
400
+ ```
401
+
402
+ **Use case:**
403
+ - Troubleshooting setup issues
404
+ - Understanding trace/log export behavior
405
+ - Debugging connection problems
406
+
407
+ **Output:**
408
+ - Goes to console (stderr)
409
+ - Prefixed with `[securenow]`
410
+
411
+ ---
412
+
413
+ ### SECURENOW_TEST_SPAN
414
+
415
+ **Description:** Emit a test span on startup to verify tracing is working.
416
+
417
+ **Format:** `1` (enabled) or `0` (disabled)
418
+
419
+ **Default:** `0`
420
+
421
+ **Example:**
422
+ ```bash
423
+ export SECURENOW_TEST_SPAN=1
424
+ ```
425
+
426
+ **Behavior:**
427
+ - Creates a span named `securenow.startup.smoke`
428
+ - Span is immediately ended
429
+ - Useful for testing collector connectivity
430
+
431
+ ---
432
+
433
+ ## Environment
434
+
435
+ ### NODE_ENV
436
+
437
+ **Description:** Standard Node.js environment variable. Sent as `deployment.environment` attribute.
438
+
439
+ **Format:** String (typically: `development`, `production`, `test`, `staging`)
440
+
441
+ **Default:** `production`
442
+
443
+ **Examples:**
444
+ ```bash
445
+ export NODE_ENV=development
446
+ export NODE_ENV=production
447
+ export NODE_ENV=staging
448
+ export NODE_ENV=test
449
+ ```
450
+
451
+ **Use case:**
452
+ - Filter traces/logs by environment
453
+ - Different configurations per environment
454
+ - Standard Node.js convention
455
+
456
+ ---
457
+
458
+ ## Configuration Examples
459
+
460
+ ### Development Environment
461
+
462
+ ```bash
463
+ # .env.development
464
+ SECURENOW_APPID=my-app-dev
465
+ SECURENOW_INSTANCE=http://localhost:4318
466
+ SECURENOW_LOGGING_ENABLED=1
467
+ SECURENOW_CAPTURE_BODY=1
468
+ SECURENOW_MAX_BODY_SIZE=20480
469
+ OTEL_LOG_LEVEL=debug
470
+ SECURENOW_TEST_SPAN=1
471
+ NODE_ENV=development
472
+ ```
473
+
474
+ ### Production Environment
475
+
476
+ ```bash
477
+ # .env.production
478
+ SECURENOW_APPID=my-app-prod
479
+ SECURENOW_INSTANCE=https://collector.prod.example.com:4318
480
+ OTEL_EXPORTER_OTLP_HEADERS=x-api-key=prod-key-12345
481
+ SECURENOW_LOGGING_ENABLED=1
482
+ SECURENOW_CAPTURE_BODY=0
483
+ SECURENOW_NO_UUID=1
484
+ SECURENOW_STRICT=1
485
+ SECURENOW_SENSITIVE_FIELDS=internal_id,session_token
486
+ OTEL_LOG_LEVEL=error
487
+ NODE_ENV=production
488
+ ```
489
+
490
+ ### PM2 Cluster
491
+
492
+ ```bash
493
+ # ecosystem.config.js environment
494
+ SECURENOW_APPID=my-app
495
+ SECURENOW_INSTANCE=http://localhost:4318
496
+ SECURENOW_LOGGING_ENABLED=1
497
+ SECURENOW_NO_UUID=1
498
+ SECURENOW_STRICT=1
499
+ SECURENOW_CAPTURE_BODY=1
500
+ NODE_ENV=production
501
+ ```
502
+
503
+ ### Docker / Kubernetes
504
+
505
+ ```bash
506
+ # Docker environment or K8s ConfigMap
507
+ SECURENOW_APPID=my-service
508
+ SECURENOW_INSTANCE=http://otel-collector:4318
509
+ SECURENOW_LOGGING_ENABLED=1
510
+ SECURENOW_NO_UUID=1
511
+ SECURENOW_CAPTURE_BODY=0
512
+ NODE_ENV=production
513
+ ```
514
+
515
+ ### Separate Collectors for Traces and Logs
516
+
517
+ ```bash
518
+ # Different backends for traces and logs
519
+ SECURENOW_APPID=my-app
520
+ OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://traces-collector:4318/v1/traces
521
+ OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://logs-collector:4318/v1/logs
522
+ SECURENOW_LOGGING_ENABLED=1
523
+ ```
524
+
525
+ ---
526
+
527
+ ## Priority and Overrides
528
+
529
+ When multiple variables are set, this is the priority order:
530
+
531
+ ### Service Name
532
+
533
+ 1. `OTEL_SERVICE_NAME` (highest priority)
534
+ 2. `SECURENOW_APPID`
535
+ 3. Auto-generated fallback (lowest priority)
536
+
537
+ ### OTLP Endpoint
538
+
539
+ 1. `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` (for traces)
540
+ 2. `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` (for logs)
541
+ 3. `OTEL_EXPORTER_OTLP_ENDPOINT`
542
+ 4. `SECURENOW_INSTANCE`
543
+ 5. Default: `http://46.62.173.237:4318` (lowest priority)
544
+
545
+ ---
546
+
547
+ ## Validation
548
+
549
+ SecureNow validates environment variables on startup. Check console output:
550
+
551
+ ```bash
552
+ [securenow] pid=12345 SECURENOW_APPID="my-app" OTEL_SERVICE_NAME=null → service.name=my-app-uuid123
553
+ [securenow] OTel SDK started → http://localhost:4318/v1/traces
554
+ [securenow] 📋 Logging: ENABLED → http://localhost:4318/v1/logs
555
+ [securenow] 📝 Request body capture: ENABLED (max: 10240 bytes)
556
+ ```
557
+
558
+ ---
559
+
560
+ ## Best Practices
561
+
562
+ ### 1. Use .env Files
563
+
564
+ Don't hardcode in your application:
565
+
566
+ ```bash
567
+ # .env
568
+ SECURENOW_APPID=my-app
569
+ SECURENOW_INSTANCE=http://localhost:4318
570
+ ```
571
+
572
+ ### 2. Different Configs per Environment
573
+
574
+ ```bash
575
+ # .env.development
576
+ SECURENOW_CAPTURE_BODY=1
577
+ OTEL_LOG_LEVEL=debug
578
+
579
+ # .env.production
580
+ SECURENOW_CAPTURE_BODY=0
581
+ OTEL_LOG_LEVEL=error
582
+ ```
583
+
584
+ ### 3. Use SECURENOW_NO_UUID in Clusters
585
+
586
+ ```bash
587
+ # PM2 cluster with 4 workers
588
+ SECURENOW_NO_UUID=1
589
+ ```
590
+
591
+ ### 4. Enable SECURENOW_STRICT in Production
592
+
593
+ ```bash
594
+ # Fail fast if misconfigured
595
+ SECURENOW_STRICT=1
596
+ ```
597
+
598
+ ### 5. Disable Body Capture in Production
599
+
600
+ ```bash
601
+ # Development
602
+ SECURENOW_CAPTURE_BODY=1
603
+
604
+ # Production
605
+ SECURENOW_CAPTURE_BODY=0
606
+ ```
607
+
608
+ ---
609
+
610
+ ## Troubleshooting
611
+
612
+ ### Check Current Values
613
+
614
+ ```bash
615
+ # Print all SECURENOW variables
616
+ env | grep SECURENOW
617
+
618
+ # Print all OTEL variables
619
+ env | grep OTEL
620
+
621
+ # Check specific variable
622
+ echo $SECURENOW_APPID
623
+ ```
624
+
625
+ ### Verify in Application
626
+
627
+ SecureNow logs current configuration on startup. Look for lines like:
628
+
629
+ ```
630
+ [securenow] pid=12345 SECURENOW_APPID="my-app" → service.name=my-app
631
+ [securenow] OTel SDK started → http://localhost:4318/v1/traces
632
+ ```
633
+
634
+ ### Enable Debug Mode
635
+
636
+ ```bash
637
+ export OTEL_LOG_LEVEL=debug
638
+ node app.js
639
+ ```
640
+
641
+ ---
642
+
643
+ ## Related Documentation
644
+
645
+ - [Express Setup Guide](./EXPRESS-SETUP-GUIDE.md)
646
+ - [Next.js Setup Guide](./NEXTJS-SETUP-COMPLETE.md)
647
+ - [Logging Guide](./LOGGING-GUIDE.md)
648
+ - [NPM README](../NPM_README.md)
649
+
650
+ ---
651
+
652
+ **Complete reference for all SecureNow environment variables.** 🎯