MCPcopy Create free account
hub / github.com/SethGammon/Citadel / buildPayload

Function buildPayload

scripts/telemetry-otlp-export.js:273–308  ·  view source on GitHub ↗
(metrics, projectName)

Source from the content-addressed store, hash-verified

271}
272
273function buildPayload(metrics, projectName) {
274 const metricEntries = [];
275 for (const [name, def] of Object.entries(metrics)) {
276 if (def.dataPoints.length === 0) continue;
277 const entry = { name, unit: def.unit };
278 if (def.type === 'gauge') {
279 entry.gauge = { dataPoints: def.dataPoints };
280 } else {
281 entry.sum = {
282 aggregationTemporality: AGGREGATION_TEMPORALITY_DELTA,
283 isMonotonic: def.monotonic === true,
284 dataPoints: def.dataPoints,
285 };
286 }
287 metricEntries.push(entry);
288 }
289
290 return {
291 resourceMetrics: [
292 {
293 resource: {
294 attributes: toAttributes({
295 'service.name': 'citadel',
296 'citadel.project': projectName,
297 }),
298 },
299 scopeMetrics: [
300 {
301 scope: { name: SCOPE_NAME, version: SCOPE_VERSION },
302 metrics: metricEntries,
303 },
304 ],
305 },
306 ],
307 };
308}
309
310function resolveEndpoint(raw) {
311 const url = new URL(raw);

Callers 1

mainFunction · 0.85

Calls 1

toAttributesFunction · 0.85

Tested by

no test coverage detected