-
Notifications
You must be signed in to change notification settings - Fork 24
INFOPLAT-2282: Add beholderNoopLogerProvider and LogStreamingEnabled flag to control emitting logs #1263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a toggle to enable or disable log streaming via the OTel exporter and provides a no-op logger provider when streaming is off.
- Added
BeholderNoopLoggerProvider
to drop all logs when streaming is disabled. - Introduced
LogStreamingEnabled
flag inConfig
and wired it through both HTTP and GRPC clients. - Updated default configuration and tests to account for the new flag.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
pkg/beholder/noop.go | Added beholderNoopLogExporter and BeholderNoopLoggerProvider . |
pkg/beholder/httpclient.go | Conditional logger setup based on LogStreamingEnabled . |
pkg/beholder/config_test.go | Updated ExampleConfig to include LogStreamingEnabled . |
pkg/beholder/config.go | Added LogStreamingEnabled field and default in DefaultConfig . |
pkg/beholder/client_test.go | Tests for enabling/disabling log streaming. |
pkg/beholder/client.go | Conditional logger setup in GRPC client based on LogStreamingEnabled . |
Comments suppressed due to low confidence (2)
pkg/beholder/config.go:49
- [nitpick] The comment on LogStreamingEnabled could mention its default value (
false
) as defined in DefaultConfig to clarify its default behavior.
LogStreamingEnabled bool // Enable streaming logs to the OTel log exporter
pkg/beholder/config_test.go:50
- [nitpick] Consider adding a unit test to verify that
DefaultConfig().LogStreamingEnabled
isfalse
to ensure default behavior remains consistent.
LogStreamingEnabled: false, // Disable streaming logs by default
pkg/beholder/client.go
Outdated
} | ||
if cfg.LogExportMaxBatchSize > 0 { | ||
batchProcessorOpts = append(batchProcessorOpts, sdklog.WithExportMaxBatchSize(cfg.LogExportMaxBatchSize)) // Default is 512, must be <= maxQueueSize | ||
var loggerProvider *sdklog.LoggerProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: get rid of else
var loggerProvider *sdklog.LoggerProvider | |
loggerProvider := BeholderNoopLoggerProvider() |
and remove
else {
loggerProvider = BeholderNoopLoggerProvider()
}
or to keep code more flat
just add
if !cfg.LogStreamingEnabled {
loggerProvider = BeholderNoopLoggerProvider()
}
Note: we expect it to be normally alway enabled in the future
pkg/beholder/config.go
Outdated
// Retry config for shared log exporter, used by Emitter and Logger | ||
LogRetryConfig *RetryConfig | ||
LogRetryConfig *RetryConfig | ||
LogStreamingEnabled bool // Enable streaming logs to the OTel log exporter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: // Enable logs streaming via OTel Logger
pkg/beholder/config.go
Outdated
LogExportInterval: 1 * time.Second, | ||
LogMaxQueueSize: 2048, | ||
LogBatchProcessor: true, | ||
LogStreamingEnabled: false, // Disable streaming logs by default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: streaming logs
-> logs streaming
since we use that terminology across the board
NOTE: for the config option singular form LogStreamingEnabled
makes more sense for consistency with other log config options
pkg/beholder/httpclient.go
Outdated
if cfg.LogExportMaxBatchSize > 0 { | ||
batchProcessorOpts = append(batchProcessorOpts, sdklog.WithExportMaxBatchSize(cfg.LogExportMaxBatchSize)) // Default is 512, must be <= maxQueueSize | ||
var loggerProvider *sdklog.LoggerProvider | ||
if cfg.LogStreamingEnabled { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…flag to control emitting logs (#1263) * Add beholderNoopLogerProvider and LogStreamingEnabled flag to control emitting logs * Fix tests * Fix config test * Flatten if conditions * Fix tests
This PR adds
beholderNoopLogerProvider
andLogStreamingEnabled
flag to control emitting logs throughsharedLogExporter
The ticket for the reference: https://smartcontract-it.atlassian.net/browse/INFOPLAT-2282