Skip to content

Commit

Permalink
Logging refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mantzas committed Oct 25, 2024
1 parent c24c071 commit bebbeba
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion component/amqp/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ var (
)

func TestMain(m *testing.M) {
os.Setenv("OTEL_BSP_SCHEDULE_DELAY", "100")
if err := os.Setenv("OTEL_BSP_SCHEDULE_DELAY", "100"); err != nil {
panic(err)
}

tracePublisher = patrontrace.Setup("test", nil, traceExporter)

Expand Down
6 changes: 4 additions & 2 deletions component/kafka/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ var (
)

func TestMain(m *testing.M) {
os.Setenv("OTEL_BSP_SCHEDULE_DELAY", "100")
if err := os.Setenv("OTEL_BSP_SCHEDULE_DELAY", "100"); err != nil {
panic(err)
}

tracePublisher = patrontrace.Setup("test", nil, traceExporter)
os.Exit(m.Run())
Expand All @@ -39,7 +41,7 @@ func TestNew(t *testing.T) {
// consumer will commit every batch in a blocking operation
saramaCfg.Consumer.Offsets.AutoCommit.Enable = false
saramaCfg.Consumer.Offsets.Initial = sarama.OffsetOldest
saramaCfg.Consumer.Group.Rebalance.Strategy = sarama.BalanceStrategySticky
saramaCfg.Consumer.Group.Rebalance.GroupStrategies = append(saramaCfg.Consumer.Group.Rebalance.GroupStrategies, sarama.NewBalanceStrategySticky())
saramaCfg.Net.DialTimeout = 15 * time.Second
saramaCfg.Version = sarama.V2_6_0_0

Expand Down
4 changes: 3 additions & 1 deletion component/sqs/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ var (
)

func TestMain(m *testing.M) {
os.Setenv("OTEL_BSP_SCHEDULE_DELAY", "100")
if err := os.Setenv("OTEL_BSP_SCHEDULE_DELAY", "100"); err != nil {
panic(err)
}

tracePublisher = patrontrace.Setup("test", nil, traceExporter)

Expand Down
4 changes: 2 additions & 2 deletions component/sqs/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func init() {
messageQueueSizeGauge = patronmetric.Float64Gauge(packageName, "sqs.queue.size", "SQS message queue size.", "1")
}

func observerMessageAge(ctx context.Context, queue string, attributes map[string]string) {
attribute, ok := attributes[sqsAttributeSentTimestamp]
func observerMessageAge(ctx context.Context, queue string, attrs map[string]string) {
attribute, ok := attrs[sqsAttributeSentTimestamp]
if !ok || len(strings.TrimSpace(attribute)) == 0 {
return
}
Expand Down
4 changes: 2 additions & 2 deletions examples/service/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ func createHttpRouter() (patron.Component, error) {
return nil, fmt.Errorf("failed to create routes: %w", err)
}

router, err := router.New(router.WithRoutes(rr...))
rt, err := router.New(router.WithRoutes(rr...))
if err != nil {
return nil, fmt.Errorf("failed to create http router: %w", err)
}

return patronhttp.New(router)
return patronhttp.New(rt)
}

0 comments on commit bebbeba

Please sign in to comment.