Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing unused tracing package #1207

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions quesma/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"context"
"fmt"
"github.com/QuesmaOrg/quesma/quesma/stats/errorstats"
asyncQueryTracing "github.com/QuesmaOrg/quesma/quesma/tracing"
quesma_v2 "github.com/QuesmaOrg/quesma/quesma/v2/core"
"github.com/rs/zerolog"
"io"
Expand Down Expand Up @@ -41,7 +40,7 @@ const (
)

// InitLogger returns channel where log messages will be sent
func InitLogger(cfg Configuration, sig chan os.Signal, doneCh chan struct{}, asyncQueryTraceLogger *asyncQueryTracing.AsyncTraceLogger) <-chan LogWithLevel {
func InitLogger(cfg Configuration, sig chan os.Signal, doneCh chan struct{}) <-chan LogWithLevel {
zerolog.TimeFieldFormat = time.RFC3339Nano // without this we don't have milliseconds timestamp precision
var output io.Writer = zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.StampMilli}
if os.Getenv("GO_ENV") == "production" { // ConsoleWriter is slow, disable it in production
Expand Down Expand Up @@ -97,9 +96,6 @@ func InitLogger(cfg Configuration, sig chan os.Signal, doneCh chan struct{}, asy

globalError := errorstats.GlobalErrorHook{}
l = l.Hook(&globalError)
if asyncQueryTraceLogger != nil {
l = l.Hook(asyncQueryTraceLogger)
}

l.Info().Msgf("Logger initialized with level %s", cfg.Level)

Expand Down
12 changes: 1 addition & 11 deletions quesma/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ import (
"github.com/QuesmaOrg/quesma/quesma/logger"
"github.com/QuesmaOrg/quesma/quesma/persistence"
"github.com/QuesmaOrg/quesma/quesma/quesma"
"github.com/QuesmaOrg/quesma/quesma/quesma/async_search_storage"
"github.com/QuesmaOrg/quesma/quesma/quesma/config"
"github.com/QuesmaOrg/quesma/quesma/quesma/ui"
"github.com/QuesmaOrg/quesma/quesma/schema"
"github.com/QuesmaOrg/quesma/quesma/table_resolver"
"github.com/QuesmaOrg/quesma/quesma/telemetry"
"github.com/QuesmaOrg/quesma/quesma/tracing"
"log"
"os"
"os/signal"
Expand Down Expand Up @@ -75,16 +73,14 @@ func main() {
log.Fatalf("error validating configuration: %v", err)
}

var asyncQueryTraceLogger *tracing.AsyncTraceLogger

licenseMod := licensing.Init(&cfg)
qmcLogChannel := logger.InitLogger(logger.Configuration{
FileLogging: cfg.Logging.FileLogging,
Path: cfg.Logging.Path,
RemoteLogDrainUrl: cfg.Logging.RemoteLogDrainUrl.ToUrl(),
Level: *cfg.Logging.Level,
ClientId: licenseMod.License.ClientID,
}, sig, doneCh, asyncQueryTraceLogger)
}, sig, doneCh)
defer logger.StdLogFile.Close()
defer logger.ErrLogFile.Close()
go func() {
Expand All @@ -93,12 +89,6 @@ func main() {
}
}()

if asyncQueryTraceLogger != nil {
asyncQueryTraceEvictor := async_search_storage.AsyncQueryTraceLoggerEvictor{AsyncQueryTrace: asyncQueryTraceLogger.AsyncQueryTrace}
asyncQueryTraceEvictor.Start()
defer asyncQueryTraceEvictor.Stop()
}

var connectionPool = clickhouse.InitDBConnectionPool(&cfg)

phoneHomeAgent := telemetry.NewPhoneHomeAgent(&cfg, connectionPool, licenseMod.License.ClientID)
Expand Down
57 changes: 0 additions & 57 deletions quesma/quesma/async_search_storage/in_memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"context"
"github.com/QuesmaOrg/quesma/quesma/logger"
"github.com/QuesmaOrg/quesma/quesma/quesma/recovery"
"github.com/QuesmaOrg/quesma/quesma/tracing"
"github.com/QuesmaOrg/quesma/quesma/util"
"strings"
"time"
Expand Down Expand Up @@ -130,59 +129,3 @@ func (e *AsyncQueriesEvictor) Close() {
e.cancel()
logger.Info().Msg("AsyncQueriesEvictor Stopped")
}

type AsyncQueryTraceLoggerEvictor struct {
AsyncQueryTrace *util.SyncMap[string, tracing.TraceCtx]
ctx context.Context
cancel context.CancelFunc
}

func (e *AsyncQueryTraceLoggerEvictor) Start() {
e.ctx, e.cancel = context.WithCancel(context.Background())

go e.FlushHangingAsyncQueryTrace(elapsedTime)
}

func (e *AsyncQueryTraceLoggerEvictor) Stop() {
e.cancel()
logger.Info().Msg("AsyncQueryTraceLoggerEvictor Stopped")
}

func (e *AsyncQueryTraceLoggerEvictor) TryFlushHangingAsyncQueryTrace(timeFun func(time.Time) time.Duration) {
asyncIds := []string{}
e.AsyncQueryTrace.Range(func(key string, value tracing.TraceCtx) bool {
if timeFun(value.Added) > EvictionInterval {
asyncIds = append(asyncIds, key)
logger.Error().Msgf("Async query %s was not finished", key)
var formattedLines strings.Builder
formattedLines.WriteString(tracing.FormatMessages(value.Messages))
logger.Info().Msg(formattedLines.String())
}
return true
})
for _, asyncId := range asyncIds {
e.AsyncQueryTrace.Delete(asyncId)
}
}

func (e *AsyncQueryTraceLoggerEvictor) FlushHangingAsyncQueryTrace(timeFun func(time.Time) time.Duration) {
go func() {
defer recovery.LogPanic()
for {
select {
case <-time.After(GCInterval):
e.TryFlushHangingAsyncQueryTrace(timeFun)
case <-e.ctx.Done():
logger.Debug().Msg("AsyncQueryTraceLoggerEvictor stopped")
e.AsyncQueryTrace.Range(func(key string, value tracing.TraceCtx) bool {
logger.Error().Msgf("Async query %s was not finished", key)
var formattedLines strings.Builder
formattedLines.WriteString(tracing.FormatMessages(value.Messages))
logger.Info().Msg(formattedLines.String())
return true
})
return
}
}
}()
}
96 changes: 0 additions & 96 deletions quesma/tracing/async_trace_logger.go

This file was deleted.

53 changes: 0 additions & 53 deletions quesma/tracing/async_trace_logger_test.go

This file was deleted.

Loading