Skip to content

PLEX-2935/generalize monitoring#2132

Draft
Unheilbar wants to merge 3 commits into
feature/solcap-read_triggerfrom
PLEX-2935/generalize-monitoring
Draft

PLEX-2935/generalize monitoring#2132
Unheilbar wants to merge 3 commits into
feature/solcap-read_triggerfrom
PLEX-2935/generalize-monitoring

Conversation

@Unheilbar
Copy link
Copy Markdown
Contributor

@Unheilbar Unheilbar commented Jun 8, 2026

JIRA
MonitoringContext() implementation by solana capability here

Summary

  • Add --with-monitoring to capability server generation for per-capability opt-in
  • Move action lifecycle monitoring (Initiated / Success / Error) into generated server code
  • Introduce shared events: CapabilityActionInitiated, CapabilityActionSuccess, CapabilityActionError
  • Add optional KVs() []any on request types for method-specific log enrichment (e.g. pkg/capabilities/v2/chain-capabilities/solana/monitoring_kvs.go)
  • Require MonitoringContext() on generated capability interfaces

Benefits

  • New RPCs get monitoring automatically after go generate --with-monitoring
  • Action implementations no longer need Initiated/Success/Error boilerplate
  • One shared event schema replaces per-method mirrored monitoring protos
  • Observability can query by method label instead of maintaining action lists
  • Capabilities can migrate one by one; default generation stays unchanged
  • chainlink-common stays lightweight: only MonitoringLabels in base package

Notes

  • Sub-execution events (e.g. WriteReportTxFeeCalculationError) and trigger monitoring remain manual
  • Proto descriptor path fixed to avoid execution_context.proto registration panic

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 8, 2026

⚠️ API Diff Results - github.com/smartcontractkit/chainlink-common

⚠️ Breaking Changes (2)

pkg/capabilities/v2/chain-capabilities/solana/server.ClientCapability (1)
  • MonitoringContext — ➕ Added
pkg/capabilities/v2/protoc/pkg (1)
  • GenerateServer — Type changed:
func(
  *google.golang.org/protobuf/compiler/protogen.Plugin, 
  *google.golang.org/protobuf/compiler/protogen.File, 
  ServerLanguage, 
  string, 
  string, 
  + bool
)
error

✅ Compatible Changes (4)

package github (1)
  • com/smartcontractkit/chainlink-common/pkg/capabilities/v2/monitoring — ➕ Added
pkg/capabilities (1)
  • MonitoringLabels — ➕ Added
pkg/capabilities/v2/chain-capabilities/solana.(*WriteReportRequest) (1)
  • KVs — ➕ Added
pkg/capabilities/v2/chain-capabilities/solana/server.ClientCapability (1)
  • MonitoringContext — ➕ Added

📄 View full apidiff report

@Unheilbar Unheilbar changed the title Plex 2935/generalize monitoring PLEX-2935/generalize monitoring Jun 8, 2026
return err
}

withMonitoring := os.Getenv("CHAINLINK_PROTOC_WITH_MONITORING") == "true"
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.

Is there precedent for the CHAINLINK_ prefix? Because we use just CL_ in many places.

mc := c.ClientCapability.MonitoringContext()
kvs := []any{"method", "GetAccountInfoWithOpts", "executionID", metadata.WorkflowExecutionID}
if labeled, ok := any(input).(capabilities.MonitoringLabels); ok {
kvs = append(kvs, labeled.KVs()...)
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.

We should separate KVs for logging and KVs for metrics.
In the case of metrics, we cannot use high-cardinality values, as it will overload metrics storage.

// on the generated ClientCapability interface.
type MonitoringContext struct {
Logger logger.Logger
Processor beholder.ProtoProcessor
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.

We no longer need to use proto processor. Previously, beholder events were the only way to observe logs from a NOP. Now, with logs streaming, it's redundant for chain capabilities.

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.

Also we should be able to define metrics (need both beholder and prom) on common level

// capability lifecycle event. It intentionally mirrors
// capabilities/libs/monitoring.ExecutionContext in the capabilities binary repo
// so that beholder consumers see a consistent schema.
message ExecutionContext {
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.

proto is redundant as we do not need to use beholder

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.

We also should not ask for the capability to populate this whole structure.
It's sufficient to expose a general MetricsAttributes method that includes capability-specific labels like chain_id, name, etc.
The rest of the fields can be provided by the generated code

@@ -0,0 +1,295 @@
package server
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.

Why do we need a separate template to enable monitoring? It contains a lot of duplicate code, and if we introduce another optional feature, it will force us to double templates.
Can't we optionally generate monitoring code by passing a variable to the template?

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