Skip to content

Conversation

kirqz23
Copy link
Contributor

@kirqz23 kirqz23 commented Jun 13, 2025

This PR adds beholderNoopLogerProvider and LogStreamingEnabled flag to control emitting logs through sharedLogExporter

The ticket for the reference: https://smartcontract-it.atlassian.net/browse/INFOPLAT-2282

Copy link
Contributor

@Copilot Copilot AI left a 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 in Config 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 is false to ensure default behavior remains consistent.
LogStreamingEnabled:   false, // Disable streaming logs by default

}
if cfg.LogExportMaxBatchSize > 0 {
batchProcessorOpts = append(batchProcessorOpts, sdklog.WithExportMaxBatchSize(cfg.LogExportMaxBatchSize)) // Default is 512, must be <= maxQueueSize
var loggerProvider *sdklog.LoggerProvider
Copy link
Contributor

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

Suggested change
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

// 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
Copy link
Contributor

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

LogExportInterval: 1 * time.Second,
LogMaxQueueSize: 2048,
LogBatchProcessor: true,
LogStreamingEnabled: false, // Disable streaming logs by default
Copy link
Contributor

@pkcll pkcll Jun 13, 2025

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

if cfg.LogExportMaxBatchSize > 0 {
batchProcessorOpts = append(batchProcessorOpts, sdklog.WithExportMaxBatchSize(cfg.LogExportMaxBatchSize)) // Default is 512, must be <= maxQueueSize
var loggerProvider *sdklog.LoggerProvider
if cfg.LogStreamingEnabled {
Copy link
Contributor

Choose a reason for hiding this comment

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

pkcll
pkcll previously approved these changes Jun 13, 2025
@pavel-raykov pavel-raykov merged commit 8fe6129 into main Jun 16, 2025
13 of 16 checks passed
@pavel-raykov pavel-raykov deleted the infoplat-2282-log-flag branch June 16, 2025 09:46
jinhoonbang pushed a commit that referenced this pull request Jun 17, 2025
…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
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.

4 participants