@copilotkit/runtime
Version:
<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />
33 lines (31 loc) • 1.28 kB
JavaScript
import "reflect-metadata";
import telemetry from "./telemetry-client.mjs";
//#region src/v2/runtime/telemetry/instance-created.ts
/**
* Fire the `oss.runtime.instance_created` telemetry event for a v2 runtime
* handler. Called once per handler factory invocation (not per request).
*
* v2 does not have a concept of remote endpoints or standalone actions, so
* those counts are 0 / []. `cloud.api_key_provided` is false at this level
* because in v2 the cloud public key arrives per-request via the
* `x-copilotcloud-public-api-key` header — not at handler creation time.
* See `handlers/handle-run.ts` for the per-request event that DOES carry
* the key when present.
*
* Errors resolving agents are swallowed — telemetry must never break
* runtime setup.
*/
function fireInstanceCreatedTelemetry({ runtime }) {
(typeof runtime.agents === "function" ? Promise.resolve(null) : Promise.resolve(runtime.agents)).then((agents) => {
telemetry.capture("oss.runtime.instance_created", {
actionsAmount: 0,
endpointTypes: [],
endpointsAmount: 0,
agentsAmount: agents ? Object.keys(agents).length : null,
"cloud.api_key_provided": false
});
}).catch(() => {});
}
//#endregion
export { fireInstanceCreatedTelemetry };
//# sourceMappingURL=instance-created.mjs.map