Skip to content

INFOPLAT-13349: feat(beholder): track log export bytes per node via gRPC stats handler#2251

Open
kirqz23 wants to merge 1 commit into
mainfrom
infoplat-13349-metered-exporter
Open

INFOPLAT-13349: feat(beholder): track log export bytes per node via gRPC stats handler#2251
kirqz23 wants to merge 1 commit into
mainfrom
infoplat-13349-metered-exporter

Conversation

@kirqz23

@kirqz23 kirqz23 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What

Adds a beholder.logs.export.bytes counter to the beholder gRPC client, restoring
per-node log volume visibility (labelled by csa_public_key) that was lost when
otelgrpc semconv v1.40.0 dropped rpc.client.request.size.

According to these docs, metrics are totally deprecated without any successors.
RPC semantic convention stability migration guide

Semantic conventions for RPC metrics

How

  • A lightweight gRPC stats.Handler (sizeCaptureHandler) reads OutPayload.Length the exact same source the old otelgrpc metric used and stores it in a shared atomic.
  • A thin sdklog.Exporter wrapper (meteredLogsExporter) sits above the OTLP retry
    loop and records the captured byte count once per batch, only on success so retries
    don't inflate the count.
  • Both are wired onto the shared log exporter connection in NewGRPCClient.

Requires

Supports

Copilot AI review requested due to automatic review settings July 14, 2026 13:54
@kirqz23 kirqz23 requested a review from a team as a code owner July 14, 2026 13:54
@github-actions

Copy link
Copy Markdown
Contributor

👋 kirqz23, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions

Copy link
Copy Markdown
Contributor

📊 API Diff Results

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

View full report

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 a custom metric to restore per-node visibility into OTLP log export volume by capturing the uncompressed outbound gRPC payload size and emitting it as beholder.logs.export.bytes (labelled by csa_public_key).

Changes:

  • Introduces a gRPC stats.Handler (sizeCaptureHandler) to capture stats.OutPayload.Length.
  • Wraps the OTLP logs exporter with meteredLogsExporter to increment a bytes counter on successful exports (to avoid retry inflation).
  • Wires the stats handler + metered exporter into NewGRPCClient’s shared log exporter connection.

Reviewed changes

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

File Description
pkg/beholder/metered_exporter.go Adds size-capture stats handler and metered exporter wrapper emitting beholder.logs.export.bytes.
pkg/beholder/client.go Wires the shared capture + exporter wrapper and attaches the gRPC stats handler(s) to the log exporter dial options.

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

Comment thread pkg/beholder/client.go
Comment on lines 573 to 576
dialOpts := []grpc.DialOption{
grpc.WithStatsHandler(otelgrpc.NewClientHandler(otelOpts...)),
grpc.WithStatsHandler(&sizeCaptureHandler{capture: capture}),
}
Comment on lines +40 to +44
op, ok := rs.(*stats.OutPayload)
if !ok {
return
}
h.capture.val.Store(int64(op.Length))
Comment on lines +78 to +84
func (e *meteredLogsExporter) Export(ctx context.Context, records []sdklog.Record) error {
err := e.inner.Export(ctx, records)
if err == nil {
e.counter.Add(ctx, e.capture.val.Load(), e.attrs)
}
return err
}
Comment on lines +56 to +60
func newMeteredLogsExporter(
inner sdklog.Exporter,
meter otelmetric.Meter,
csaPublicKeyHex string,
capture *sizeCapture,
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