vcluster-yaml-mcp-server 1.0.10 → 1.0.11
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 +7 -1
- package/src/instrumentation.js +72 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vcluster-yaml-mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "MCP server for querying vcluster YAML configurations using jq",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -33,6 +33,12 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@modelcontextprotocol/sdk": "^1.20.1",
|
|
36
|
+
"@opentelemetry/api": "^1.9.0",
|
|
37
|
+
"@opentelemetry/auto-instrumentations-node": "^0.66.0",
|
|
38
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "^0.207.0",
|
|
39
|
+
"@opentelemetry/resources": "^2.2.0",
|
|
40
|
+
"@opentelemetry/sdk-node": "^0.207.0",
|
|
41
|
+
"@opentelemetry/semantic-conventions": "^1.37.0",
|
|
36
42
|
"ajv": "^8.17.1",
|
|
37
43
|
"ajv-formats": "^3.0.1",
|
|
38
44
|
"chalk": "^5.4.1",
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// OpenTelemetry instrumentation setup
|
|
2
|
+
// This file must be loaded BEFORE the application code
|
|
3
|
+
|
|
4
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
5
|
+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
|
|
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
|
+
|
|
15
|
+
// Configure OTLP exporter
|
|
16
|
+
const traceExporter = new OTLPTraceExporter({
|
|
17
|
+
// OTel Collector endpoint (can be overridden via env var)
|
|
18
|
+
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
|
+
});
|
|
22
|
+
|
|
23
|
+
// Configure service resource
|
|
24
|
+
const resource = Resource.default().merge(
|
|
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
|
|
35
|
+
const sdk = new NodeSDK({
|
|
36
|
+
resource,
|
|
37
|
+
traceExporter,
|
|
38
|
+
instrumentations: [
|
|
39
|
+
getNodeAutoInstrumentations({
|
|
40
|
+
// Auto-instrument Express, HTTP, and other common libraries
|
|
41
|
+
'@opentelemetry/instrumentation-fs': {
|
|
42
|
+
enabled: false, // Disable file system instrumentation (too noisy)
|
|
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
|
+
},
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Start the SDK
|
|
59
|
+
sdk.start();
|
|
60
|
+
|
|
61
|
+
console.log('OpenTelemetry tracing initialized');
|
|
62
|
+
console.log(` Service: ${resource.attributes[ATTR_SERVICE_NAME]}`);
|
|
63
|
+
console.log(` Version: ${resource.attributes[ATTR_SERVICE_VERSION]}`);
|
|
64
|
+
console.log(` Exporter: ${process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://opentelemetry-collector.tempo.svc.cluster.local:4317'}`);
|
|
65
|
+
|
|
66
|
+
// Graceful shutdown
|
|
67
|
+
process.on('SIGTERM', () => {
|
|
68
|
+
sdk.shutdown()
|
|
69
|
+
.then(() => console.log('OpenTelemetry SDK shut down successfully'))
|
|
70
|
+
.catch((error) => console.error('Error shutting down OpenTelemetry SDK', error))
|
|
71
|
+
.finally(() => process.exit(0));
|
|
72
|
+
});
|