Skip to content

Commit

Permalink
Add testcase for console
Browse files Browse the repository at this point in the history
  • Loading branch information
robinknaapen committed Jul 3, 2024
1 parent 9ffa0b6 commit 9299fee
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions config/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp"
"go.opentelemetry.io/otel/exporters/stdout/stdoutlog"
"go.opentelemetry.io/otel/log"
"go.opentelemetry.io/otel/log/noop"
sdklog "go.opentelemetry.io/otel/sdk/log"
Expand Down Expand Up @@ -59,8 +60,15 @@ func TestLoggerProvider(t *testing.T) {

func TestLogProcessor(t *testing.T) {
ctx := context.Background()

otlpHTTPExporter, err := otlploghttp.New(ctx)
require.NoError(t, err)

consoleExporter, err := stdoutlog.New(
stdoutlog.WithPrettyPrint(),
)
require.NoError(t, err)

testCases := []struct {
name string
processor LogRecordProcessor
Expand Down Expand Up @@ -149,6 +157,21 @@ func TestLogProcessor(t *testing.T) {
},
wantErr: errors.New("no valid log exporter"),
},
{
name: "batch/console",
processor: LogRecordProcessor{
Batch: &BatchLogRecordProcessor{
MaxExportBatchSize: ptr(0),
ExportTimeout: ptr(0),
MaxQueueSize: ptr(0),
ScheduleDelay: ptr(0),
Exporter: LogRecordExporter{
Console: map[string]any{},
},
},
},
wantProcessor: sdklog.NewBatchProcessor(consoleExporter),
},
{
name: "batch/otlp-http-exporter",
processor: LogRecordProcessor{
Expand Down Expand Up @@ -341,6 +364,17 @@ func TestLogProcessor(t *testing.T) {
},
wantErr: errors.New("no valid log exporter"),
},
{
name: "simple/console",
processor: LogRecordProcessor{
Simple: &SimpleLogRecordProcessor{
Exporter: LogRecordExporter{
Console: map[string]any{},
},
},
},
wantProcessor: sdklog.NewSimpleProcessor(consoleExporter),
},
{
name: "simple/otlp-exporter",
processor: LogRecordProcessor{
Expand Down

0 comments on commit 9299fee

Please sign in to comment.