@netgreener/runtime 0.1.0
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/CHANGELOG.md +16 -0
- package/README.md +28 -0
- package/TUTORIAL.md +495 -0
- package/dist/aggregator.d.ts +43 -0
- package/dist/aggregator.js +270 -0
- package/dist/analyze/analyzeGate.d.ts +44 -0
- package/dist/analyze/analyzeGate.js +114 -0
- package/dist/analyze/apiOverconsumptionDetector.d.ts +13 -0
- package/dist/analyze/apiOverconsumptionDetector.js +75 -0
- package/dist/analyze/astDetectors.d.ts +38 -0
- package/dist/analyze/astDetectors.js +566 -0
- package/dist/analyze/buildResourceFindings.d.ts +34 -0
- package/dist/analyze/buildResourceFindings.js +86 -0
- package/dist/analyze/cli.d.ts +20 -0
- package/dist/analyze/cli.js +186 -0
- package/dist/analyze/cpuResourceDetectors.d.ts +35 -0
- package/dist/analyze/cpuResourceDetectors.js +163 -0
- package/dist/analyze/heuristicScan.d.ts +61 -0
- package/dist/analyze/heuristicScan.js +91 -0
- package/dist/analyze/index.d.ts +15 -0
- package/dist/analyze/index.js +15 -0
- package/dist/analyze/loadTypescript.d.ts +8 -0
- package/dist/analyze/loadTypescript.js +23 -0
- package/dist/analyze/memoryIoDetectors.d.ts +15 -0
- package/dist/analyze/memoryIoDetectors.js +68 -0
- package/dist/analyze/preferAstDetectors.d.ts +18 -0
- package/dist/analyze/preferAstDetectors.js +91 -0
- package/dist/analyze/projectScan.d.ts +19 -0
- package/dist/analyze/projectScan.js +115 -0
- package/dist/analyze/resourceAdmission.d.ts +33 -0
- package/dist/analyze/resourceAdmission.js +91 -0
- package/dist/analyze/resourceFindingCandidate.d.ts +61 -0
- package/dist/analyze/resourceFindingCandidate.js +75 -0
- package/dist/analyze/retryAmplificationDetector.d.ts +11 -0
- package/dist/analyze/retryAmplificationDetector.js +55 -0
- package/dist/analyze/schemas/resource-finding.schema.json +352 -0
- package/dist/analyze/serviceDiscovery.d.ts +66 -0
- package/dist/analyze/serviceDiscovery.js +210 -0
- package/dist/analyze/unboundedParallelismDetector.d.ts +11 -0
- package/dist/analyze/unboundedParallelismDetector.js +57 -0
- package/dist/analyze/validateResourceFinding.d.ts +19 -0
- package/dist/analyze/validateResourceFinding.js +46 -0
- package/dist/bullmq.d.ts +33 -0
- package/dist/bullmq.js +106 -0
- package/dist/cli/helpText.d.ts +8 -0
- package/dist/cli/helpText.js +99 -0
- package/dist/cli/netgreener.d.ts +12 -0
- package/dist/cli/netgreener.js +65 -0
- package/dist/collectorIpc.d.ts +28 -0
- package/dist/collectorIpc.js +189 -0
- package/dist/collectorMetadata.d.ts +15 -0
- package/dist/collectorMetadata.js +33 -0
- package/dist/config.d.ts +41 -0
- package/dist/config.js +97 -0
- package/dist/contract/index.d.ts +1 -0
- package/dist/contract/index.js +1 -0
- package/dist/contract/observation-envelope.schema.json +331 -0
- package/dist/contract/observation-protobuf-view.schema.json +773 -0
- package/dist/contract/observation-v1.d.mts +42 -0
- package/dist/contract/observation-v1.mjs +555 -0
- package/dist/contract/observationIdentity.d.ts +11 -0
- package/dist/contract/observationIdentity.js +48 -0
- package/dist/contract/observationProjection.d.ts +3 -0
- package/dist/contract/observationProjection.js +29 -0
- package/dist/contract/validate.d.ts +20 -0
- package/dist/contract/validate.js +227 -0
- package/dist/dogfood/mp3WorkerGates.d.ts +54 -0
- package/dist/dogfood/mp3WorkerGates.js +86 -0
- package/dist/dogfood/retainDryRunArtifact.d.ts +45 -0
- package/dist/dogfood/retainDryRunArtifact.js +103 -0
- package/dist/dogfood/tenantDogfoodGates.d.ts +76 -0
- package/dist/dogfood/tenantDogfoodGates.js +206 -0
- package/dist/exporter.d.ts +56 -0
- package/dist/exporter.js +304 -0
- package/dist/express.d.ts +44 -0
- package/dist/express.js +118 -0
- package/dist/externalApiMeter.d.ts +72 -0
- package/dist/externalApiMeter.js +1167 -0
- package/dist/fastify.d.ts +53 -0
- package/dist/fastify.js +148 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +31 -0
- package/dist/n4/deploymentMatrix.d.ts +22 -0
- package/dist/n4/deploymentMatrix.js +57 -0
- package/dist/n4/missingnessInventory.d.ts +22 -0
- package/dist/n4/missingnessInventory.js +72 -0
- package/dist/nest.d.ts +42 -0
- package/dist/nest.js +87 -0
- package/dist/processResources.d.ts +28 -0
- package/dist/processResources.js +31 -0
- package/dist/processRuntime.d.ts +35 -0
- package/dist/processRuntime.js +96 -0
- package/dist/requestContext.d.ts +21 -0
- package/dist/requestContext.js +33 -0
- package/dist/runtime.d.ts +60 -0
- package/dist/runtime.js +289 -0
- package/dist/runtimeHealth.d.ts +35 -0
- package/dist/runtimeHealth.js +121 -0
- package/dist/serverlessHints.d.ts +26 -0
- package/dist/serverlessHints.js +52 -0
- package/dist/tenantContext.d.ts +78 -0
- package/dist/tenantContext.js +226 -0
- package/dist/tenantDefaults.d.ts +9 -0
- package/dist/tenantDefaults.js +9 -0
- package/dist/types.d.ts +131 -0
- package/dist/types.js +2 -0
- package/dist/uploader.d.ts +23 -0
- package/dist/uploader.js +52 -0
- package/dist/windowId.d.ts +2 -0
- package/dist/windowId.js +7 -0
- package/examples/analyze-manifest.mjs +30 -0
- package/examples/bullmq-live-smoke.mjs +178 -0
- package/examples/bullmq-mp3-worker-gate.mjs +237 -0
- package/examples/express-dry-run.mjs +72 -0
- package/examples/process-mp3-restart-gate.mjs +135 -0
- package/examples/retain-dry-run.mjs +110 -0
- package/examples/tenant-dogfood.mjs +269 -0
- package/fixtures/analyze-sample/architectureNoise.ts +13 -0
- package/fixtures/analyze-sample/cpuHotPaths.ts +27 -0
- package/fixtures/analyze-sample/fanOutClient.ts +15 -0
- package/fixtures/analyze-sample/inferenceHotPaths.ts +22 -0
- package/fixtures/analyze-sample/memoryIoHotPaths.ts +21 -0
- package/fixtures/analyze-sample/modelLoadHotPaths.ts +11 -0
- package/fixtures/analyze-sample/nestedLookup.ts +15 -0
- package/fixtures/analyze-sample/retryClient.ts +10 -0
- package/fixtures/analyze-sample/securitySmell.ts +8 -0
- package/fixtures/analyze-sample/server.ts +11 -0
- package/fixtures/analyze-sample/styleOnly.ts +7 -0
- package/fixtures/analyze-sample/worker.ts +4 -0
- package/fixtures/dual-view-projection.v1.json +53 -0
- package/fixtures/identity-preimages.v1.json +42 -0
- package/fixtures/mp2_shadow_digest_golden.v1.json +47 -0
- package/fixtures/projection-batch-document.v1.json +170 -0
- package/fixtures/projection-batch.v1.json +9 -0
- package/fixtures/python_reference_shapes.md +24 -0
- package/fixtures/session_metadata_runtime_v0.json +120 -0
- package/fixtures/session_metadata_with_tenant.json +85 -0
- package/package.json +137 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatible ``service_runtime_v0.collector`` metadata values for
|
|
3
|
+
* ``@netgreener/runtime`` observation origins in legacy RunSession projections.
|
|
4
|
+
*
|
|
5
|
+
* These identify *where the observation came from* inside the Node emitter —
|
|
6
|
+
* not separate general-purpose collectors, and not APM/vendor products.
|
|
7
|
+
*
|
|
8
|
+
* N6 packaging doc twin: ``PACKAGING.md``.
|
|
9
|
+
*/
|
|
10
|
+
/** Known collector metadata strings emitted by this package. */
|
|
11
|
+
export declare const COMPATIBLE_COLLECTOR_METADATA: readonly ["express_middleware", "fastify_middleware", "nest_express_middleware", "nest_fastify_middleware", "node_process", "bullmq_worker", "outbound_http"];
|
|
12
|
+
export type CompatibleCollectorMetadata = (typeof COMPATIBLE_COLLECTOR_METADATA)[number];
|
|
13
|
+
export declare function isCompatibleCollectorMetadata(value: string): boolean;
|
|
14
|
+
/** Short descriptions for packaging / dogfood docs (not user-facing UI copy). */
|
|
15
|
+
export declare const COLLECTOR_METADATA_NOTES: Record<CompatibleCollectorMetadata, string>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatible ``service_runtime_v0.collector`` metadata values for
|
|
3
|
+
* ``@netgreener/runtime`` observation origins in legacy RunSession projections.
|
|
4
|
+
*
|
|
5
|
+
* These identify *where the observation came from* inside the Node emitter —
|
|
6
|
+
* not separate general-purpose collectors, and not APM/vendor products.
|
|
7
|
+
*
|
|
8
|
+
* N6 packaging doc twin: ``PACKAGING.md``.
|
|
9
|
+
*/
|
|
10
|
+
/** Known collector metadata strings emitted by this package. */
|
|
11
|
+
export const COMPATIBLE_COLLECTOR_METADATA = [
|
|
12
|
+
'express_middleware',
|
|
13
|
+
'fastify_middleware',
|
|
14
|
+
'nest_express_middleware',
|
|
15
|
+
'nest_fastify_middleware',
|
|
16
|
+
'node_process',
|
|
17
|
+
'bullmq_worker',
|
|
18
|
+
'outbound_http',
|
|
19
|
+
];
|
|
20
|
+
const COLLECTOR_SET = new Set(COMPATIBLE_COLLECTOR_METADATA);
|
|
21
|
+
export function isCompatibleCollectorMetadata(value) {
|
|
22
|
+
return COLLECTOR_SET.has(String(value || '').trim());
|
|
23
|
+
}
|
|
24
|
+
/** Short descriptions for packaging / dogfood docs (not user-facing UI copy). */
|
|
25
|
+
export const COLLECTOR_METADATA_NOTES = {
|
|
26
|
+
express_middleware: 'Express middleware request/response metering origin',
|
|
27
|
+
fastify_middleware: 'Fastify plugin request/response metering origin',
|
|
28
|
+
nest_express_middleware: 'Nest on Express adapter middleware origin',
|
|
29
|
+
nest_fastify_middleware: 'Nest on Fastify adapter middleware origin',
|
|
30
|
+
node_process: 'Process/cron helper origin (no HTTP framework)',
|
|
31
|
+
bullmq_worker: 'BullMQ worker job flush origin',
|
|
32
|
+
outbound_http: 'Outbound fetch/axios/undici external API meter origin',
|
|
33
|
+
};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type RuntimeConfig = {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
apiUrl: string;
|
|
4
|
+
token: string;
|
|
5
|
+
projectId: number;
|
|
6
|
+
organizationId: number | null;
|
|
7
|
+
flushIntervalMs: number;
|
|
8
|
+
dryRun: boolean;
|
|
9
|
+
deployEnvironment: string | null;
|
|
10
|
+
releaseTag: string | null;
|
|
11
|
+
/** Watts used for crude window energy estimate (trend accuracy). */
|
|
12
|
+
estimateTdpWatts: number;
|
|
13
|
+
tenantSource: string;
|
|
14
|
+
tenantClaim: string;
|
|
15
|
+
tenantHeader: string;
|
|
16
|
+
tenantPathRegex: string | null;
|
|
17
|
+
tenantTaskKwarg: string;
|
|
18
|
+
tenantLabelClaim: string | null;
|
|
19
|
+
};
|
|
20
|
+
/** Established v0 flush / TDP bounds (committed Node runtime foundation). */
|
|
21
|
+
export declare const DEFAULT_RUNTIME_FLUSH_MINUTES = 5;
|
|
22
|
+
export declare const MIN_RUNTIME_FLUSH_MINUTES = 1;
|
|
23
|
+
export declare const MAX_RUNTIME_FLUSH_MINUTES: number;
|
|
24
|
+
export declare const DEFAULT_ESTIMATE_TDP_WATTS = 65;
|
|
25
|
+
export declare const MIN_ESTIMATE_TDP_WATTS = 1;
|
|
26
|
+
/** Committed ceiling is 10_000 W — not the working-tree test literal 2000. */
|
|
27
|
+
export declare const MAX_ESTIMATE_TDP_WATTS = 10000;
|
|
28
|
+
/**
|
|
29
|
+
* Load runtime config from the supplied env object (defaults to process.env).
|
|
30
|
+
*
|
|
31
|
+
* Every field is read from that object so callers can pass an isolated map
|
|
32
|
+
* without ambient process.env leaking into tests or programmatic loads.
|
|
33
|
+
*
|
|
34
|
+
* Required when enabled: NETGREENER_TOKEN, NETGREENER_PROJECT_ID
|
|
35
|
+
* API URL: NETGREENER_API_URL (default https://core-api.netgreener.com)
|
|
36
|
+
*/
|
|
37
|
+
export declare function loadRuntimeConfig(env?: NodeJS.ProcessEnv): RuntimeConfig;
|
|
38
|
+
export declare function configReady(config: RuntimeConfig): {
|
|
39
|
+
ok: boolean;
|
|
40
|
+
reason?: string;
|
|
41
|
+
};
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** Established v0 flush / TDP bounds (committed Node runtime foundation). */
|
|
2
|
+
export const DEFAULT_RUNTIME_FLUSH_MINUTES = 5;
|
|
3
|
+
export const MIN_RUNTIME_FLUSH_MINUTES = 1;
|
|
4
|
+
export const MAX_RUNTIME_FLUSH_MINUTES = 24 * 60;
|
|
5
|
+
export const DEFAULT_ESTIMATE_TDP_WATTS = 65;
|
|
6
|
+
export const MIN_ESTIMATE_TDP_WATTS = 1;
|
|
7
|
+
/** Committed ceiling is 10_000 W — not the working-tree test literal 2000. */
|
|
8
|
+
export const MAX_ESTIMATE_TDP_WATTS = 10_000;
|
|
9
|
+
const MIN_RUNTIME_FLUSH_INTERVAL_MS = MIN_RUNTIME_FLUSH_MINUTES * 60 * 1000;
|
|
10
|
+
const MAX_RUNTIME_FLUSH_INTERVAL_MS = MAX_RUNTIME_FLUSH_MINUTES * 60 * 1000;
|
|
11
|
+
function envTruthy(env, name) {
|
|
12
|
+
const v = (env[name] || '').trim().toLowerCase();
|
|
13
|
+
return v === '1' || v === 'true' || v === 'yes' || v === 'on';
|
|
14
|
+
}
|
|
15
|
+
function envNumberInRange(env, name, fallback, min, max) {
|
|
16
|
+
const raw = (env[name] || '').trim();
|
|
17
|
+
if (!raw)
|
|
18
|
+
return fallback;
|
|
19
|
+
const n = Number(raw);
|
|
20
|
+
return Number.isFinite(n) && n >= min && n <= max ? n : fallback;
|
|
21
|
+
}
|
|
22
|
+
function envPositiveSafeInteger(env, name, fallback) {
|
|
23
|
+
const raw = (env[name] || '').trim();
|
|
24
|
+
if (!raw)
|
|
25
|
+
return fallback;
|
|
26
|
+
const n = Number(raw);
|
|
27
|
+
return Number.isSafeInteger(n) && n > 0 ? n : fallback;
|
|
28
|
+
}
|
|
29
|
+
function isPositiveSafeInteger(value) {
|
|
30
|
+
return Number.isSafeInteger(value) && value > 0;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Load runtime config from the supplied env object (defaults to process.env).
|
|
34
|
+
*
|
|
35
|
+
* Every field is read from that object so callers can pass an isolated map
|
|
36
|
+
* without ambient process.env leaking into tests or programmatic loads.
|
|
37
|
+
*
|
|
38
|
+
* Required when enabled: NETGREENER_TOKEN, NETGREENER_PROJECT_ID
|
|
39
|
+
* API URL: NETGREENER_API_URL (default https://core-api.netgreener.com)
|
|
40
|
+
*/
|
|
41
|
+
export function loadRuntimeConfig(env = process.env) {
|
|
42
|
+
const enabled = envTruthy(env, 'NETGREENER_SERVICE_RUNTIME');
|
|
43
|
+
const apiUrl = (env.NETGREENER_API_URL || 'https://core-api.netgreener.com').replace(/\/+$/, '');
|
|
44
|
+
const token = (env.NETGREENER_TOKEN || '').trim();
|
|
45
|
+
const projectId = envPositiveSafeInteger(env, 'NETGREENER_PROJECT_ID', 0);
|
|
46
|
+
const organizationIdRaw = envPositiveSafeInteger(env, 'NETGREENER_ORG_ID', 0);
|
|
47
|
+
const flushMinutes = envNumberInRange(env, 'NETGREENER_RUNTIME_FLUSH_MINUTES', DEFAULT_RUNTIME_FLUSH_MINUTES, MIN_RUNTIME_FLUSH_MINUTES, MAX_RUNTIME_FLUSH_MINUTES);
|
|
48
|
+
return {
|
|
49
|
+
enabled,
|
|
50
|
+
apiUrl,
|
|
51
|
+
token,
|
|
52
|
+
projectId,
|
|
53
|
+
organizationId: organizationIdRaw > 0 ? organizationIdRaw : null,
|
|
54
|
+
flushIntervalMs: flushMinutes * 60 * 1000,
|
|
55
|
+
dryRun: envTruthy(env, 'NETGREENER_RUNTIME_DRY_RUN'),
|
|
56
|
+
deployEnvironment: (env.NETGREENER_DEPLOY_ENVIRONMENT || env.DEPLOY_ENV || '').trim() || null,
|
|
57
|
+
releaseTag: (env.NETGREENER_RELEASE_TAG || env.GIT_SHA || '').trim() || null,
|
|
58
|
+
estimateTdpWatts: envNumberInRange(env, 'NETGREENER_ESTIMATE_TDP_WATTS', DEFAULT_ESTIMATE_TDP_WATTS, MIN_ESTIMATE_TDP_WATTS, MAX_ESTIMATE_TDP_WATTS),
|
|
59
|
+
tenantSource: (env.NETGREENER_TENANT_SOURCE || 'none').trim().toLowerCase(),
|
|
60
|
+
tenantClaim: (env.NETGREENER_TENANT_CLAIM || 'organization_id').trim(),
|
|
61
|
+
tenantHeader: (env.NETGREENER_TENANT_HEADER || 'X-Organization-Id').trim(),
|
|
62
|
+
tenantPathRegex: (env.NETGREENER_TENANT_PATH_REGEX || '').trim() || null,
|
|
63
|
+
tenantTaskKwarg: (env.NETGREENER_TENANT_TASK_KWARG || 'organization_id').trim(),
|
|
64
|
+
tenantLabelClaim: (env.NETGREENER_TENANT_LABEL_CLAIM || '').trim() || null,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export function configReady(config) {
|
|
68
|
+
if (!config.enabled)
|
|
69
|
+
return { ok: false, reason: 'NETGREENER_SERVICE_RUNTIME not enabled' };
|
|
70
|
+
if (!config.token)
|
|
71
|
+
return { ok: false, reason: 'NETGREENER_TOKEN missing' };
|
|
72
|
+
if (!isPositiveSafeInteger(config.projectId)) {
|
|
73
|
+
return { ok: false, reason: 'NETGREENER_PROJECT_ID must be a positive safe integer' };
|
|
74
|
+
}
|
|
75
|
+
if (config.organizationId !== null && !isPositiveSafeInteger(config.organizationId)) {
|
|
76
|
+
return { ok: false, reason: 'NETGREENER_ORG_ID must be a positive safe integer' };
|
|
77
|
+
}
|
|
78
|
+
if (!Number.isFinite(config.flushIntervalMs) ||
|
|
79
|
+
config.flushIntervalMs < MIN_RUNTIME_FLUSH_INTERVAL_MS ||
|
|
80
|
+
config.flushIntervalMs > MAX_RUNTIME_FLUSH_INTERVAL_MS) {
|
|
81
|
+
return {
|
|
82
|
+
ok: false,
|
|
83
|
+
reason: `flushIntervalMs must be between ${MIN_RUNTIME_FLUSH_INTERVAL_MS} and ${MAX_RUNTIME_FLUSH_INTERVAL_MS}`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (!Number.isFinite(config.estimateTdpWatts) ||
|
|
87
|
+
config.estimateTdpWatts < MIN_ESTIMATE_TDP_WATTS ||
|
|
88
|
+
config.estimateTdpWatts > MAX_ESTIMATE_TDP_WATTS) {
|
|
89
|
+
return {
|
|
90
|
+
ok: false,
|
|
91
|
+
reason: `estimateTdpWatts must be between ${MIN_ESTIMATE_TDP_WATTS} and ${MAX_ESTIMATE_TDP_WATTS}`,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (!config.apiUrl)
|
|
95
|
+
return { ok: false, reason: 'NETGREENER_API_URL missing' };
|
|
96
|
+
return { ok: true };
|
|
97
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { validateExternalApiV0, validateMeasurementProvenance, validateRuntimeSessionMetadata, validateServiceRuntimeV0, type ContractIssue, type ContractResult, } from './validate.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { validateExternalApiV0, validateMeasurementProvenance, validateRuntimeSessionMetadata, validateServiceRuntimeV0, } from './validate.js';
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.netgreener.com/contracts/v1/observation-envelope.schema.json",
|
|
4
|
+
"$comment": "Semantic authoring/TCK conformance view. Canonical field/type/number source is observation/v1/source/observation.proto (ADR 0009). Structural Protobuf JSON view: observation-protobuf-view.schema.json. Dual-view migration; consumer pins not auto-updated.",
|
|
5
|
+
"title": "NetGreener Observation v1 semantic envelope (MP0 draft)",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"schema_name",
|
|
10
|
+
"schema_version",
|
|
11
|
+
"contract_status",
|
|
12
|
+
"batch_id",
|
|
13
|
+
"batch_sequence",
|
|
14
|
+
"emitted_at",
|
|
15
|
+
"source",
|
|
16
|
+
"routing",
|
|
17
|
+
"privacy",
|
|
18
|
+
"events"
|
|
19
|
+
],
|
|
20
|
+
"properties": {
|
|
21
|
+
"$schema": { "type": "string" },
|
|
22
|
+
"schema_name": { "const": "netgreener.observation.v1" },
|
|
23
|
+
"schema_version": { "const": 1 },
|
|
24
|
+
"contract_status": { "const": "mp0_draft" },
|
|
25
|
+
"batch_id": { "$ref": "#/$defs/batchId" },
|
|
26
|
+
"batch_sequence": { "$ref": "#/$defs/uint64String" },
|
|
27
|
+
"emitted_at": { "type": "string", "format": "date-time" },
|
|
28
|
+
"source": { "$ref": "#/$defs/source" },
|
|
29
|
+
"routing": { "$ref": "#/$defs/routing" },
|
|
30
|
+
"privacy": { "$ref": "#/$defs/privacy" },
|
|
31
|
+
"window": { "$ref": "#/$defs/window" },
|
|
32
|
+
"events": {
|
|
33
|
+
"type": "array",
|
|
34
|
+
"minItems": 1,
|
|
35
|
+
"maxItems": 1000,
|
|
36
|
+
"items": {
|
|
37
|
+
"oneOf": [
|
|
38
|
+
{ "$ref": "#/$defs/operationEvent" },
|
|
39
|
+
{ "$ref": "#/$defs/operationSummary" },
|
|
40
|
+
{ "$ref": "#/$defs/externalCall" },
|
|
41
|
+
{ "$ref": "#/$defs/resourceSample" },
|
|
42
|
+
{ "$ref": "#/$defs/adapterHealth" }
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"$defs": {
|
|
48
|
+
"uint64String": { "type": "string", "pattern": "^(0|[1-9][0-9]{0,19})$" },
|
|
49
|
+
"positiveUint64String": { "type": "string", "pattern": "^[1-9][0-9]{0,19}$" },
|
|
50
|
+
"eventId": { "type": "string", "pattern": "^evt_[0-9a-f]{64}$" },
|
|
51
|
+
"batchId": { "type": "string", "pattern": "^bat_[0-9a-f]{64}$" },
|
|
52
|
+
"runtimeInstanceId": { "type": "string", "pattern": "^rti_[0-9a-f]{64}$" },
|
|
53
|
+
"runtimeWindowId": { "type": "string", "pattern": "^rtw_[0-9a-f]{64}$" },
|
|
54
|
+
"boundedIdentifier": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:@/-]{0,199}$" },
|
|
55
|
+
"source": {
|
|
56
|
+
"type": "object",
|
|
57
|
+
"additionalProperties": false,
|
|
58
|
+
"required": [
|
|
59
|
+
"language",
|
|
60
|
+
"runtime_name",
|
|
61
|
+
"runtime_version",
|
|
62
|
+
"adapter_name",
|
|
63
|
+
"adapter_version",
|
|
64
|
+
"runtime_instance_id",
|
|
65
|
+
"capability_ids",
|
|
66
|
+
"deployment_mode"
|
|
67
|
+
],
|
|
68
|
+
"properties": {
|
|
69
|
+
"language": { "type": "string", "pattern": "^[a-z][a-z0-9+-]{0,31}$" },
|
|
70
|
+
"runtime_name": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$" },
|
|
71
|
+
"runtime_version": { "type": "string", "minLength": 1, "maxLength": 80 },
|
|
72
|
+
"adapter_name": { "type": "string", "minLength": 1, "maxLength": 120 },
|
|
73
|
+
"adapter_version": { "type": "string", "minLength": 1, "maxLength": 80 },
|
|
74
|
+
"runtime_instance_id": { "$ref": "#/$defs/runtimeInstanceId" },
|
|
75
|
+
"capability_ids": {
|
|
76
|
+
"type": "array",
|
|
77
|
+
"minItems": 1,
|
|
78
|
+
"uniqueItems": true,
|
|
79
|
+
"items": { "type": "string", "pattern": "^CAP-R[1-6]$" }
|
|
80
|
+
},
|
|
81
|
+
"framework": { "type": ["string", "null"], "maxLength": 80 },
|
|
82
|
+
"deployment_mode": { "enum": ["vm", "container", "kubernetes", "ci_job", "serverless_thin", "local", "unknown"] }
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"routing": {
|
|
86
|
+
"type": "object",
|
|
87
|
+
"additionalProperties": false,
|
|
88
|
+
"required": ["project_id", "workload_id", "service_name"],
|
|
89
|
+
"properties": {
|
|
90
|
+
"organization_id": { "type": "integer", "minimum": 1 },
|
|
91
|
+
"project_id": { "type": "integer", "minimum": 1 },
|
|
92
|
+
"workload_id": { "$ref": "#/$defs/boundedIdentifier" },
|
|
93
|
+
"service_name": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$" },
|
|
94
|
+
"environment": { "type": ["string", "null"], "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,49}$" },
|
|
95
|
+
"release_tag": { "type": ["string", "null"], "maxLength": 120 }
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"privacy": {
|
|
99
|
+
"type": "object",
|
|
100
|
+
"additionalProperties": false,
|
|
101
|
+
"required": ["content_capture", "dimension_policy", "route_policy", "dropped_dimension_count"],
|
|
102
|
+
"properties": {
|
|
103
|
+
"content_capture": { "const": "none" },
|
|
104
|
+
"dimension_policy": { "const": "allowlist" },
|
|
105
|
+
"route_policy": { "const": "template_or_unknown" },
|
|
106
|
+
"dropped_dimension_count": { "type": "integer", "minimum": 0 }
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"window": {
|
|
110
|
+
"type": "object",
|
|
111
|
+
"additionalProperties": false,
|
|
112
|
+
"required": ["state", "start_time", "end_time"],
|
|
113
|
+
"properties": {
|
|
114
|
+
"runtime_window_id": { "$ref": "#/$defs/runtimeWindowId" },
|
|
115
|
+
"state": { "enum": ["open", "closed", "thin"] },
|
|
116
|
+
"start_time": { "type": "string", "format": "date-time" },
|
|
117
|
+
"end_time": { "type": ["string", "null"], "format": "date-time" }
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"eventCommon": {
|
|
121
|
+
"type": "object",
|
|
122
|
+
"required": ["event_id", "sequence", "wall_time_unix_nano", "monotonic_time_ns", "clock_source"],
|
|
123
|
+
"properties": {
|
|
124
|
+
"event_id": { "$ref": "#/$defs/eventId" },
|
|
125
|
+
"sequence": { "$ref": "#/$defs/positiveUint64String" },
|
|
126
|
+
"wall_time_unix_nano": { "$ref": "#/$defs/positiveUint64String" },
|
|
127
|
+
"monotonic_time_ns": { "$ref": "#/$defs/uint64String" },
|
|
128
|
+
"clock_source": { "enum": ["runtime_monotonic", "process_monotonic", "unavailable"] },
|
|
129
|
+
"execution_id": { "$ref": "#/$defs/boundedIdentifier" },
|
|
130
|
+
"runtime_window_id": { "$ref": "#/$defs/runtimeWindowId" },
|
|
131
|
+
"traceparent": {
|
|
132
|
+
"type": "string",
|
|
133
|
+
"pattern": "^[0-9a-f]{2}-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"operation": {
|
|
138
|
+
"type": "object",
|
|
139
|
+
"additionalProperties": false,
|
|
140
|
+
"required": ["kind", "unit_type", "name", "identity_source"],
|
|
141
|
+
"properties": {
|
|
142
|
+
"kind": { "enum": ["http.server", "task", "process", "script", "cron", "background", "unattributed"] },
|
|
143
|
+
"unit_type": { "enum": ["http_route", "task", "process", "script", "cron", "background", "unattributed"] },
|
|
144
|
+
"name": { "type": "string", "minLength": 1, "maxLength": 200, "pattern": "^[^?#\\r\\n]+$" },
|
|
145
|
+
"identity_source": { "enum": ["framework_template", "declared", "generated", "unknown_bucket"] },
|
|
146
|
+
"http_method": { "type": "string", "pattern": "^[A-Z]{3,12}$" },
|
|
147
|
+
"route_template": {
|
|
148
|
+
"oneOf": [
|
|
149
|
+
{ "const": "__unknown__" },
|
|
150
|
+
{ "type": "string", "pattern": "^/[^?#\\r\\n]{0,198}$" }
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"allOf": [
|
|
155
|
+
{
|
|
156
|
+
"if": { "properties": { "kind": { "const": "http.server" } }, "required": ["kind"] },
|
|
157
|
+
"then": { "required": ["http_method", "route_template"] }
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
"operationEvent": {
|
|
162
|
+
"allOf": [
|
|
163
|
+
{ "$ref": "#/$defs/eventCommon" },
|
|
164
|
+
{
|
|
165
|
+
"type": "object",
|
|
166
|
+
"required": ["record_type", "operation", "facts"],
|
|
167
|
+
"properties": {
|
|
168
|
+
"record_type": { "const": "operation_event" },
|
|
169
|
+
"operation": { "$ref": "#/$defs/operation" },
|
|
170
|
+
"facts": {
|
|
171
|
+
"type": "object",
|
|
172
|
+
"additionalProperties": false,
|
|
173
|
+
"required": ["phase", "outcome"],
|
|
174
|
+
"properties": {
|
|
175
|
+
"phase": { "enum": ["start", "finish", "heartbeat"] },
|
|
176
|
+
"outcome": { "enum": ["ok", "error", "cancelled", "unknown"] },
|
|
177
|
+
"duration_ns": { "$ref": "#/$defs/uint64String" },
|
|
178
|
+
"status_code": { "type": ["integer", "null"], "minimum": 0, "maximum": 999 }
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
"unevaluatedProperties": false
|
|
185
|
+
},
|
|
186
|
+
"operationSummary": {
|
|
187
|
+
"allOf": [
|
|
188
|
+
{ "$ref": "#/$defs/eventCommon" },
|
|
189
|
+
{
|
|
190
|
+
"type": "object",
|
|
191
|
+
"required": ["record_type", "operation", "facts"],
|
|
192
|
+
"properties": {
|
|
193
|
+
"record_type": { "const": "operation_summary" },
|
|
194
|
+
"operation": { "$ref": "#/$defs/operation" },
|
|
195
|
+
"facts": {
|
|
196
|
+
"type": "object",
|
|
197
|
+
"additionalProperties": false,
|
|
198
|
+
"required": ["calls", "errors", "duration_ns_sum", "duration_ns_max"],
|
|
199
|
+
"properties": {
|
|
200
|
+
"calls": { "type": "integer", "minimum": 1, "maximum": 1000000000 },
|
|
201
|
+
"errors": { "type": "integer", "minimum": 0, "maximum": 1000000000 },
|
|
202
|
+
"duration_ns_sum": { "$ref": "#/$defs/uint64String" },
|
|
203
|
+
"duration_ns_max": { "$ref": "#/$defs/uint64String" },
|
|
204
|
+
"concurrency_max": { "type": "integer", "minimum": 1, "maximum": 1000000 }
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"unevaluatedProperties": false
|
|
211
|
+
},
|
|
212
|
+
"usage": {
|
|
213
|
+
"type": "object",
|
|
214
|
+
"additionalProperties": false,
|
|
215
|
+
"required": ["unit", "value", "source"],
|
|
216
|
+
"properties": {
|
|
217
|
+
"unit": {
|
|
218
|
+
"oneOf": [
|
|
219
|
+
{ "enum": ["input_tokens", "output_tokens", "total_tokens", "cached_input_tokens", "reasoning_tokens", "request_bytes", "response_bytes", "provider_units"] },
|
|
220
|
+
{ "type": "string", "pattern": "^x-[a-z0-9][a-z0-9_.-]{0,62}$" }
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
"value": { "$ref": "#/$defs/uint64String" },
|
|
224
|
+
"source": { "enum": ["provider_response", "documented_header", "sdk_callback", "declared"] }
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
"externalCall": {
|
|
228
|
+
"allOf": [
|
|
229
|
+
{ "$ref": "#/$defs/eventCommon" },
|
|
230
|
+
{
|
|
231
|
+
"type": "object",
|
|
232
|
+
"required": ["record_type", "facts"],
|
|
233
|
+
"properties": {
|
|
234
|
+
"record_type": { "const": "external_call" },
|
|
235
|
+
"parent_operation_event_id": { "$ref": "#/$defs/eventId" },
|
|
236
|
+
"facts": {
|
|
237
|
+
"type": "object",
|
|
238
|
+
"additionalProperties": false,
|
|
239
|
+
"required": ["service", "operation", "attempts", "errors", "duration_ns"],
|
|
240
|
+
"properties": {
|
|
241
|
+
"provider": { "type": ["string", "null"], "pattern": "^[a-z0-9][a-z0-9_.-]{0,63}$" },
|
|
242
|
+
"service": { "type": "string", "pattern": "^[a-z0-9][a-z0-9_.-]{0,63}$" },
|
|
243
|
+
"operation": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,99}$" },
|
|
244
|
+
"model": { "type": ["string", "null"], "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,127}$" },
|
|
245
|
+
"destination_domain": { "type": ["string", "null"], "pattern": "^[a-z0-9][a-z0-9.-]{0,252}[a-z0-9]$" },
|
|
246
|
+
"attempts": { "type": "integer", "minimum": 1, "maximum": 1000000 },
|
|
247
|
+
"errors": { "type": "integer", "minimum": 0, "maximum": 1000000 },
|
|
248
|
+
"duration_ns": { "$ref": "#/$defs/uint64String" },
|
|
249
|
+
"usage": { "type": "array", "maxItems": 32, "items": { "$ref": "#/$defs/usage" } }
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
],
|
|
255
|
+
"unevaluatedProperties": false
|
|
256
|
+
},
|
|
257
|
+
"measurement": {
|
|
258
|
+
"type": "object",
|
|
259
|
+
"additionalProperties": false,
|
|
260
|
+
"required": ["name", "value", "unit", "temporality", "source", "coverage"],
|
|
261
|
+
"properties": {
|
|
262
|
+
"name": { "enum": ["process.cpu.time", "process.memory.rss", "system.energy", "gpu.energy", "gpu.utilization"] },
|
|
263
|
+
"value": { "type": "string", "pattern": "^(0|[1-9][0-9]{0,30})(\\.[0-9]{1,12})?$" },
|
|
264
|
+
"unit": { "enum": ["ns", "By", "J", "1"] },
|
|
265
|
+
"temporality": { "enum": ["cumulative", "delta", "gauge"] },
|
|
266
|
+
"source": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:/-]{0,119}$" },
|
|
267
|
+
"coverage": { "type": "number", "minimum": 0, "maximum": 1 }
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"resourceSample": {
|
|
271
|
+
"allOf": [
|
|
272
|
+
{ "$ref": "#/$defs/eventCommon" },
|
|
273
|
+
{
|
|
274
|
+
"type": "object",
|
|
275
|
+
"required": ["record_type", "facts"],
|
|
276
|
+
"properties": {
|
|
277
|
+
"record_type": { "const": "resource_sample" },
|
|
278
|
+
"parent_operation_event_id": { "$ref": "#/$defs/eventId" },
|
|
279
|
+
"facts": {
|
|
280
|
+
"type": "object",
|
|
281
|
+
"additionalProperties": false,
|
|
282
|
+
"required": ["scope", "sample_kind", "subject_id", "measurements"],
|
|
283
|
+
"properties": {
|
|
284
|
+
"scope": { "enum": ["process", "process_tree", "container", "cgroup", "host", "device"] },
|
|
285
|
+
"sample_kind": { "enum": ["start", "periodic", "end", "snapshot"] },
|
|
286
|
+
"subject_id": { "$ref": "#/$defs/boundedIdentifier" },
|
|
287
|
+
"measurements": { "type": "array", "minItems": 1, "maxItems": 32, "items": { "$ref": "#/$defs/measurement" } }
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
],
|
|
293
|
+
"unevaluatedProperties": false
|
|
294
|
+
},
|
|
295
|
+
"adapterHealth": {
|
|
296
|
+
"allOf": [
|
|
297
|
+
{ "$ref": "#/$defs/eventCommon" },
|
|
298
|
+
{
|
|
299
|
+
"type": "object",
|
|
300
|
+
"required": ["record_type", "facts"],
|
|
301
|
+
"properties": {
|
|
302
|
+
"record_type": { "const": "adapter_health" },
|
|
303
|
+
"facts": {
|
|
304
|
+
"type": "object",
|
|
305
|
+
"additionalProperties": false,
|
|
306
|
+
"required": ["component", "status", "reason_codes", "counters"],
|
|
307
|
+
"properties": {
|
|
308
|
+
"component": { "enum": ["adapter", "exporter", "sampler", "collector"] },
|
|
309
|
+
"status": { "enum": ["ok", "degraded", "error", "disabled"] },
|
|
310
|
+
"reason_codes": { "type": "array", "maxItems": 32, "uniqueItems": true, "items": { "type": "string", "pattern": "^[A-Z][A-Z0-9_]{0,63}$" } },
|
|
311
|
+
"counters": {
|
|
312
|
+
"type": "object",
|
|
313
|
+
"additionalProperties": false,
|
|
314
|
+
"properties": {
|
|
315
|
+
"dropped_events": { "type": "integer", "minimum": 0 },
|
|
316
|
+
"retries": { "type": "integer", "minimum": 0 },
|
|
317
|
+
"rejected_events": { "type": "integer", "minimum": 0 },
|
|
318
|
+
"queue_depth": { "type": "integer", "minimum": 0 },
|
|
319
|
+
"queue_oldest_age_ms": { "type": "integer", "minimum": 0 }
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
],
|
|
327
|
+
"unevaluatedProperties": false
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|