From c883c353a04439f376a7e9f971bbcb3cb67825a9 Mon Sep 17 00:00:00 2001 From: Carson Ip Date: Tue, 14 Jan 2025 17:13:24 +0000 Subject: [PATCH] Sort imports, remove logger.go --- .../sampling/eventstorage/logger.go | 50 ------------------- .../sampling/eventstorage/storage.go | 1 + .../sampling/eventstorage/storage_manager.go | 1 + 3 files changed, 2 insertions(+), 50 deletions(-) delete mode 100644 x-pack/apm-server/sampling/eventstorage/logger.go diff --git a/x-pack/apm-server/sampling/eventstorage/logger.go b/x-pack/apm-server/sampling/eventstorage/logger.go deleted file mode 100644 index 695a68e8a78..00000000000 --- a/x-pack/apm-server/sampling/eventstorage/logger.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License 2.0; -// you may not use this file except in compliance with the Elastic License 2.0. - -package eventstorage - -import ( - "fmt" - "sync" - - "github.com/elastic/elastic-agent-libs/logp" -) - -// LogpAdaptor adapts logp.Logger to the badger.Logger interface. -type LogpAdaptor struct { - *logp.Logger - - mu sync.RWMutex - last string -} - -// Errorf prints the log message when the current message isn't the same as the -// previously logged message. -func (a *LogpAdaptor) Errorf(format string, args ...interface{}) { - msg := fmt.Sprintf(format, args...) - if a.setLast(msg) { - a.Logger.Errorf(format, args...) - } -} - -func (a *LogpAdaptor) setLast(msg string) bool { - a.mu.RLock() - if msg != a.last { - a.mu.RUnlock() - return false - } - a.mu.RUnlock() - a.mu.Lock() - defer a.mu.Unlock() - shouldSet := msg != a.last - if shouldSet { - a.last = msg - } - return shouldSet -} - -// Warningf adapts badger.Logger.Warningf to logp.Logger.Warngf. -func (a *LogpAdaptor) Warningf(format string, args ...interface{}) { - a.Warnf(format, args...) -} diff --git a/x-pack/apm-server/sampling/eventstorage/storage.go b/x-pack/apm-server/sampling/eventstorage/storage.go index 8936dea0804..70f57b8e1b7 100644 --- a/x-pack/apm-server/sampling/eventstorage/storage.go +++ b/x-pack/apm-server/sampling/eventstorage/storage.go @@ -12,6 +12,7 @@ import ( "time" "github.com/cockroachdb/pebble" + "github.com/elastic/apm-data/model/modelpb" ) diff --git a/x-pack/apm-server/sampling/eventstorage/storage_manager.go b/x-pack/apm-server/sampling/eventstorage/storage_manager.go index aa0888cee4a..911feb81a62 100644 --- a/x-pack/apm-server/sampling/eventstorage/storage_manager.go +++ b/x-pack/apm-server/sampling/eventstorage/storage_manager.go @@ -12,6 +12,7 @@ import ( "time" "github.com/cockroachdb/pebble" + "github.com/elastic/apm-data/model/modelpb" "github.com/elastic/apm-server/internal/logs" "github.com/elastic/elastic-agent-libs/logp"