Skip to content

Conversation

kirqz23
Copy link
Contributor

@kirqz23 kirqz23 commented Oct 16, 2025

This PR splits some code into separate functions: newLoggerExporter, newLoggerProvider and newMessageLoggerProvider. Additionally it adds gRPC instrumentation to the Beholder client to enable automatic collection of gRPC performance metrics using StatsHandler. The instrumentation provides visibility into gRPC request/response sizes, durations, success rates.

Related to: smartcontractkit/chainlink#19089

@kirqz23 kirqz23 requested a review from a team as a code owner October 16, 2025 10:40
Copy link

👋 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!

Copy link

github-actions bot commented Oct 16, 2025

✅ API Diff Results - No breaking changes


📄 View full apidiff report

otlptracegrpc.WithTLSCredentials(creds),
otlptracegrpc.WithEndpoint(config.OtelExporterGRPCEndpoint),
// Uses deferred binding for global providers
otlptracegrpc.WithDialOption(grpc.WithStatsHandler(otelgrpc.NewClientHandler())),
Copy link
Contributor

Choose a reason for hiding this comment

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

it should not be applied to meter and tracer providers because otelgrpc uses them actually under the hood

otlpmetricgrpc.WithTLSCredentials(creds),
otlpmetricgrpc.WithEndpoint(cfg.OtelExporterGRPCEndpoint),
// Uses deferred binding for global providers
otlpmetricgrpc.WithDialOption(grpc.WithStatsHandler(otelgrpc.NewClientHandler())),
Copy link
Contributor

Choose a reason for hiding this comment

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

}
}

opts := []otlploggrpc.Option{
Copy link
Contributor

@pkcll pkcll Oct 16, 2025

Choose a reason for hiding this comment

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

#nit: should be renamed to logExporterOpts or something more explicit
Its used here https://github.com/smartcontractkit/chainlink-common/pull/1617/files#diff-74ce7f3d5474f67956a5d9ba5779b478b715235a0d33e8826eb99b146664ae4dR146 for sharedLogExporter

otlploggrpc.WithTLSCredentials(creds),
otlploggrpc.WithEndpoint(cfg.OtelExporterGRPCEndpoint),
// Uses deferred binding for global providers
otlploggrpc.WithDialOption(grpc.WithStatsHandler(otelgrpc.NewClientHandler())),
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

That would require changing order how things are initialized in NewGRPCClient
It should be metrics, tracing first than logger.

Copy link
Contributor

Choose a reason for hiding this comment

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

#nit: Maybe it worth creating a helper function newLoggerProvider for logger similar to how its done for metrics and traces

…emitter using shared exporter with grpc metrics
@kirqz23 kirqz23 requested a review from pkcll October 16, 2025 17:14
@kirqz23 kirqz23 changed the title INFOPLAT-2288: Add WithStatsHandler for in-house grpc metrics to Beholder INFOPLAT-2288: Add grpc metrics to Beholder using StatsHandler Oct 16, 2025
pkcll
pkcll previously approved these changes Oct 16, 2025
Copy link

@github-actions github-actions bot left a comment

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: 28f28bd Previous: 2c2872d Ratio
BenchmarkKeystore_Sign/nop/in-process 786.2 ns/op 373.4 ns/op 2.11

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

Comment on lines +509 to +513
messageAttributes := []attribute.KeyValue{
attribute.String(AttrKeyDataType, "custom_message"),
}
messageLoggerResource, err := sdkresource.Merge(
sdkresource.NewSchemaless(messageAttributes...),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a valid simplification?

Suggested change
messageAttributes := []attribute.KeyValue{
attribute.String(AttrKeyDataType, "custom_message"),
}
messageLoggerResource, err := sdkresource.Merge(
sdkresource.NewSchemaless(messageAttributes...),
messageLoggerResource, err := sdkresource.Merge(
sdkresource.NewSchemaless(attribute.String(AttrKeyDataType, "custom_message")),

Comment on lines +467 to +471
loggerAttributes := []attribute.KeyValue{
attribute.String(AttrKeyDataType, "zap_log_message"),
}
loggerResource, err := sdkresource.Merge(
sdkresource.NewSchemaless(loggerAttributes...),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
loggerAttributes := []attribute.KeyValue{
attribute.String(AttrKeyDataType, "zap_log_message"),
}
loggerResource, err := sdkresource.Merge(
sdkresource.NewSchemaless(loggerAttributes...),
loggerResource, err := sdkresource.Merge(
sdkresource.NewSchemaless(attribute.String(AttrKeyDataType, "zap_log_message")),

Comment on lines +408 to +416
otelOpts := []otelgrpc.Option{
otelgrpc.WithMeterProvider(meter),
otelgrpc.WithTracerProvider(tracer),
}

opts := []otlploggrpc.Option{
otlploggrpc.WithTLSCredentials(creds),
otlploggrpc.WithEndpoint(cfg.OtelExporterGRPCEndpoint),
otlploggrpc.WithDialOption(grpc.WithStatsHandler(otelgrpc.NewClientHandler(otelOpts...))),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit/ could simplify and reduce nesting:

Suggested change
otelOpts := []otelgrpc.Option{
otelgrpc.WithMeterProvider(meter),
otelgrpc.WithTracerProvider(tracer),
}
opts := []otlploggrpc.Option{
otlploggrpc.WithTLSCredentials(creds),
otlploggrpc.WithEndpoint(cfg.OtelExporterGRPCEndpoint),
otlploggrpc.WithDialOption(grpc.WithStatsHandler(otelgrpc.NewClientHandler(otelOpts...))),
otelClient := otelgrpc.NewClientHandler(otelgrpc.WithMeterProvider(meter), otelgrpc.WithTracerProvider(tracer))
opts := []otlploggrpc.Option{
otlploggrpc.WithTLSCredentials(creds),
otlploggrpc.WithEndpoint(cfg.OtelExporterGRPCEndpoint),
otlploggrpc.WithDialOption(grpc.WithStatsHandler(otelClient)),

Copy link
Contributor

@jmank88 jmank88 left a comment

Choose a reason for hiding this comment

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

LGTM just some style nits

@jmank88 jmank88 merged commit 9a6afcd into main Oct 16, 2025
19 of 22 checks passed
@jmank88 jmank88 deleted the infoplat-2288-logs-capacity branch October 16, 2025 21:39
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