MCPcopy Create free account
hub / github.com/anus-dev/ANUS / main

Function main

scripts/telemetry_gcp.js:65–187  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63`;
64
65async function main() {
66 console.log('✨ Starting Local Telemetry Exporter for Google Cloud ✨');
67
68 let collectorProcess;
69 let collectorLogFd;
70
71 const originalSandboxSetting = manageTelemetrySettings(
72 true,
73 'http://localhost:4317',
74 'gcp',
75 );
76 registerCleanup(
77 () => [collectorProcess].filter((p) => p), // Function to get processes
78 () => [collectorLogFd].filter((fd) => fd), // Function to get FDs
79 originalSandboxSetting,
80 );
81
82 const projectId = process.env.OTLP_GOOGLE_CLOUD_PROJECT;
83 if (!projectId) {
84 console.error(
85 '🛑 Error: OTLP_GOOGLE_CLOUD_PROJECT environment variable is not exported.',
86 );
87 console.log(
88 ' Please set it to your Google Cloud Project ID and try again.',
89 );
90 console.log(' `export OTLP_GOOGLE_CLOUD_PROJECT=your-project-id`');
91 process.exit(1);
92 }
93 console.log(`✅ Using OTLP Google Cloud Project ID: ${projectId}`);
94
95 console.log('\n🔑 Please ensure you are authenticated with Google Cloud:');
96 console.log(
97 ' - Run `gcloud auth application-default login` OR ensure `GOOGLE_APPLICATION_CREDENTIALS` environment variable points to a valid service account key.',
98 );
99 console.log(
100 ' - The account needs "Cloud Trace Agent", "Monitoring Metric Writer", and "Logs Writer" roles.',
101 );
102
103 if (!fileExists(BIN_DIR)) fs.mkdirSync(BIN_DIR, { recursive: true });
104
105 const otelcolPath = await ensureBinary(
106 'otelcol-contrib',
107 'open-telemetry/opentelemetry-collector-releases',
108 (version, platform, arch, ext) =>
109 `otelcol-contrib_${version}_${platform}_${arch}.${ext}`,
110 'otelcol-contrib',
111 false, // isJaeger = false
112 ).catch((e) => {
113 console.error(`🛑 Error getting otelcol-contrib: ${e.message}`);
114 return null;
115 });
116 if (!otelcolPath) process.exit(1);
117
118 console.log('🧹 Cleaning up old processes and logs...');
119 try {
120 execSync('pkill -f "otelcol-contrib"');
121 console.log('✅ Stopped existing otelcol-contrib process.');
122 } catch (_e) {

Callers 1

telemetry_gcp.jsFile · 0.70

Calls 6

manageTelemetrySettingsFunction · 0.90
registerCleanupFunction · 0.90
fileExistsFunction · 0.90
ensureBinaryFunction · 0.90
waitForPortFunction · 0.90
getOtelConfigContentFunction · 0.85

Tested by

no test coverage detected