Skip to content

Add resource attribute support to ChipIngress client#2216

Draft
pkcll wants to merge 2 commits into
mainfrom
chip-ingress-resource-attributes
Draft

Add resource attribute support to ChipIngress client#2216
pkcll wants to merge 2 commits into
mainfrom
chip-ingress-resource-attributes

Conversation

@pkcll

@pkcll pkcll commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds resource-attribute propagation from beholder.Config.ResourceAttributes to the ChipIngress cre topic via two mechanisms: (1) gRPC metadata headers (chipingress.WithHeaderProvider/NewStaticHeaderProvider), raw key names, parity with beholder__platform__messages; (2) CloudEvent extensions (chipingress.WithResourceAttributeExtensions) with keys sanitized to ^[a-z0-9]+$ per the CloudEvents spec, surfacing as ce_<name> Kafka headers.
  • Wires both the non-batch ChipIngressEmitter and ChipIngressBatchEmitterService to stamp resource attributes on every emitted event.

Known gaps / follow-ups (called out for reviewers)

  • gRPC-metadata → Kafka-header forwarding is unconfirmed server-side. The chip-ingress server's baseKafkaHeaders logic does not appear to forward arbitrary incoming gRPC metadata onto Kafka headers today. The CE-extension mechanism guarantees headers immediately; the gRPC-metadata mechanism is shipped for observability now, with full parity once/if a chip-ingress server-side change forwards it. A follow-up ticket against chip-ingress should track that.
  • pkg/durableemitter is out of scope. It has its own NewEvent call site and config, and wiring it up would also require chainlink core changes (application.go, shell.go, plugins/loop_registry.go). This assumes production CRE-topic traffic goes through the beholder emitters, not DurableEmitter — unconfirmed, worth a sanity check before merge.
  • Cross-module version bump needed. pkg/chipingress is its own Go module; go.mod's pinned pkg/chipingress pseudo-version needs bumping to pick these changes up in pkg/beholder (standard two-step process per this repo's history).

Test plan

  • go test ./pkg/chipingress/... and go test ./pkg/beholder/... pass
  • New unit tests: SanitizeExtensionName, WithResourceAttributeExtensions (sanitization, reserved-name skip, deterministic dedup), NewStaticHeaderProvider, resourceAttributesToStringMap, and emitter-level tests asserting ce_<sanitized> extensions land on published/batched events
  • Manual verification against a live chip-ingress endpoint (not done in this session)

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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

✅ Compatible Changes (7)

./ (7)
  • EventOpt — ➕ Added

  • NewEventWithOpts — ➕ Added

  • NewStaticHeaderProvider — ➕ Added

  • SanitizeExtensionName — ➕ Added

  • SanitizeMetadataHeaders — ➕ Added

  • SanitizeMetadataValue — ➕ Added

  • WithResourceAttributeExtensions — ➕ Added


📄 View full apidiff report

@pkcll pkcll force-pushed the chip-ingress-resource-attributes branch from e6eabcc to fdb6dee Compare July 2, 2026 03:48
@pkcll pkcll requested a review from patrickhuie19 July 2, 2026 05:05
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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

✅ Compatible Changes (1)

pkg/beholder.ChipIngressEmitterConfig (1)
  • NewWithResourceAttributes — ➕ Added

📄 View full apidiff report

Comment thread go.mod Outdated
gopkg.in/yaml.v2 v2.4.0 // indirect
)

replace github.com/smartcontractkit/chainlink-common/pkg/chipingress => ./pkg/chipingress

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.

any way to avoid the local replace?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For sure, will clean this up.

patrickhuie19
patrickhuie19 previously approved these changes Jul 10, 2026
@pkcll pkcll force-pushed the chip-ingress-resource-attributes branch 4 times, most recently from 4a43f88 to de3f8a9 Compare July 11, 2026 01:20
pkcll added 2 commits July 10, 2026 21:32
Propagate node resource attributes from beholder.Config.ResourceAttributes
to the cre topic via gRPC metadata headers and sanitized CloudEvent
extensions, matching legacy beholder__platform__messages identification.
Root module must pin the submodule commit that contains the new
chipingress API; required after removing the local replace directive.
@pkcll pkcll force-pushed the chip-ingress-resource-attributes branch from aa6b73c to d6a531b Compare July 11, 2026 01:32
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.

2 participants