Skip to content

durableemitter: add tracing spans and chip ingress client name - #2432

Merged
jmank88 merged 6 commits into
mainfrom
durable-emitter-tracing
Oct 2, 2026
Merged

jmank88 merged 6 commits into
mainfrom
durable-emitter-tracing

Conversation

@pkcll

@pkcll pkcll commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • DurableEmitter now creates otel spans: durable_emitter.emit, durable_emitter.deliver (remote-parented on and linked to the emit/retransmit span, since delivery runs on the batcher goroutine, so sampling follows the emit span), durable_emitter.retransmit_tick, durable_emitter.expiry_tick. Idle retransmit_tick passes are not traced; expiry_tick is traced once per pass (see Span behavior).
  • New Config.TracerProvider / SetupConfig.TracerProvider (nil uses the global provider); Setup passes it to the chip ingress client so gRPC spans use the same provider.
  • Setup passes chipingress.WithClientName("durable_emitter") (the existing batch.ClientNameDurableEmitter), so chip-ingress and the gRPC spans/metrics can identify the emitter.

PR stack (merge in this order)

  1. chipingress: add WithClientName option #2433 - chipingress: add WithClientName option (merged; base: main)
  2. durableemitter: add tracing spans and chip ingress client name #2432 - durableemitter: add tracing spans and chip ingress client name (this PR) (merged; needed chipingress: add WithClientName option #2433, base: main)
  3. loop: pass beholder TracerProvider to the durable emitter #2434 - loop: pass beholder TracerProvider to the durable emitter (needs durableemitter: add tracing spans and chip ingress client name #2432, merged; base: main)

Jira: INFOPLAT-19423

Span behavior

  • durable_emitter.emit: one per Emit call (child of the caller ctx). Attributes: source_domain, entity_type. Error status on failure.
  • durable_emitter.deliver: one per delivered or failed event, started when the batch callback fires. Attribute: phase (batch or retransmit). Error status when the publish failed.
  • durable_emitter.retransmit_tick: started only when ListPending returns rows, with a pending count. A ListPending failure still produces an error span. Idle ticks (the host loop runs every 1s) produce no span.
  • durable_emitter.expiry_tick: one per expiry pass (every ExpiryInterval, 1m by default), started when the pass begins. Attribute: purged count, set when the pass ends. Error status on failure.

Depends on

Notes

  • gRPC client spans remain root spans (the batch client publishes on a detached context); the span link provides correlation.
  • Timeout/batching config changes go in a separate PR.

Test plan

  • go test -race ./pkg/durableemitter/ (span tests in tracing_test.go: emit/deliver parent and link, deliver failure status, retransmit-phase link, expiry tick, background error status, idle retransmit ticks produce no spans, nil provider default; tracing tests stress-run under -race)
  • go build ./pkg/..., go vet, go mod tidy -diff clean
  • CI (SonarQube coverage gate fails on all PRs in this repo because the Sonar job reads a stale go-test-results artifact; CI-owner fix)

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

✅ API Diff Results - github.com/smartcontractkit/chainlink-common/pkg/chipingress

✅ Compatible Changes (1)

./ (1)
  • WithClientName — ➕ Added

📄 View full apidiff report

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ API Diff Results - github.com/smartcontractkit/chainlink-common

✅ Compatible Changes (2)

pkg/durableemitter.Config (1)
  • TracerProvider — ➕ Added
pkg/durableemitter.SetupConfig (1)
  • TracerProvider — ➕ Added

📄 View full apidiff report

@pkcll
pkcll force-pushed the durable-emitter-tracing branch from ccd2a62 to ecb2287 Compare October 1, 2026 03:33
@pkcll pkcll changed the title durableemitter: add tracing spans; chipingress: add WithClientName durableemitter: add tracing spans and chip ingress client name Oct 1, 2026
Emit, delivery (linked to the emit span), retransmit tick and expiry tick now create otel spans via Config/SetupConfig.TracerProvider (global provider when nil). Setup passes the provider and client name durable_emitter to the chip ingress client. Temporarily pins pkg/chipingress to the chipingress-client-name branch; bump to the released version once that PR merges.
…nd errors, tidy go.mod

The deliver span now uses the originating span as its remote parent so sampling follows the emit span (it stays linked too). Expiry and retransmit failures set error status on their tick spans. Adds tests for expiry_tick, the retransmit-phase deliver link, background error status and the nil tracer provider default, drops the stale go.sum lines flagged by check-tidy, and re-pins pkg/chipingress to the updated chipingress-client-name branch.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: ee21d71 Previous: ccd2a62 Ratio
BenchmarkKeystore_Sign/nop/in-process 738.7 ns/op 274.9 ns/op 2.69

This comment was automatically generated by workflow using github-action-benchmark.

@pkcll pkcll mentioned this pull request Oct 2, 2026
1 of 2 tasks
Replaces the dev-branch pin now that chipingress-client-name is merged (dbc6c22). Bump to a tagged release once pkg/chipingress is released.
@pkcll
pkcll marked this pull request as ready for review October 2, 2026 01:25
@pkcll
pkcll requested a review from a team as a code owner October 2, 2026 01:25
Copilot AI balanced review requested due to automatic review settings October 2, 2026 01:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The retransmit tracing test has a race and does not verify that the tick span is the actual parent and link.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds OpenTelemetry tracing and client identification to the durable emitter.

Changes:

  • Instruments emit, delivery, retransmission, and expiry operations.
  • Propagates tracer-provider and client-name configuration.
  • Adds tracing tests and updates the chip-ingress dependency.
File Description
pkg/​durableemitter/​durable_emitter.go Implements tracing spans and error recording.
pkg/​durableemitter/​setup.go Configures tracing and client identity.
pkg/​durableemitter/​tracing_test.go Tests tracing behavior and relationships.
go.mod Updates chip-ingress dependency.
go.sum Updates dependency checksums.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +132 to +135
require.Len(t, retransmit.Links(), 1)
assert.Equal(t, retransmit.Links()[0].SpanContext.SpanID(), retransmit.Parent().SpanID())
tick := endedSpan(rec, spanRetransmitTick)
require.NotNil(t, tick)
retransmit_tick is started only when rows are pending (a ListPending failure still records an error span). expiry_tick is recorded after the pass, back-dated to its start, only when rows were purged or an error occurred. Idle ticks previously produced a root span every interval on every node.
@pkcll
pkcll requested a review from jmank88 October 2, 2026 02:09
Comment thread pkg/durableemitter/durable_emitter.go Outdated
Start the span when the expiry pass begins and set the purged count and error status when it ends, instead of recording a back-dated span afterwards. DB calls in the pass are now children of the span. Idle expiry passes (once per ExpiryInterval) are traced again; idle retransmit ticks still are not.
@jmank88
jmank88 enabled auto-merge October 2, 2026 21:16
@jmank88
jmank88 added this pull request to the merge queue Oct 2, 2026
Merged via the queue into main with commit 3e181f9 Oct 2, 2026
40 of 43 checks passed
@jmank88
jmank88 deleted the durable-emitter-tracing branch October 2, 2026 22:31
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.

4 participants