Skip to content

Commit

Permalink
add too httpclient and test
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghestrimtu committed Nov 29, 2024
1 parent 9fb5e70 commit 39e2ca6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
1 change: 0 additions & 1 deletion pkg/beholder/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func newGRPCClient(cfg Config, otlploggrpcNew otlploggrpcFactory) (*Client, erro
sdklog.WithExportMaxBatchSize(cfg.LogExportMaxBatchSize), // Default is 512, must be <= maxQueueSize
sdklog.WithExportInterval(cfg.LogExportInterval), // Default is 1s
sdklog.WithMaxQueueSize(cfg.LogMaxQueueSize), // Default is 2048

)
} else {
loggerProcessor = sdklog.NewSimpleProcessor(sharedLogExporter)
Expand Down
14 changes: 10 additions & 4 deletions pkg/beholder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ func DefaultConfig() Config {
// Resource
ResourceAttributes: defaultOtelAttributes,
// Message Emitter
EmitterExportTimeout: 1 * time.Second,
EmitterBatchProcessor: true,
EmitterExportTimeout: 1 * time.Second,
EmitterExportMaxBatchSize: 512,
EmitterExportInterval: 1 * time.Second,
EmitterMaxQueueSize: 2048,
EmitterBatchProcessor: true,
// OTel message log exporter retry config
LogRetryConfig: defaultRetryConfig.Copy(),
// Trace
Expand All @@ -99,8 +102,11 @@ func DefaultConfig() Config {
// OTel metric exporter retry config
MetricRetryConfig: defaultRetryConfig.Copy(),
// Log
LogExportTimeout: 1 * time.Second,
LogBatchProcessor: true,
LogExportTimeout: 1 * time.Second,
LogExportMaxBatchSize: 512,
LogExportInterval: 1 * time.Second,
LogMaxQueueSize: 2048,
LogBatchProcessor: true,
}
}

Expand Down
14 changes: 10 additions & 4 deletions pkg/beholder/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ func ExampleConfig() {
otelattr.String("sender", "beholderclient"),
},
// Message Emitter
EmitterExportTimeout: 1 * time.Second,
EmitterBatchProcessor: true,
EmitterExportTimeout: 1 * time.Second,
EmitterExportMaxBatchSize: 512,
EmitterExportInterval: 1 * time.Second,
EmitterMaxQueueSize: 2048,
EmitterBatchProcessor: true,
// OTel message log exporter retry config
LogRetryConfig: nil,
// Trace
Expand All @@ -39,8 +42,11 @@ func ExampleConfig() {
// OTel metric exporter retry config
MetricRetryConfig: nil,
// Log
LogExportTimeout: 1 * time.Second,
LogBatchProcessor: true,
LogExportTimeout: 1 * time.Second,
LogExportMaxBatchSize: 512,
LogExportInterval: 1 * time.Second,
LogMaxQueueSize: 2048,
LogBatchProcessor: true,
}
fmt.Printf("%+v\n", config)
config.LogRetryConfig = &beholder.RetryConfig{
Expand Down
10 changes: 8 additions & 2 deletions pkg/beholder/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ func newHTTPClient(cfg Config, otlploghttpNew otlploghttpFactory) (*Client, erro
if cfg.LogBatchProcessor {
loggerProcessor = sdklog.NewBatchProcessor(
sharedLogExporter,
sdklog.WithExportTimeout(cfg.LogExportTimeout), // Default is 30s
sdklog.WithExportTimeout(cfg.LogExportTimeout), // Default is 30s
sdklog.WithExportMaxBatchSize(cfg.LogExportMaxBatchSize), // Default is 512, must be <= maxQueueSize
sdklog.WithExportInterval(cfg.LogExportInterval), // Default is 1s
sdklog.WithMaxQueueSize(cfg.LogMaxQueueSize), // Default is 2048
)
} else {
loggerProcessor = sdklog.NewSimpleProcessor(sharedLogExporter)
Expand Down Expand Up @@ -119,7 +122,10 @@ func newHTTPClient(cfg Config, otlploghttpNew otlploghttpFactory) (*Client, erro
if cfg.EmitterBatchProcessor {
messageLogProcessor = sdklog.NewBatchProcessor(
sharedLogExporter,
sdklog.WithExportTimeout(cfg.EmitterExportTimeout), // Default is 30s
sdklog.WithExportTimeout(cfg.EmitterExportTimeout), // Default is 30s
sdklog.WithExportMaxBatchSize(cfg.EmitterExportMaxBatchSize), // Default is 512, must be <= maxQueueSize
sdklog.WithExportInterval(cfg.EmitterExportInterval), // Default is 1s
sdklog.WithMaxQueueSize(cfg.EmitterMaxQueueSize), // Default is 2048
)
} else {
messageLogProcessor = sdklog.NewSimpleProcessor(sharedLogExporter)
Expand Down

0 comments on commit 39e2ca6

Please sign in to comment.