Skip to content

feat: stamp service.instance.id on spans and share it with the heartbeat - #24

Merged
PabloPardoGarcia merged 1 commit into
mainfrom
pablo/rius-436-service-instance-id
Aug 20, 2026
Merged

feat: stamp service.instance.id on spans and share it with the heartbeat#24
PabloPardoGarcia merged 1 commit into
mainfrom
pablo/rius-436-service-instance-id

Conversation

@PabloPardoGarcia

Copy link
Copy Markdown
Member

Fixes RIUS-436 (TypeScript side; wire contract identical to the Python PR: glassflow/rius-sdk-python#63).

What

One uuid per client, minted in init() before the provider is built:

  • Stamped on the OTel Resource as service.instance.id (standard OTel semconv), so every exported span carries it.
  • Injected into HeartbeatSender (now a required option) instead of the sender minting its own, so heartbeat payloads carry the same identity.

The backend can now join heartbeats to traces and count replicas sharing one agent_name.

Decisions

  • Stamped unconditionally (heartbeat off included) — the id identifies the client/process, not the heartbeat feature.
  • Workers spawned after init() (cluster/fork patterns) should init() themselves for exact per-worker span identity; noted in the code.

Tests

New cases in tests/client.test.ts (written first, watched fail):

  • resource attribute present and a valid UUID
  • heartbeat payload instance_id == span resource attribute (injected exporter + transport)
  • present with heartbeat: false
  • distinct ids across two separately initialized clients

The former "fresh instanceId per sender" test now asserts the sender carries the injected identity.

All gates green: vitest (224 passed), biome, tsc, build.

One uuid per client, minted at init before the provider is built: stamped
as the service.instance.id resource attribute on every span and injected
into HeartbeatSender so heartbeat payloads carry the same identity. The
backend can now join heartbeats to traces and count replicas.

Stamped unconditionally (heartbeat off included). Workers spawned after
init() should init() themselves for exact per-worker span identity.
@PabloPardoGarcia
PabloPardoGarcia merged commit a523813 into main Aug 20, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant