Skip to content

[1/2] chipingress: expose drop failure classification for partial delivery metrics#2210

Closed
pkcll wants to merge 1 commit into
mainfrom
chipingress-partial-delivery-cl-nodes
Closed

[1/2] chipingress: expose drop failure classification for partial delivery metrics#2210
pkcll wants to merge 1 commit into
mainfrom
chipingress-partial-delivery-cl-nodes

Conversation

@pkcll

@pkcll pkcll commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Part 1 of 2 — adds the chipingress batch client helpers needed for the beholder partial-delivery metric change.

  • Export ErrMessageBufferFull and ErrClientShutdown sentinels from pkg/chipingress/batch.
  • Add batch.ClassifyDropFailure to map send/queue errors into shared metric dimensions (error_type, error_code, error_reason).

Part 2: #2266
Jira: INFOPLAT-13901

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

📊 API Diff Results

No changes detected for module github.com/smartcontractkit/chainlink-common

View full report

@pkcll
pkcll force-pushed the chipingress-partial-delivery-cl-nodes branch 4 times, most recently from 59011ac to d16297c Compare July 3, 2026 20:41
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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

✅ Compatible Changes (7)

batch (7)
  • ErrClientShutdown — ➕ Added

  • ErrMessageBufferFull — ➕ Added

  • ErrorCodeFor — ➕ Added

  • ErrorTypeBufferFull — ➕ Added

  • ErrorTypeClientError — ➕ Added

  • ErrorTypePartialDelivery — ➕ Added

  • ErrorTypeRPCError — ➕ Added


📄 View full apidiff report

@pkcll
pkcll force-pushed the chipingress-partial-delivery-cl-nodes branch 7 times, most recently from f74f0a3 to 6d7cc16 Compare July 21, 2026 05:57
@pkcll pkcll changed the title beholder: log partial delivery per-event errors with error_code and reason chipingress: expose drop failure classification for partial delivery metrics Jul 21, 2026
@pkcll
pkcll force-pushed the chipingress-partial-delivery-cl-nodes branch from 6d7cc16 to 5b8513f Compare July 21, 2026 06:07
@pkcll pkcll changed the title chipingress: expose drop failure classification for partial delivery metrics [1/2] chipingress: expose drop failure classification for partial delivery metrics Jul 21, 2026
@pkcll
pkcll marked this pull request as ready for review July 21, 2026 06:14
@pkcll
pkcll requested a review from a team as a code owner July 21, 2026 06:14
Copilot AI review requested due to automatic review settings July 21, 2026 06:14

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.

Pull request overview

Adds shared error classification utilities to pkg/chipingress/batch so downstream components (e.g., beholder in the follow-up PR) can emit consistent partial-delivery / send/queue failure metrics and logs.

Changes:

  • Introduces DropFailure and ClassifyDropFailure(err) to map batch send/queue errors into {error_type, error_code, error_reason}.
  • Adds unit tests covering common gRPC statuses, partial-delivery PublishError, and local queue conditions.
  • Exports ErrMessageBufferFull / ErrClientShutdown sentinels and updates QueueMessage to return them for reliable errors.Is matching.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pkg/chipingress/batch/drop_failure.go Adds the DropFailure model + ClassifyDropFailure helper used for metric/log dimensions.
pkg/chipingress/batch/drop_failure_test.go Adds coverage for error classification across partial delivery, gRPC, and local queue errors.
pkg/chipingress/batch/client.go Exports sentinel errors and returns them from QueueMessage to enable stable classification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/chipingress/batch/drop_failure.go Outdated
Comment on lines +74 to +78
return DropFailure{
ErrorType: ErrorTypeRPCError,
ErrorCode: codes.Unknown.String(),
ErrorReason: err.Error(),
}
Comment on lines +74 to +80
{
name: "unknown error",
err: errors.New("something else"),
wantType: batch.ErrorTypeRPCError,
wantCode: codes.Unknown.String(),
wantReason: "something else",
},
Comment thread pkg/chipingress/batch/drop_failure.go Outdated
ErrorType string // partial_delivery | rpc_error | buffer_full | client_error
ErrorCode string // PUBLISH_ERROR_CODE_* or gRPC code name (DeadlineExceeded, …)
ErrorReason string // server reason, status message, or client error text
}

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.

It seems that you don't really need a separate type DropFailure here.

In #2266, you can:

@pkcll pkcll Jul 21, 2026

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.

Addressed in #2266

Copilot AI review requested due to automatic review settings July 21, 2026 21:25
@pkcll
pkcll force-pushed the chipingress-partial-delivery-cl-nodes branch from 65f2ba8 to e8d7286 Compare July 21, 2026 21:27

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

Comment on lines +36 to +41
if errors.Is(err, ErrMessageBufferFull) {
return ErrMessageBufferFull.Error()
}
if errors.Is(err, ErrClientShutdown) {
return ErrClientShutdown.Error()
}
Comment on lines +18 to +22
// ErrorCodeFor returns a bounded error code string for a batch send/queue error.
// The returned code is intended for metric dimensions; callers can infer the
// error category from the code:
// - PUBLISH_ERROR_CODE_* -> partial_delivery
// - "buffer_full" -> buffer_full
Comment on lines +50 to +54
{
name: "buffer full",
err: batch.ErrMessageBufferFull,
want: batch.ErrMessageBufferFull.Error(),
},
Comment on lines +55 to +59
{
name: "client shutdown",
err: batch.ErrClientShutdown,
want: batch.ErrClientShutdown.Error(),
},
Comment on lines +22 to +25
var (
ErrMessageBufferFull = errors.New("message buffer is full")
ErrClientShutdown = errors.New("client is shutdown")
)
Comment on lines +67 to +72
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
assert.Equal(t, tt.want, batch.ErrorCodeFor(tt.err))
})
}
Copilot AI review requested due to automatic review settings July 21, 2026 21:29

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (4)

pkg/chipingress/batch/drop_failure.go:40

  • ErrorCodeFor currently returns the full sentinel error messages for buffer-full and shutdown ("message buffer is full" / "client is shutdown"), but the function comment describes stable metric codes ("buffer_full" / "client_shutdown"). Returning the human-readable strings couples metric dimensions to error wording and doesn't match the documented values.
	if errors.Is(err, ErrMessageBufferFull) {
		return ErrMessageBufferFull.Error()
	}
	if errors.Is(err, ErrClientShutdown) {
		return ErrClientShutdown.Error()

pkg/chipingress/batch/drop_failure_test.go:54

  • Test expects ErrorCodeFor to return the sentinel error string for buffer-full, but the helper's doc (and intended metric code) is "buffer_full". Align the test expectation with the stable code value.
			name: "buffer full",
			err:  batch.ErrMessageBufferFull,
			want: batch.ErrMessageBufferFull.Error(),
		},

pkg/chipingress/batch/drop_failure_test.go:59

  • Test expects ErrorCodeFor to return the sentinel error string for shutdown, but the helper's doc (and intended metric code) is "client_shutdown". Align the test expectation with the stable code value.
			name: "client shutdown",
			err:  batch.ErrClientShutdown,
			want: batch.ErrClientShutdown.Error(),
		},

pkg/chipingress/batch/drop_failure.go:53

  • PR description mentions adding batch.ClassifyDropFailure to provide shared metric dimensions (error_type, error_code, error_reason), but this file currently only exposes ErrorCodeFor. Consider adding the promised helper so downstream callers (e.g. beholder) can consistently derive all dimensions without re-implementing logic.
	return ErrorTypeClientError
}

Comment on lines +75 to +78
func TestErrorCodeFor_nil(t *testing.T) {
t.Parallel()
require.Empty(t, batch.ErrorCodeFor(nil))
}
@pkcll
pkcll force-pushed the chipingress-partial-delivery-cl-nodes branch 2 times, most recently from 57bb513 to 8cd89c4 Compare July 21, 2026 21:41
@pkcll

pkcll commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Folding this into #2266 — moved drop_failure.go there and simplified ErrorCodeFor to return (errorType, errorCode) directly, so there's no cross-PR dependency to coordinate.

@pkcll pkcll closed this Jul 22, 2026
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.

3 participants