@@ -12,6 +12,12 @@ const { makeId } = require('../util/hashes')
1212 * The base LLM event class that contains logic and properties
1313 * (e.g. `trace_id`, `vendor`) that are common to all LLM events.
1414 *
15+ * Properties are defined as public fields rather than private because
16+ * these LLM event objects are serialized and then sent via the custom
17+ * event aggregator.
18+ * The property names (using snake_case like `trace_id`) must be preserved
19+ * exactly as-is in the serialized output to match the expected schema.
20+ *
1521 * @property {boolean|undefined } error Set to `true` if an error occurred
1622 * during creation call, omitted if no error occurred
1723 * @property {string } id UUID or identifier for the event
@@ -43,13 +49,15 @@ module.exports = class EventBase {
4349 this . vendor = vendor
4450 this . metadata = agent
4551
46- // Omit `error` property if no error occurred
52+ // The spec says that the `error` property should only be
53+ // sent (via the collector) if it is set to true.
4754 if ( error === true ) {
4855 this . error = error
4956 }
5057
51- // If a certain attribute value is not accessible via instrumentation,
52- // it can be omitted from the event.
58+ // Like `error`, the spec says that if any other certain attribute value
59+ // is not accessible via instrumentation (thus `undefined`), it will be
60+ // omitted from the event.
5361 if ( requestId ) this . request_id = requestId
5462 if ( responseModel ) this [ 'response.model' ] = responseModel
5563 }
0 commit comments