vcluster-yaml-mcp-server 1.0.11 → 1.0.12
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/package.json +1 -1
- package/src/instrumentation.js +6 -37
package/package.json
CHANGED
package/src/instrumentation.js
CHANGED
|
@@ -4,52 +4,22 @@
|
|
|
4
4
|
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
5
5
|
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
|
|
6
6
|
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
7
|
-
import { Resource } from '@opentelemetry/resources';
|
|
8
|
-
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions';
|
|
9
|
-
import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api';
|
|
10
|
-
|
|
11
|
-
// Enable diagnostic logging (set to DiagLogLevel.DEBUG for troubleshooting)
|
|
12
|
-
const logLevel = process.env.OTEL_LOG_LEVEL === 'debug' ? DiagLogLevel.DEBUG : DiagLogLevel.INFO;
|
|
13
|
-
diag.setLogger(new DiagConsoleLogger(), logLevel);
|
|
14
7
|
|
|
15
8
|
// Configure OTLP exporter
|
|
16
9
|
const traceExporter = new OTLPTraceExporter({
|
|
17
|
-
// OTel Collector endpoint (can be overridden via env var)
|
|
18
10
|
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://opentelemetry-collector.tempo.svc.cluster.local:4317',
|
|
19
|
-
// Use gRPC protocol
|
|
20
|
-
// No TLS needed for in-cluster communication
|
|
21
11
|
});
|
|
22
12
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
new Resource({
|
|
26
|
-
[ATTR_SERVICE_NAME]: process.env.OTEL_SERVICE_NAME || 'vcluster-yaml-mcp-server',
|
|
27
|
-
[ATTR_SERVICE_VERSION]: process.env.npm_package_version || '1.0.0',
|
|
28
|
-
// Add custom attributes
|
|
29
|
-
'deployment.environment': process.env.NODE_ENV || 'production',
|
|
30
|
-
'service.namespace': 'default',
|
|
31
|
-
})
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
// Initialize OpenTelemetry SDK
|
|
13
|
+
// Initialize OpenTelemetry SDK with minimal config
|
|
14
|
+
// The SDK will automatically detect and set up resource attributes
|
|
35
15
|
const sdk = new NodeSDK({
|
|
36
|
-
|
|
16
|
+
serviceName: process.env.OTEL_SERVICE_NAME || 'vcluster-yaml-mcp-server',
|
|
37
17
|
traceExporter,
|
|
38
18
|
instrumentations: [
|
|
39
19
|
getNodeAutoInstrumentations({
|
|
40
|
-
//
|
|
20
|
+
// Disable file system instrumentation (too noisy)
|
|
41
21
|
'@opentelemetry/instrumentation-fs': {
|
|
42
|
-
enabled: false,
|
|
43
|
-
},
|
|
44
|
-
'@opentelemetry/instrumentation-express': {
|
|
45
|
-
enabled: true,
|
|
46
|
-
},
|
|
47
|
-
'@opentelemetry/instrumentation-http': {
|
|
48
|
-
enabled: true,
|
|
49
|
-
// Add request/response headers to spans
|
|
50
|
-
requestHook: (span, request) => {
|
|
51
|
-
span.setAttribute('http.client_ip', request.headers['x-forwarded-for'] || request.connection.remoteAddress);
|
|
52
|
-
},
|
|
22
|
+
enabled: false,
|
|
53
23
|
},
|
|
54
24
|
}),
|
|
55
25
|
],
|
|
@@ -59,8 +29,7 @@ const sdk = new NodeSDK({
|
|
|
59
29
|
sdk.start();
|
|
60
30
|
|
|
61
31
|
console.log('OpenTelemetry tracing initialized');
|
|
62
|
-
console.log(` Service: ${
|
|
63
|
-
console.log(` Version: ${resource.attributes[ATTR_SERVICE_VERSION]}`);
|
|
32
|
+
console.log(` Service: ${process.env.OTEL_SERVICE_NAME || 'vcluster-yaml-mcp-server'}`);
|
|
64
33
|
console.log(` Exporter: ${process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://opentelemetry-collector.tempo.svc.cluster.local:4317'}`);
|
|
65
34
|
|
|
66
35
|
// Graceful shutdown
|