feat: Add per-instance OTEL resource attributes for metrics and logs#77
feat: Add per-instance OTEL resource attributes for metrics and logs#77
Conversation
Code ReviewGood PR overall — the Mimir/Loki cardinality split is the right approach and the implementation is clean. A few things worth addressing: Bug: Stale JSDoc comment left in place In The first comment is now stale and should be deleted. Minor: The class-level Minor: The module-level Nit: Non-standard OTEL attribute names
Test coverage No new unit tests for Overall solid work. The stale JSDoc is the only thing I would fix before merge; the rest are suggestions. |
Additional Code Review Notes(Adding to the existing review — the stale JSDoc, double Minor: In attrs['service.instance.id'] = 'opus-transcriber-proxy';This hardcodes the same string already assigned via const SERVICE_NAME = 'opus-transcriber-proxy';
// ...
attrs[ATTR_SERVICE_NAME] = SERVICE_NAME;
// ...
attrs['service.instance.id'] = SERVICE_NAME; // static — keeps Loki stream count boundedPre-existing (not introduced here, but worth noting): In OPENAI_API_KEY: env.OPENAI_API_KEY, // could be undefined → becomes the string "undefined"
GEMINI_API_KEY: env.GEMINI_API_KEY || '', // correctAll other keys guard against Overall: Clean, well-motivated change. The Mimir/Loki split is the right architecture. The stale JSDoc is the only real fix needed before merge. |
Summary
createResource()into separate metrics and logs resources to handle Mimir vs Loki cardinality differentlyservice.instance.id= container instance name (meeting ID) for unique series in Mimirservice.instance.idto prevent Loki stream explosion, withrunIdcarrying the instance identity as structured metadataCONTAINER_INSTANCE_NAME(the human-readable session/meeting ID) to container viastartOptions.envVarscityandcountryresource attributes from CF runtime env varsKey decisions
runIdfield name chosen to avoid Loki auto-indexing (unlikesession_idorcontainer_id)startOptions.envVarsfully replaces class-levelenvVars(CF containers??semantics), sobuildContainerEnvVars()is shared between class default and start overrideCONTAINER_INSTANCE_NAMEfalls back toCLOUDFLARE_DURABLE_OBJECT_IDthencrypto.randomUUID()for non-CF environmentsTest plan
runIdshows meeting UUID in Lokicity/countryappear as non-indexed fields in Loki