securenow 3.0.2 → 3.0.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tracing.js +13 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securenow",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "type": "commonjs",
5
5
  "main": "register.js",
6
6
  "exports": { ".": "./register.js", "./register": "./register.js", "./tracing": "./tracing.js" },
package/tracing.js CHANGED
@@ -4,12 +4,12 @@
4
4
  * securenow/tracing.js
5
5
  * Preload with: NODE_OPTIONS="--require securenow/register" (or -r securenow/register via PM2)
6
6
  * Env you can use:
7
- * - securenow_instance=http://host:4318 # base OTLP/HTTP endpoint (defaults to http://46.62.173.237:4318)
7
+ * - SECURENOW_INSTANCE=http://host:4318 # base OTLP/HTTP endpoint (defaults to http://46.62.173.237:4318)
8
8
  * - OTEL_EXPORTER_OTLP_ENDPOINT=... # alt base (will be used if securenow_instance not set)
9
9
  * - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=... # full traces URL (overrides base)
10
10
  * - OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer abc123,foo=bar"
11
11
  * - OTEL_SERVICE_NAME=your-service # logical name (UUID suffix auto-appended)
12
- * - securenow_appid=your-appid # fallback logical name (UUID suffix auto-appended)
12
+ * - SECURENOW_APPID=your-appid # fallback logical name (UUID suffix auto-appended)
13
13
  * - SECURENOW_NO_UUID=1 # disable UUID suffix
14
14
  * - SECURENOW_DISABLE_INSTRUMENTATIONS="@opentelemetry/instrumentation-mongodb,@opentelemetry/instrumentation-redis"
15
15
  * - OTEL_LOG_LEVEL=info|debug # OTel internal diagnostics
@@ -17,10 +17,11 @@
17
17
  */
18
18
 
19
19
  const { diag, DiagConsoleLogger, DiagLogLevel } = require('@opentelemetry/api');
20
+ const env = k => process.env[k] ?? process.env[k.toUpperCase()] ?? process.env[k.toLowerCase()];
20
21
 
21
22
  // ---------- Diagnostics level ----------
22
23
  (() => {
23
- const L = (process.env.OTEL_LOG_LEVEL || '').toLowerCase();
24
+ const L = (env('OTEL_LOG_LEVEL') || '').toLowerCase();
24
25
  const level =
25
26
  L === 'debug' ? DiagLogLevel.DEBUG :
26
27
  L === 'info' ? DiagLogLevel.INFO :
@@ -48,8 +49,8 @@ try {
48
49
  }
49
50
 
50
51
  // ---------- Endpoint config (HTTP/4318) ----------
51
- const endpointBase = (process.env.securenow_instance || process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://46.62.173.237:4318').replace(/\/$/, '');
52
- const tracesUrl = (process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT || `${endpointBase}/v1/traces`);
52
+ const endpointBase = (env('SECURENOW_INSTANCE') || env('OTEL_EXPORTER_OTLP_ENDPOINT') || 'http://46.62.173.237:4318').replace(/\/$/, '');
53
+ const tracesUrl = (env('OTEL_EXPORTER_OTLP_TRACES_ENDPOINT') || `${endpointBase}/v1/traces`);
53
54
 
54
55
  // ---------- Headers parsing ----------
55
56
  function parseOtelHeaders(str) {
@@ -67,19 +68,18 @@ function parseOtelHeaders(str) {
67
68
  }
68
69
  return headers;
69
70
  }
70
- const headers = parseOtelHeaders(process.env.OTEL_EXPORTER_OTLP_HEADERS);
71
-
71
+ const headers = parseOtelHeaders(env('OTEL_EXPORTER_OTLP_HEADERS'));
72
72
  // ---------- Service name with UUID rules ----------
73
73
  let serviceName;
74
- if (process.env.securenow_appid) {
75
- serviceName = process.env.securenow_appid;
74
+ if (env('SECURENOW_APPID')) {
75
+ serviceName = env('SECURENOW_APPID');
76
76
  } else {
77
77
  // default can also be unique to avoid collisions
78
78
  serviceName = `securenow-free-${uuidv4()}`;
79
79
  }
80
80
 
81
81
  // ---------- Disable instrumentations via env ----------
82
- const disabledList = (process.env.SECURENOW_DISABLE_INSTRUMENTATIONS || '')
82
+ const disabledList = (env('SECURENOW_DISABLE_INSTRUMENTATIONS') || '')
83
83
  .split(',')
84
84
  .map(s => s.trim())
85
85
  .filter(Boolean);
@@ -97,8 +97,8 @@ const sdk = new NodeSDK({
97
97
  }),
98
98
  resource: new Resource({
99
99
  [SemanticResourceAttributes.SERVICE_NAME]: serviceName,
100
- [SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: process.env.NODE_ENV || 'development',
101
- [SemanticResourceAttributes.SERVICE_VERSION]: process.env.npm_package_version || undefined,
100
+ [SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: env('NODE_ENV') || 'development',
101
+ [SemanticResourceAttributes.SERVICE_VERSION]: env('npm_package_version') || undefined,
102
102
  }),
103
103
  });
104
104
 
@@ -110,7 +110,7 @@ const sdk = new NodeSDK({
110
110
  console.log('[securenow] OTel SDK started →', tracesUrl);
111
111
 
112
112
  // Optional smoke test to verify export path
113
- if ((process.env.SECURENOW_TEST_SPAN || '') === '1') {
113
+ if ((env('SECURENOW_TEST_SPAN') || '') === '1') {
114
114
  const api = require('@opentelemetry/api');
115
115
  const tracer = api.trace.getTracer('securenow-smoke');
116
116
  const span = tracer.startSpan('securenow.startup.smoke');