From fb1a0f9f128861deaa2a815f2e1ef807ba956a54 Mon Sep 17 00:00:00 2001 From: shantanualshi Date: Fri, 29 Nov 2024 11:50:14 +0530 Subject: [PATCH 01/13] refactor: refactor generator implementation --- generator/generator.go | 135 +++++++++++----------------------- generator/log/app-logger.go | 44 +++++++++++ generator/log/logger.go | 22 ++++++ generator/{ => log}/values.go | 44 +++++------ generator/main.go | 9 ++- 5 files changed, 136 insertions(+), 118 deletions(-) create mode 100644 generator/log/app-logger.go create mode 100644 generator/log/logger.go rename generator/{ => log}/values.go (76%) diff --git a/generator/generator.go b/generator/generator.go index 9721b726..551effd7 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -7,115 +7,66 @@ import ( "time" "github.com/cyriltovena/loki-log-generator/flog" + "github.com/cyriltovena/loki-log-generator/log" "github.com/grafana/loki/pkg/push" "github.com/prometheus/common/model" ) -type AppLogger struct { - labels model.LabelSet - levels map[model.LabelValue]model.LabelSet - logger Logger -} - -func (app *AppLogger) Log(level model.LabelValue, t time.Time, message string) { - labels, ok := app.levels[level] - if !ok { - labels = app.labels - } - _ = app.logger.Handle(labels, t, message) -} - -func (app *AppLogger) LogWithMetadata(level model.LabelValue, t time.Time, message string, metadata push.LabelsAdapter) { - labels, ok := app.levels[level] - if !ok { - labels = app.labels - } - _ = app.logger.HandleWithMetadata(labels, t, message, metadata) -} - -type Logger interface { - Handle(labels model.LabelSet, timestamp time.Time, message string) error - HandleWithMetadata(labels model.LabelSet, timestamp time.Time, message string, metadata push.LabelsAdapter) error -} - -type LoggerFunc func(labels model.LabelSet, timestamp time.Time, message string, metadata push.LabelsAdapter) error - -func (f LoggerFunc) Handle(labels model.LabelSet, timestamp time.Time, message string) error { - return f(labels, timestamp, message, nil) -} -func (f LoggerFunc) HandleWithMetadata(labels model.LabelSet, timestamp time.Time, message string, metadata push.LabelsAdapter) error { - return f(labels, timestamp, message, metadata) -} - -func NewAppLogger(labels model.LabelSet, logger Logger) *AppLogger { - levels := map[model.LabelValue]model.LabelSet{ - DEBUG: labels.Merge(model.LabelSet{"level": DEBUG}), - INFO: labels.Merge(model.LabelSet{"level": INFO}), - WARN: labels.Merge(model.LabelSet{"level": WARN}), - ERROR: labels.Merge(model.LabelSet{"level": ERROR}), - } - return &AppLogger{ - labels: labels, - levels: levels, - logger: logger, - } -} - -type LogGenerator func(ctx context.Context, logger *AppLogger, metadata push.LabelsAdapter) +type LogGenerator func(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) var generators = map[model.LabelValue]map[model.LabelValue]LogGenerator{ "gateway": { - "apache": func(ctx context.Context, logger *AppLogger, metadata push.LabelsAdapter) { + "apache": func(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { go func() { for ctx.Err() == nil { - level := randLevel() + level := log.RandLevel() t := time.Now() - logger.LogWithMetadata(level, t, flog.NewApacheCommonLog(t, randURI(), statusFromLevel(level)), metadata) + logger.LogWithMetadata(level, t, flog.NewApacheCommonLog(t, log.RandURI(), statusFromLevel(level)), metadata) time.Sleep(time.Duration(rand.Intn(5000)) * time.Millisecond) } }() }, - "httpd": func(ctx context.Context, logger *AppLogger, metadata push.LabelsAdapter) { + "httpd": func(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { go func() { for ctx.Err() == nil { - level := randLevel() + level := log.RandLevel() t := time.Now() - logger.LogWithMetadata(level, t, flog.NewApacheCombinedLog(t, randURI(), statusFromLevel(level)), metadata) + logger.LogWithMetadata(level, t, flog.NewApacheCombinedLog(t, log.RandURI(), statusFromLevel(level)), metadata) time.Sleep(time.Duration(rand.Intn(5000)) * time.Millisecond) } }() }, - "nginx": func(ctx context.Context, logger *AppLogger, metadata push.LabelsAdapter) { + "nginx": func(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { go func() { for ctx.Err() == nil { - level := randLevel() + level := log.RandLevel() t := time.Now() - logger.LogWithMetadata(level, t, flog.NewCommonLogFormat(t, randURI(), statusFromLevel(level)), metadata) + logger.LogWithMetadata(level, t, flog.NewCommonLogFormat(t, log.RandURI(), statusFromLevel(level)), metadata) time.Sleep(time.Duration(rand.Intn(5000)) * time.Millisecond) } }() }, - "nginx-json": func(ctx context.Context, logger *AppLogger, metadata push.LabelsAdapter) { + "nginx-json": func(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { go func() { for ctx.Err() == nil { - level := randLevel() + level := log.RandLevel() t := time.Now() - logger.LogWithMetadata(level, t, flog.NewJSONLogFormat(t, randURI(), statusFromLevel(level)), metadata) + logger.LogWithMetadata(level, t, flog.NewJSONLogFormat(t, log.RandURI(), statusFromLevel(level)), metadata) time.Sleep(time.Duration(rand.Intn(5000)) * time.Millisecond) } }() }, - "nginx-json-mixed": func(ctx context.Context, logger *AppLogger, metadata push.LabelsAdapter) { + "nginx-json-mixed": func(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { go func() { for ctx.Err() == nil { - level := randLevel() + level := log.RandLevel() t := time.Now() - if level == ERROR { - log := flog.NewCommonLogFormat(t, randURI(), statusFromLevel(level)) + if level == log.ERROR { + log := flog.NewCommonLogFormat(t, log.RandURI(), statusFromLevel(level)) // Add a stacktrace to the logfmt log, and include a field that will conflict with stream selectors logger.LogWithMetadata(level, t, fmt.Sprintf("%s %s", log, `method=GET namespace=whoopsie caller=flush.go:253 stacktrace="Exception in thread \"main\" java.lang.NullPointerException\n at com.example.myproject.Book.getTitle(Book.java:16)\n at com.example.myproject.Author.getBookTitles(Author.java:25)\n at com.example.myproject.Bootstrap.main(Bootstrap.java:14)"`), metadata) } - logger.LogWithMetadata(level, t, flog.NewJSONLogFormat(t, randURI(), statusFromLevel(level)), metadata) + logger.LogWithMetadata(level, t, flog.NewJSONLogFormat(t, log.RandURI(), statusFromLevel(level)), metadata) time.Sleep(time.Duration(rand.Intn(5000)) * time.Millisecond) } }() @@ -141,7 +92,7 @@ var generators = map[model.LabelValue]map[model.LabelValue]LogGenerator{ }, } -var noisyTempo = func(ctx context.Context, logger *AppLogger, metadata push.LabelsAdapter) { +var noisyTempo = func(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { const fmt1 = `level=debug ts=%s caller=broadcast.go:48 msg="Invalidating forwarded broadcast" key=collectors/compactor version=%d oldVersion=%d content=[compactor-%s] oldContent=[compactor-%s]` const fmt2 = `level=warn ts=%s caller=instance.go:43 msg="TRACE_TOO_LARGE: max size of trace (52428800) exceeded tenant %s"` const fmt3 = `level=info ts=%s caller=compactor.go:242 msg="flushed to block" bytes=%dB objects=%d values=%d` @@ -153,74 +104,74 @@ var noisyTempo = func(ctx context.Context, logger *AppLogger, metadata push.Labe go func() { for ctx.Err() == nil { t := time.Now() - logger.LogWithMetadata(DEBUG, t, fmt.Sprintf(fmt1, t.Format(time.RFC3339Nano), rand.Intn(100), rand.Intn(100), randSeq(5), randSeq(5)), metadata) + logger.LogWithMetadata(log.DEBUG, t, fmt.Sprintf(fmt1, t.Format(time.RFC3339Nano), rand.Intn(100), rand.Intn(100), log.RandSeq(5), log.RandSeq(5)), metadata) time.Sleep(time.Duration(rand.Intn(1000)) * time.Millisecond) } }() go func() { for ctx.Err() == nil { t := time.Now() - logger.LogWithMetadata(WARN, t, fmt.Sprintf(fmt2, t.Format(time.RFC3339Nano), randOrgID()), metadata) + logger.LogWithMetadata(log.WARN, t, fmt.Sprintf(fmt2, t.Format(time.RFC3339Nano), log.RandOrgID()), metadata) time.Sleep(time.Duration(rand.Intn(3000)) * time.Millisecond) } }() go func() { for ctx.Err() == nil { t := time.Now() - logger.LogWithMetadata(INFO, t, fmt.Sprintf(fmt3, t.Format(time.RFC3339Nano), rand.Intn(1000), rand.Intn(1000), rand.Intn(1000)), metadata) + logger.LogWithMetadata(log.INFO, t, fmt.Sprintf(fmt3, t.Format(time.RFC3339Nano), rand.Intn(1000), rand.Intn(1000), rand.Intn(1000)), metadata) time.Sleep(time.Duration(rand.Intn(4000)) * time.Millisecond) } }() go func() { for ctx.Err() == nil { t := time.Now() - logger.LogWithMetadata(INFO, t, fmt.Sprintf(fmt4, t.Format(time.RFC3339Nano), rand.Intn(1000)), metadata) + logger.LogWithMetadata(log.INFO, t, fmt.Sprintf(fmt4, t.Format(time.RFC3339Nano), rand.Intn(1000)), metadata) time.Sleep(time.Duration(rand.Intn(7000)) * time.Millisecond) } }() go func() { for ctx.Err() == nil { t := time.Now() - logger.LogWithMetadata(INFO, t, fmt.Sprintf(fmt5, t.Format(time.RFC3339Nano), randOrgID(), randSeq(5)), metadata) + logger.LogWithMetadata(log.INFO, t, fmt.Sprintf(fmt5, t.Format(time.RFC3339Nano), log.RandOrgID(), log.RandSeq(5)), metadata) time.Sleep(time.Duration(rand.Intn(1000)) * time.Millisecond) } }() go func() { for ctx.Err() == nil { t := time.Now() - logger.LogWithMetadata(ERROR, t, fmt.Sprintf(fmt6, t.Format(time.RFC3339Nano), flog.FakeIP()), metadata) + logger.LogWithMetadata(log.ERROR, t, fmt.Sprintf(fmt6, t.Format(time.RFC3339Nano), flog.FakeIP()), metadata) time.Sleep(time.Duration(rand.Intn(2000)) * time.Millisecond) } }() go func() { for ctx.Err() == nil { t := time.Now() - logger.LogWithMetadata(INFO, t, fmt.Sprintf(fmt7, t.Format(time.RFC3339Nano), randOrgID(), rand.Intn(1000)), metadata) + logger.LogWithMetadata(log.INFO, t, fmt.Sprintf(fmt7, t.Format(time.RFC3339Nano), log.RandOrgID(), rand.Intn(1000)), metadata) time.Sleep(time.Duration(rand.Intn(5000)) * time.Millisecond) } }() go func() { for ctx.Err() == nil { t := time.Now() - logger.LogWithMetadata(INFO, t, fmt.Sprintf(fmt8, t.Format(time.RFC3339Nano)), metadata) + logger.LogWithMetadata(log.INFO, t, fmt.Sprintf(fmt8, t.Format(time.RFC3339Nano)), metadata) time.Sleep(20 * time.Second) } }() } -var mimirPod = func(ctx context.Context, logger *AppLogger, metadata push.LabelsAdapter) { +var mimirPod = func(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { go func() { for ctx.Err() == nil { t := time.Now() - logger.LogWithMetadata(INFO, t, mimirGRPCLog("", "/cortex.Ingester/Push"), metadata) + logger.LogWithMetadata(log.INFO, t, mimirGRPCLog("", "/cortex.Ingester/Push"), metadata) time.Sleep(time.Duration(rand.Intn(5000)) * time.Millisecond) } }() } -func startFailingMimirPod(ctx context.Context, logger Logger) { - appLogger := NewAppLogger(model.LabelSet{ - "cluster": model.LabelValue(clusters[0]), +func startFailingMimirPod(ctx context.Context, logger log.Logger) { + appLogger := log.NewAppLogger(model.LabelSet{ + "cluster": model.LabelValue(log.Clusters[0]), "namespace": model.LabelValue("mimir"), "service_name": "mimir-ingester", }, logger) @@ -228,14 +179,14 @@ func startFailingMimirPod(ctx context.Context, logger Logger) { go func() { for ctx.Err() == nil { t := time.Now() - appLogger.LogWithMetadata(ERROR, t, mimirGRPCLog("connection refused to object store", "/cortex.Ingester/Push"), randStructuredMetadata("mimir-ingester")) + appLogger.LogWithMetadata(log.ERROR, t, mimirGRPCLog("connection refused to object store", "/cortex.Ingester/Push"), log.RandStructuredMetadata("mimir-ingester")) time.Sleep(time.Duration(rand.Intn(10000)) * time.Millisecond) } }() go func() { for ctx.Err() == nil { t := time.Now() - appLogger.LogWithMetadata(INFO, t, mimirGRPCLog("", "/cortex.Ingester/Push"), randStructuredMetadata("mimir-ingester")) + appLogger.LogWithMetadata(log.INFO, t, mimirGRPCLog("", "/cortex.Ingester/Push"), log.RandStructuredMetadata("mimir-ingester")) time.Sleep(time.Duration(rand.Intn(500)) * time.Millisecond) } }() @@ -247,11 +198,11 @@ const ( ) func mimirGRPCLog(err string, path string) string { - level := INFO - org := randOrgID() + level := log.INFO + org := log.RandOrgID() if err != "" { - level = ERROR - org = orgIDs[rand.Intn(len(orgIDs[2:]))] + level = log.ERROR + org = log.OrgIDs[rand.Intn(len(log.OrgIDs[2:]))] } log := fmt.Sprintf( @@ -260,7 +211,7 @@ func mimirGRPCLog(err string, path string) string { org, level, path, - randDuration(), + log.RandDuration(), ) if err != "" { log += ` err="` + err + `"` @@ -271,11 +222,11 @@ func mimirGRPCLog(err string, path string) string { func statusFromLevel(level model.LabelValue) int { switch level { - case INFO: + case log.INFO: return 200 - case WARN: + case log.WARN: return 400 - case ERROR: + case log.ERROR: return 500 default: return 200 diff --git a/generator/log/app-logger.go b/generator/log/app-logger.go new file mode 100644 index 00000000..9c8eb8d5 --- /dev/null +++ b/generator/log/app-logger.go @@ -0,0 +1,44 @@ +package log + +import ( + "time" + + "github.com/grafana/loki/pkg/push" + "github.com/prometheus/common/model" +) + +type AppLogger struct { + labels model.LabelSet + levels map[model.LabelValue]model.LabelSet + logger Logger +} + +func NewAppLogger(labels model.LabelSet, logger Logger) *AppLogger { + levels := map[model.LabelValue]model.LabelSet{ + DEBUG: labels.Merge(model.LabelSet{"level": DEBUG}), + INFO: labels.Merge(model.LabelSet{"level": INFO}), + WARN: labels.Merge(model.LabelSet{"level": WARN}), + ERROR: labels.Merge(model.LabelSet{"level": ERROR}), + } + return &AppLogger{ + labels: labels, + levels: levels, + logger: logger, + } +} + +func (app *AppLogger) Log(level model.LabelValue, t time.Time, message string) { + labels, ok := app.levels[level] + if !ok { + labels = app.labels + } + _ = app.logger.Handle(labels, t, message) +} + +func (app *AppLogger) LogWithMetadata(level model.LabelValue, t time.Time, message string, metadata push.LabelsAdapter) { + labels, ok := app.levels[level] + if !ok { + labels = app.labels + } + _ = app.logger.HandleWithMetadata(labels, t, message, metadata) +} diff --git a/generator/log/logger.go b/generator/log/logger.go new file mode 100644 index 00000000..0073f425 --- /dev/null +++ b/generator/log/logger.go @@ -0,0 +1,22 @@ +package log + +import ( + "time" + + "github.com/grafana/loki/pkg/push" + "github.com/prometheus/common/model" +) + +type Logger interface { + Handle(labels model.LabelSet, timestamp time.Time, message string) error + HandleWithMetadata(labels model.LabelSet, timestamp time.Time, message string, metadata push.LabelsAdapter) error +} + +type LoggerFunc func(labels model.LabelSet, timestamp time.Time, message string, metadata push.LabelsAdapter) error + +func (f LoggerFunc) Handle(labels model.LabelSet, timestamp time.Time, message string) error { + return f(labels, timestamp, message, nil) +} +func (f LoggerFunc) HandleWithMetadata(labels model.LabelSet, timestamp time.Time, message string, metadata push.LabelsAdapter) error { + return f(labels, timestamp, message, metadata) +} diff --git a/generator/values.go b/generator/log/values.go similarity index 76% rename from generator/values.go rename to generator/log/values.go index 9b1052b1..4cd206cc 100644 --- a/generator/values.go +++ b/generator/log/values.go @@ -1,16 +1,16 @@ -package main +package log import ( "math/rand" "strings" "time" - gofakeit "github.com/brianvoe/gofakeit/v7" + "github.com/brianvoe/gofakeit/v7" "github.com/grafana/loki/pkg/push" "github.com/prometheus/common/model" ) -var clusters = []string{ +var Clusters = []string{ "us-west-1", "us-east-1", "us-east-2", @@ -79,12 +79,12 @@ var level = []model.LabelValue{ ERROR, } -var orgIDs = []string{"1218", "29", "1010", "2419", "2919"} -var userIDs = []string{"14234", "03428", "10572", "94223", "08203", "93820", "12345", "54321", "67890"} +var OrgIDs = []string{"1218", "29", "1010", "2419", "2919"} +var UserIDs = []string{"14234", "03428", "10572", "94223", "08203", "93820", "12345", "54321", "67890"} var defaultTraceId = gofakeit.UUID() -func randLevel() model.LabelValue { +func RandLevel() model.LabelValue { r := rand.Intn(100) if r < 5 { return ERROR @@ -95,13 +95,13 @@ func randLevel() model.LabelValue { } } -func randURI() string { +func RandURI() string { return URI[rand.Intn(len(URI))] } func ForAllClusters(namespace, svc model.LabelValue, cb func(model.LabelSet, push.LabelsAdapter)) { podCount := rand.Intn(10) + 1 - for _, cluster := range clusters { + for _, cluster := range Clusters { for i := 0; i < podCount; i++ { clusterInt := 0 for _, char := range cluster { @@ -114,12 +114,12 @@ func ForAllClusters(namespace, svc model.LabelValue, cb func(model.LabelSet, pus "__stream_shard__": model.LabelValue(shards[clusterInt%len(shards)]), "namespace": model.LabelValue(namespace), "service_name": svc, - }, randStructuredMetadata(string(svc))) + }, RandStructuredMetadata(string(svc))) } } } -func randSeq(n int) string { +func RandSeq(n int) string { letters := []rune("abcdefghijklmnopqrstuvwxyz0123456789") b := make([]rune, n) for i := range b { @@ -128,15 +128,15 @@ func randSeq(n int) string { return string(b) } -func randOrgID() string { - return orgIDs[rand.Intn(len(orgIDs))] +func RandOrgID() string { + return OrgIDs[rand.Intn(len(OrgIDs))] } -func randUserID() string { - return userIDs[rand.Intn(len(userIDs))] +func RandUserID() string { + return UserIDs[rand.Intn(len(UserIDs))] } -func randError() string { +func RandError() string { switch rand.Intn(10) { case 0: return gofakeit.ErrorDatabase().Error() @@ -155,15 +155,15 @@ func randError() string { var filesNames = []string{gofakeit.ProductName(), gofakeit.ProductName(), gofakeit.ProductName(), gofakeit.Word(), gofakeit.Word()} -func randFileName() string { +func RandFileName() string { return strings.ReplaceAll(strings.ToLower(filesNames[rand.Intn(len(filesNames))]), " ", "_") } -func randDuration() string { +func RandDuration() string { return (time.Duration(gofakeit.Number(1, 30000)) * time.Millisecond).String() } -func randTraceID(prevTrace string) string { +func RandTraceID(prevTrace string) string { // 50% chance to use `prevTrace` if it is set if prevTrace != "" && rand.Intn(2) == 0 { return prevTrace @@ -174,10 +174,10 @@ func randTraceID(prevTrace string) string { return newTrace } -func randStructuredMetadata(svc string) push.LabelsAdapter { +func RandStructuredMetadata(svc string) push.LabelsAdapter { return push.LabelsAdapter{ - push.LabelAdapter{Name: "traceID", Value: randTraceID(defaultTraceId)}, - push.LabelAdapter{Name: "pod", Value: svc + "-" + randSeq(5)}, - push.LabelAdapter{Name: "user", Value: randUserID()}, + push.LabelAdapter{Name: "traceID", Value: RandTraceID(defaultTraceId)}, + push.LabelAdapter{Name: "pod", Value: svc + "-" + RandSeq(5)}, + push.LabelAdapter{Name: "user", Value: RandUserID()}, } } diff --git a/generator/main.go b/generator/main.go index 27bf36a5..2955fa38 100644 --- a/generator/main.go +++ b/generator/main.go @@ -8,6 +8,7 @@ import ( "os/signal" "time" + "github.com/cyriltovena/loki-log-generator/log" "github.com/grafana/loki-client-go/loki" "github.com/grafana/loki/pkg/push" "github.com/prometheus/common/model" @@ -31,9 +32,9 @@ func main() { } defer client.Stop() - var logger Logger = client + var logger log.Logger = client if *dry { - logger = LoggerFunc(func(labels model.LabelSet, timestamp time.Time, message string, metadata push.LabelsAdapter) error { + logger = log.LoggerFunc(func(labels model.LabelSet, timestamp time.Time, message string, metadata push.LabelsAdapter) error { fmt.Println(labels, timestamp, message, metadata) return nil }) @@ -44,12 +45,12 @@ func main() { // Creates and starts all apps. for namespace, apps := range generators { for serviceName, generator := range apps { - ForAllClusters(namespace, serviceName, func(labels model.LabelSet, metadata push.LabelsAdapter) { + log.ForAllClusters(namespace, serviceName, func(labels model.LabelSet, metadata push.LabelsAdapter) { // Remove `metadata` from nginx logs if serviceName == "nginx" { metadata = push.LabelsAdapter{} } - generator(ctx, NewAppLogger(labels, logger), metadata) + generator(ctx, log.NewAppLogger(labels, logger), metadata) }) } } From acdf7df687a624d3a5bd055caa88cb4cb7e4d456 Mon Sep 17 00:00:00 2001 From: shantanualshi Date: Fri, 29 Nov 2024 11:52:03 +0530 Subject: [PATCH 02/13] chore: modify dockerfile to start otel-collector --- generator/Dockerfile | 28 ++++++++++++++++++++++++++-- generator/otel-config.yaml | 28 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 generator/otel-config.yaml diff --git a/generator/Dockerfile b/generator/Dockerfile index 53589ad6..c74ef7a0 100644 --- a/generator/Dockerfile +++ b/generator/Dockerfile @@ -1,14 +1,38 @@ +# Start with the OTEL collector stage +FROM otel/opentelemetry-collector-contrib:latest AS collector +# Final stage FROM golang:1.22 +# Copy the collector binary from the collector stage +COPY --from=collector /otelcol-contrib /otelcol-contrib + WORKDIR /go/src/app +# Copy and build the log generator COPY go.mod go.sum ./ COPY *.go ./ COPY flog/ flog/ RUN go mod download - RUN CGO_ENABLED=0 GOOS=linux go build -o /generator -ENTRYPOINT ["/generator"] +# Copy the OTEL collector config +COPY otel-config.yaml /etc/otel/config.yaml + +# Create a startup script +COPY < Date: Fri, 29 Nov 2024 11:53:02 +0530 Subject: [PATCH 03/13] chore: get go otel dependencies --- generator/go.mod | 33 +++++++++++----- generator/go.sum | 80 +++++++++++++++++++++++++------------- generator/otel-config.yaml | 6 +-- 3 files changed, 78 insertions(+), 41 deletions(-) diff --git a/generator/go.mod b/generator/go.mod index 8bea4f3f..aabef7bb 100644 --- a/generator/go.mod +++ b/generator/go.mod @@ -1,4 +1,4 @@ -module github.com/cyriltovena/loki-log-generator +module github.com/grafana/explore-logs/generator go 1.22 @@ -11,21 +11,32 @@ require ( github.com/grafana/loki/pkg/push v0.0.0-20240912152814-63e84b476a9a github.com/prometheus/common v0.34.0 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.9.0 + go.opentelemetry.io/contrib/bridges/otelslog v0.7.0 + go.opentelemetry.io/otel v1.32.0 + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0 + go.opentelemetry.io/otel/sdk v1.32.0 + go.opentelemetry.io/otel/sdk/log v0.8.0 + google.golang.org/grpc v1.67.1 ) require ( github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dennwc/varint v1.0.0 // indirect github.com/go-kit/kit v0.10.0 // indirect github.com/go-kit/log v0.2.0 // indirect github.com/go-logfmt/logfmt v0.5.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/grafana/regexp v0.0.0-20220304095617-2e8d9baf4ac2 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect github.com/jpillora/backoff v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect @@ -39,17 +50,19 @@ require ( github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/procfs v0.7.3 // indirect github.com/prometheus/prometheus v0.35.0 // indirect + go.opentelemetry.io/otel/log v0.8.0 // indirect + go.opentelemetry.io/otel/metric v1.32.0 // indirect + go.opentelemetry.io/otel/trace v1.32.0 // indirect + go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/goleak v1.1.12 // indirect golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/oauth2 v0.7.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/appengine v1.6.7 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/text v0.20.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.56.3 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/protobuf v1.35.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/generator/go.sum b/generator/go.sum index fefa3283..6802d3d6 100644 --- a/generator/go.sum +++ b/generator/go.sum @@ -171,14 +171,16 @@ github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/checkpoint-restore/go-criu/v4 v4.1.0/go.mod h1:xUQBLp4RLc5zJtWY++yjOoMoB5lihDt7fai+75m+rGw= github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= @@ -430,7 +432,10 @@ github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV github.com/go-logr/logr v1.2.1/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.0/go.mod h1:YkVgnZu1ZjjL7xTxrfm/LLZBfkhTqSR1ydtm6jTKKwI= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-openapi/analysis v0.21.2/go.mod h1:HZwRk4RRisyG8vx2Oe6aqeSQcoxRp47Xkp3+K6q+LdY= github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= @@ -573,8 +578,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-containerregistry v0.5.1/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -604,6 +609,8 @@ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= @@ -638,6 +645,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 h1:ad0vkEBuk23VJzZR9nkLVG0YAoN9coASF1GusYX6AlU= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0/go.mod h1:igFoXX2ELCW06bol23DWPB5BEWfZISOzSP5K2sbLea0= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= @@ -741,8 +750,9 @@ github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -1003,6 +1013,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= @@ -1064,8 +1076,6 @@ github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -1074,9 +1084,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= @@ -1149,6 +1158,8 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opentelemetry.io/contrib v0.20.0/go.mod h1:G/EtFaa6qaN7+LxqfIAT3GiZa7Wv5DTBUzl5H4LY0Kc= +go.opentelemetry.io/contrib/bridges/otelslog v0.7.0 h1:uLoBPCQtxi5eFRryx5yd3DTxOKRQSils1VJUKjFnlSc= +go.opentelemetry.io/contrib/bridges/otelslog v0.7.0/go.mod h1:1nWHCQN5JjEeWriWKuEY9Zycy0P8OHaPV64KudYbaKw= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.20.0/go.mod h1:oVGt1LRbBOBq1A5BQLlUg9UaU/54aiHw8cgjV3aWZ/E= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.28.0/go.mod h1:vEhqr0m4eTc+DWxfsXoXue2GBgV2uUwVznkGIHW/e5w= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.20.0/go.mod h1:2AboqHi0CiIZU0qwhtUfCYD1GeUzvvIXWNkhDt7ZMG4= @@ -1157,30 +1168,46 @@ go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzox go.opentelemetry.io/otel v1.3.0/go.mod h1:PWIKzi6JCp7sM0k9yZ43VX+T345uNbAkDKwHVjb2PTs= go.opentelemetry.io/otel v1.6.0/go.mod h1:bfJD2DZVw0LBxghOTlgnlI0CV3hLDu9XF/QKOUXMTQQ= go.opentelemetry.io/otel v1.6.1/go.mod h1:blzUabWHkX6LJewxvadmzafgh/wnvBSDBdOuwkAtrWQ= +go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= +go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0/go.mod h1:VpP4/RMn8bv8gNo9uK7/IMY4mtWLELsS+JIP0inH0h4= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.6.1/go.mod h1:NEu79Xo32iVb+0gVNV8PMd7GoWqnyDXRlj04yFjqz40= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0 h1:WzNab7hOOLzdDF/EoWCt4glhrbMPVMOO5JYTmpz36Ls= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0/go.mod h1:hKvJwTzJdp90Vh7p6q/9PAOd55dI6WA6sWj62a/JvSs= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.3.0/go.mod h1:hO1KLR7jcKaDDKDkvI9dP/FIhpmna5lkqPUQdEjFAM8= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.6.1/go.mod h1:YJ/JbY5ag/tSQFXzH3mtDmHqzF3aFn3DI/aB1n7pt4w= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.3.0/go.mod h1:keUU7UfnwWTWpJ+FWnyqmogPa82nuU5VUANFq49hlMY= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.6.1/go.mod h1:UJJXJj0rltNIemDMwkOJyggsvyMG9QHfJeFH0HS5JjM= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.3.0/go.mod h1:QNX1aly8ehqqX1LEa6YniTU7VY9I6R3X/oPxhGdTceE= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.6.1/go.mod h1:DAKwdo06hFLc0U88O10x4xnb5sc7dDRDqRuiN+io8JE= +go.opentelemetry.io/otel/log v0.8.0 h1:egZ8vV5atrUWUbnSsHn6vB8R21G2wrKqNiDt3iWertk= +go.opentelemetry.io/otel/log v0.8.0/go.mod h1:M9qvDdUTRCopJcGRKg57+JSQ9LgLBrwwfC32epk5NX8= go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU= go.opentelemetry.io/otel/metric v0.28.0/go.mod h1:TrzsfQAmQaB1PDcdhBauLMk7nyyg9hm+GoQq/ekE9Iw= +go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= +go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw= go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc= go.opentelemetry.io/otel/sdk v1.3.0/go.mod h1:rIo4suHNhQwBIPg9axF8V9CA72Wz2mKF1teNrup8yzs= go.opentelemetry.io/otel/sdk v1.6.1/go.mod h1:IVYrddmFZ+eJqu2k38qD3WezFR2pymCzm8tdxyh3R4E= +go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= +go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/sdk/export/metric v0.20.0/go.mod h1:h7RBNMsDJ5pmI1zExLi+bJK+Dr8NQCh0qGhm1KDnNlE= +go.opentelemetry.io/otel/sdk/log v0.8.0 h1:zg7GUYXqxk1jnGF/dTdLPrK06xJdrXgqgFLnI4Crxvs= +go.opentelemetry.io/otel/sdk/log v0.8.0/go.mod h1:50iXr0UVwQrYS45KbruFrEt4LvAdCaWWgIrsN3ZQggo= go.opentelemetry.io/otel/sdk/metric v0.20.0/go.mod h1:knxiS8Xd4E/N+ZqKmUPf3gTTZ4/0TjTXukfxjzSTpHE= go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw= go.opentelemetry.io/otel/trace v1.3.0/go.mod h1:c/VDhno8888bvQYmbYLqe41/Ldmr/KKunbvWM4/fEjk= go.opentelemetry.io/otel/trace v1.6.0/go.mod h1:qs7BrU5cZ8dXQHBGxHMOxwME/27YH2qEp4/+tZLLwJE= go.opentelemetry.io/otel/trace v1.6.1/go.mod h1:RkFRM1m0puWIq10oxImnGEduNBzxiN7TXluRBtE+5j0= +go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= +go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ= go.opentelemetry.io/proto/otlp v0.12.1/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= +go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= +go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1332,8 +1359,8 @@ golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1352,8 +1379,8 @@ golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= -golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1366,8 +1393,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1493,8 +1520,8 @@ golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1509,8 +1536,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1598,8 +1625,8 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= -golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= -golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1648,7 +1675,6 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/cloud v0.0.0-20151119220103-975617b05ea8/go.mod h1:0H1ncTHf11KCFhTc/+EFRbzSCOZx+VUbRMk55Yv5MYk= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= @@ -1764,8 +1790,8 @@ google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ5 google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= -google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1781,8 +1807,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/generator/otel-config.yaml b/generator/otel-config.yaml index aa4c9b79..7696ec96 100644 --- a/generator/otel-config.yaml +++ b/generator/otel-config.yaml @@ -13,10 +13,8 @@ processors: exporters: otlphttp/logs: - endpoint: http://localhost:4317/v1/logs - verbosity: detailed - sampling_initial: 1 - sampling_thereafter: 1 + # change this depending on where you're running loki (can be made configurable) + endpoint: http://localhost:3100/otlp tls: insecure: true From 5be16a58ac22cfc2e6ae8e412a3cfc6d892b3bce Mon Sep 17 00:00:00 2001 From: shantanualshi Date: Fri, 29 Nov 2024 17:41:20 +0530 Subject: [PATCH 04/13] fixup! chore: modify dockerfile to start otel-collector --- generator/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/generator/Dockerfile b/generator/Dockerfile index c74ef7a0..b37a31e5 100644 --- a/generator/Dockerfile +++ b/generator/Dockerfile @@ -13,6 +13,7 @@ WORKDIR /go/src/app COPY go.mod go.sum ./ COPY *.go ./ COPY flog/ flog/ +COPY log/ log/ RUN go mod download RUN CGO_ENABLED=0 GOOS=linux go build -o /generator @@ -29,8 +30,8 @@ COPY < Date: Fri, 29 Nov 2024 17:43:31 +0530 Subject: [PATCH 05/13] chore: implement otel logging --- generator/generator.go | 24 +++++- generator/log/otel-logger.go | 143 +++++++++++++++++++++++++++++++++++ generator/log/values.go | 2 +- generator/main.go | 6 +- 4 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 generator/log/otel-logger.go diff --git a/generator/generator.go b/generator/generator.go index 551effd7..8f74385f 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -6,8 +6,8 @@ import ( "math/rand" "time" - "github.com/cyriltovena/loki-log-generator/flog" - "github.com/cyriltovena/loki-log-generator/log" + "github.com/grafana/explore-logs/generator/flog" + "github.com/grafana/explore-logs/generator/log" "github.com/grafana/loki/pkg/push" "github.com/prometheus/common/model" ) @@ -90,6 +90,26 @@ var generators = map[model.LabelValue]map[model.LabelValue]LogGenerator{ "tempo-ingester": noisyTempo, "tempo-distributor": noisyTempo, }, + "loki-otel": { + "loki-ingester-otel": lokiPod, + }, +} + +func lokiPod(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { + go func() { + for ctx.Err() == nil { + t := time.Now() + logger.LogWithMetadata(log.ERROR, t, mimirGRPCLog("connection refused to object store", "/loki.Ingester/Push"), log.RandStructuredMetadata("mimir-ingester")) + time.Sleep(time.Duration(rand.Intn(10000)) * time.Millisecond) + } + }() + go func() { + for ctx.Err() == nil { + t := time.Now() + logger.LogWithMetadata(log.INFO, t, mimirGRPCLog("", "/loki.Ingester/Push"), log.RandStructuredMetadata("loki-ingester")) + time.Sleep(time.Duration(rand.Intn(500)) * time.Millisecond) + } + }() } var noisyTempo = func(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { diff --git a/generator/log/otel-logger.go b/generator/log/otel-logger.go new file mode 100644 index 00000000..881ad820 --- /dev/null +++ b/generator/log/otel-logger.go @@ -0,0 +1,143 @@ +package log + +import ( + "context" + "fmt" + "log/slog" + "os" + "time" + + "github.com/grafana/loki/pkg/push" + "github.com/prometheus/common/model" + "go.opentelemetry.io/contrib/bridges/otelslog" + "go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc" + sdk "go.opentelemetry.io/otel/sdk/log" + "go.opentelemetry.io/otel/sdk/resource" + semconv "go.opentelemetry.io/otel/semconv/v1.26.0" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +// OtelLogger implements the Logger interface and provides OpenTelemetry context awareness +type OtelLogger struct { + logger *slog.Logger +} + +// NewOtelLogger creates a new OpenTelemetry-aware logger +func NewOtelLogger() *OtelLogger { + provider, err := loggingProvider() + if err != nil { + return nil + } + return &OtelLogger{ + logger: otelslog.NewLogger("log-generator", otelslog.WithLoggerProvider(provider)), + } +} + +// Handle implements the Logger interface +func (o *OtelLogger) Handle(labels model.LabelSet, timestamp time.Time, message string) error { + return o.HandleWithMetadata(labels, timestamp, message, nil) +} + +// HandleWithMetadata implements the Logger interface with OpenTelemetry context +func (o *OtelLogger) HandleWithMetadata(labels model.LabelSet, timestamp time.Time, message string, metadata push.LabelsAdapter) error { + // Convert labels to slog attributes + attrs := make([]slog.Attr, 0, len(labels)+3) // +3 for potential trace context + + // Add all labels as attributes + for k, v := range labels { + attrs = append(attrs, slog.String(string(k), string(v))) + } + + // Add metadata if present + if metadata != nil { + for _, label := range metadata { + attrs = append(attrs, slog.String(label.Name, label.Value)) + } + } + + // Extract trace context if available + if traceID := extractTraceID(metadata); traceID != "" { + attrs = append(attrs, slog.String("trace_id", traceID)) + } + + // Determine log level from labels + level := getSlogLevel(labels) + + // Create the log record + record := slog.NewRecord(timestamp, level, message, 0) + record.AddAttrs(attrs...) + + // Log the record + return o.logger.Handler().Handle(context.Background(), record) +} + +// extractTraceID attempts to get trace ID from metadata +func extractTraceID(metadata push.LabelsAdapter) string { + if metadata == nil { + return "" + } + + for _, label := range metadata { + if label.Name == "traceID" { + return label.Value + } + } + return "" +} + +// getSlogLevel converts Loki log levels to slog levels +func getSlogLevel(labels model.LabelSet) slog.Level { + if level, ok := labels["level"]; ok { + switch level { + case "error": + return slog.LevelError + case "warn": + return slog.LevelWarn + case "info": + return slog.LevelInfo + case "debug": + return slog.LevelDebug + } + } + return slog.LevelInfo +} + +func loggingProvider() (*sdk.LoggerProvider, error) { + ctx := context.Background() + + // Get collector endpoint from env var or use default + collectorEndpoint := os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT") + if collectorEndpoint == "" { + collectorEndpoint = "localhost:4317" + } + + // Create gRPC connection to collector + conn, err := grpc.NewClient(collectorEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) + + if err != nil { + return nil, fmt.Errorf("failed to connect to collector: %w", err) + } + + // Create resource with service information + res, err := resource.New(ctx, + resource.WithAttributes( + semconv.ServiceName("log-generator"), + semconv.ServiceVersion("1.0.0"), + ), + ) + if err != nil { + return nil, fmt.Errorf("failed to create resource: %w", err) + } + + // Create OTLP exporter + exporter, err := otlploggrpc.New(ctx, + otlploggrpc.WithGRPCConn(conn)) + if err != nil { + return nil, fmt.Errorf("failed to create log exporter: %w", err) + } + proc := sdk.NewBatchProcessor(exporter) + + // Create logger provider + return sdk.NewLoggerProvider(sdk.WithResource(res), sdk.WithProcessor(proc)), nil +} diff --git a/generator/log/values.go b/generator/log/values.go index 4cd206cc..7c1749f9 100644 --- a/generator/log/values.go +++ b/generator/log/values.go @@ -112,7 +112,7 @@ func ForAllClusters(namespace, svc model.LabelValue, cb func(model.LabelSet, pus "env": model.LabelValue(namespaces[rand.Intn(len(namespaces))]), "cluster": model.LabelValue(cluster), "__stream_shard__": model.LabelValue(shards[clusterInt%len(shards)]), - "namespace": model.LabelValue(namespace), + "namespace": namespace, "service_name": svc, }, RandStructuredMetadata(string(svc))) } diff --git a/generator/main.go b/generator/main.go index 2955fa38..bd0e9913 100644 --- a/generator/main.go +++ b/generator/main.go @@ -6,9 +6,10 @@ import ( "fmt" "os" "os/signal" + "strings" "time" - "github.com/cyriltovena/loki-log-generator/log" + "github.com/grafana/explore-logs/generator/log" "github.com/grafana/loki-client-go/loki" "github.com/grafana/loki/pkg/push" "github.com/prometheus/common/model" @@ -50,6 +51,9 @@ func main() { if serviceName == "nginx" { metadata = push.LabelsAdapter{} } + if strings.Contains(string(serviceName), "-otel") { + logger = log.NewOtelLogger() + } generator(ctx, log.NewAppLogger(labels, logger), metadata) }) } From fa2d5bbeba9cb8b6585d464bf6053e3ef835d772 Mon Sep 17 00:00:00 2001 From: shantanualshi Date: Fri, 29 Nov 2024 18:01:53 +0530 Subject: [PATCH 06/13] chore: fix a few minor bugs --- generator/generator.go | 30 +++++++++++++++++++++++++++--- generator/log/otel-logger.go | 8 ++++---- generator/main.go | 6 ++++-- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/generator/generator.go b/generator/generator.go index 8f74385f..392ef211 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -95,18 +95,18 @@ var generators = map[model.LabelValue]map[model.LabelValue]LogGenerator{ }, } -func lokiPod(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { +var lokiPod = func(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { go func() { for ctx.Err() == nil { t := time.Now() - logger.LogWithMetadata(log.ERROR, t, mimirGRPCLog("connection refused to object store", "/loki.Ingester/Push"), log.RandStructuredMetadata("mimir-ingester")) + logger.LogWithMetadata(log.ERROR, t, lokiGRPCLog("connection refused to object store", "/loki.Ingester/Push"), log.RandStructuredMetadata("loki-ingester")) time.Sleep(time.Duration(rand.Intn(10000)) * time.Millisecond) } }() go func() { for ctx.Err() == nil { t := time.Now() - logger.LogWithMetadata(log.INFO, t, mimirGRPCLog("", "/loki.Ingester/Push"), log.RandStructuredMetadata("loki-ingester")) + logger.LogWithMetadata(log.INFO, t, lokiGRPCLog("", "/loki.Ingester/Push"), log.RandStructuredMetadata("loki-ingester")) time.Sleep(time.Duration(rand.Intn(500)) * time.Millisecond) } }() @@ -214,6 +214,7 @@ func startFailingMimirPod(ctx context.Context, logger log.Logger) { const ( mimirGrpcLogFmt = `ts=%s caller=grpc_logging.go:66 tenant=%s level=%s method=%s duration=%s msg=gRPC` + lokiGrpcLogFmt = `ts=%s caller=grpc_logging.go:66 tenant=%s level=%s method=%s duration=%s msg=gRPC` // we need another app may be pyrscope and many different pattern this time to make pattern tab interesting. ) @@ -240,6 +241,29 @@ func mimirGRPCLog(err string, path string) string { return log } +func lokiGRPCLog(err, path string) string { + level := log.INFO + org := log.RandOrgID() + if err != "" { + level = log.ERROR + org = log.OrgIDs[rand.Intn(len(log.OrgIDs[2:]))] + } + + log := fmt.Sprintf( + lokiGrpcLogFmt, + time.Now().Format(time.RFC3339Nano), + org, + level, + path, + log.RandDuration(), + ) + if err != "" { + log += ` err="` + err + `"` + } + + return log +} + func statusFromLevel(level model.LabelValue) int { switch level { case log.INFO: diff --git a/generator/log/otel-logger.go b/generator/log/otel-logger.go index 881ad820..c5bff217 100644 --- a/generator/log/otel-logger.go +++ b/generator/log/otel-logger.go @@ -24,8 +24,8 @@ type OtelLogger struct { } // NewOtelLogger creates a new OpenTelemetry-aware logger -func NewOtelLogger() *OtelLogger { - provider, err := loggingProvider() +func NewOtelLogger(svcName string) *OtelLogger { + provider, err := loggingProvider(svcName) if err != nil { return nil } @@ -103,7 +103,7 @@ func getSlogLevel(labels model.LabelSet) slog.Level { return slog.LevelInfo } -func loggingProvider() (*sdk.LoggerProvider, error) { +func loggingProvider(svcName string) (*sdk.LoggerProvider, error) { ctx := context.Background() // Get collector endpoint from env var or use default @@ -122,7 +122,7 @@ func loggingProvider() (*sdk.LoggerProvider, error) { // Create resource with service information res, err := resource.New(ctx, resource.WithAttributes( - semconv.ServiceName("log-generator"), + semconv.ServiceName(svcName), semconv.ServiceVersion("1.0.0"), ), ) diff --git a/generator/main.go b/generator/main.go index bd0e9913..40a778ab 100644 --- a/generator/main.go +++ b/generator/main.go @@ -52,9 +52,11 @@ func main() { metadata = push.LabelsAdapter{} } if strings.Contains(string(serviceName), "-otel") { - logger = log.NewOtelLogger() + generator(ctx, log.NewAppLogger(labels, log.NewOtelLogger(string(serviceName))), metadata) + } else { + generator(ctx, log.NewAppLogger(labels, logger), metadata) } - generator(ctx, log.NewAppLogger(labels, logger), metadata) + }) } } From b60b44f37bf77fb4164af0a855e45815066a5550 Mon Sep 17 00:00:00 2001 From: Galen Date: Mon, 2 Dec 2024 09:04:13 -0600 Subject: [PATCH 07/13] chore: update spellcheck --- project-words.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/project-words.txt b/project-words.txt index a1538f2f..851856f7 100644 --- a/project-words.txt +++ b/project-words.txt @@ -325,9 +325,14 @@ opencontainers opentracing openzipkin osext +otelslog +otlplog +otlploggrpc +semconv otelgrpc otelhttp oteltest +otlphttp otlptrace otlptracegrpc otlptracehttp From 29c18c79e5ec2b08516de7e614889f164706fc9e Mon Sep 17 00:00:00 2001 From: shantanualshi Date: Thu, 2 Jan 2025 11:33:32 +0530 Subject: [PATCH 08/13] chore: add some more log types --- generator/generator.go | 48 +++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/generator/generator.go b/generator/generator.go index 392ef211..c8be6466 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -91,25 +91,43 @@ var generators = map[model.LabelValue]map[model.LabelValue]LogGenerator{ "tempo-distributor": noisyTempo, }, "loki-otel": { - "loki-ingester-otel": lokiPod, + "loki-ingester-otel": lokiOtelPod("loki-ingester-otel"), + "loki-querier-otel": lokiOtelPod("loki-querier-otel"), + "loki-queryfrontend-otel": lokiOtelPod("loki-queryfrontend-otel"), + "loki-distributor-otel": lokiOtelPod("loki-distributor-otel"), }, } -var lokiPod = func(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { - go func() { - for ctx.Err() == nil { - t := time.Now() - logger.LogWithMetadata(log.ERROR, t, lokiGRPCLog("connection refused to object store", "/loki.Ingester/Push"), log.RandStructuredMetadata("loki-ingester")) - time.Sleep(time.Duration(rand.Intn(10000)) * time.Millisecond) - } - }() - go func() { - for ctx.Err() == nil { - t := time.Now() - logger.LogWithMetadata(log.INFO, t, lokiGRPCLog("", "/loki.Ingester/Push"), log.RandStructuredMetadata("loki-ingester")) - time.Sleep(time.Duration(rand.Intn(500)) * time.Millisecond) +func lokiOtelPod(svc string) LogGenerator { + logs := map[string]map[model.LabelValue]string{ + "loki-ingester-otel": { + log.ERROR: lokiGRPCLog("connection refused to object store", "/loki.Ingester/Push"), + log.INFO: lokiGRPCLog("", "/loki.Ingester/Push"), + }, + "loki-querier-otel": { + log.INFO: lokiGRPCLog("caller=engine.go:263 component=querier org_id=29 traceID=<_> msg=\"executing query\" query=<_> query_hash=1182293200 type=range length=20s step=4 token_id=123", "loki.Query/Engine"), + log.DEBUG: lokiGRPCLog("caller=scheduler_processor.go:135 component=querier msg=\"received query\" worker=<_> wait_time_sec=20s", "loki.Query/SchedulerProcessor"), + }, + "loki-queryfrontend-otel": { + log.INFO: lokiGRPCLog("caller=roundtrip.go:419 org_id=29 traceID=213098 msg=\"executing query\" type=instant query=\"abc\" query_hash=120938", "loki.Query/QueryRange"), + }, + "loki-distributor-otel": { + log.DEBUG: lokiGRPCLog("caller=push.go:165 org_id=29 traceID=192382 msg=\"push request parsed\" path=push.go contentType=application/x-protobuf contentEncoding= bodySize=129KB streams=12938 entries=81902398 streamLabelsSize=2KB entriesSize=2MB structuredMetadataSize=200KB totalSize=20MB mostRecentLagMs=10s", "loki.Distributor/Push"), + log.INFO: lokiGRPCLog("caller=tee_service.go:273 msg=\"prepared Tee batches for tenant\" tenant=29 stream_count=100 avg_logs_slice_cap_start=120 avg_logs_slice_cap_end=123992 avg_logs_slice_len_end=10200 avg_log_lines_count=122300 avg_log_line_length=10s", "loki.Distributor/Tee"), + }, + } + return func(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { + serviceLogs := logs[svc] + for k, v := range serviceLogs { + go func() { + for ctx.Err() == nil { + t := time.Now() + logger.LogWithMetadata(k, t, v, log.RandStructuredMetadata("loki-ingester")) + time.Sleep(time.Duration(rand.Intn(5000)) * time.Millisecond) + } + }() } - }() + } } var noisyTempo = func(ctx context.Context, logger *log.AppLogger, metadata push.LabelsAdapter) { From 4e38a3be1da2eceaed492dfb4e71469d8110ba9f Mon Sep 17 00:00:00 2001 From: shantanualshi Date: Thu, 2 Jan 2025 11:56:25 +0530 Subject: [PATCH 09/13] chore: fix spellcheck --- project-words.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/project-words.txt b/project-words.txt index 851856f7..68ff8d57 100644 --- a/project-words.txt +++ b/project-words.txt @@ -505,3 +505,4 @@ capslock pageup pagedown linefilter +queryfrontend From 9687edd32038008ccbf47c25c0bc2bc32404f591 Mon Sep 17 00:00:00 2001 From: shantanualshi Date: Thu, 2 Jan 2025 13:24:52 +0530 Subject: [PATCH 10/13] chore: upgrade loki versions in docker-compose files --- docker-compose.dev.yaml | 2 +- docker-compose.local.yaml | 2 +- docker-compose.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index 2f1c4af1..050113a5 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -18,7 +18,7 @@ services: extra_hosts: - 'host.docker.internal:host-gateway' loki: - image: grafana/loki:3.2.0 + image: grafana/loki:3.3.2 environment: LOG_CLUSTER_DEPTH: '8' LOG_SIM_TH: '0.3' diff --git a/docker-compose.local.yaml b/docker-compose.local.yaml index 16ecfc20..95e6c05e 100644 --- a/docker-compose.local.yaml +++ b/docker-compose.local.yaml @@ -22,7 +22,7 @@ services: extra_hosts: - 'host.docker.internal:host-gateway' loki: - image: grafana/loki:3.3.0 + image: grafana/loki:3.3.2 environment: LOG_CLUSTER_DEPTH: '8' LOG_SIM_TH: '0.3' diff --git a/docker-compose.yaml b/docker-compose.yaml index 5184aaec..593ca3f7 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,7 +16,7 @@ services: extra_hosts: - 'host.docker.internal:host-gateway' loki: - image: grafana/loki:3.2.0 + image: grafana/loki:3.3.2 environment: LOG_CLUSTER_DEPTH: '8' LOG_SIM_TH: '0.3' From 46b87c76357604220d54a4933c704bf47097a129 Mon Sep 17 00:00:00 2001 From: shantanualshi Date: Thu, 2 Jan 2025 13:33:27 +0530 Subject: [PATCH 11/13] fix: pass arguments to the generator inside dockerfile --- generator/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/Dockerfile b/generator/Dockerfile index b37a31e5..f103a41d 100644 --- a/generator/Dockerfile +++ b/generator/Dockerfile @@ -31,7 +31,7 @@ COPY < Date: Thu, 2 Jan 2025 14:04:39 +0530 Subject: [PATCH 12/13] fix: run generate-logs in docker --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 53ebaff9..0573d3f6 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "e2e:flake": "yarn e2e:10x", "e2e:debug": "playwright test --debug -x --trace on /test", "e2e:codegen": "playwright install && playwright codegen", - "generate-logs": "pushd generator; go mod download; go run . -url http://localhost:3100/loki/api/v1/push; popd", + "generate-logs": "pushd generator; docker build -t log-generator . && docker run log-generator -url http://host.docker.internal:3100/loki/api/v1/push; popd", "server": "docker compose -f docker-compose.local.yaml up --build", "server:localLoki": "docker compose -f docker-compose-local-loki.dev.yaml up --build", "server:ci": "docker compose -f docker-compose.dev.yaml up --build -d", From a3924a834392caac4eaba495132949b42e941749 Mon Sep 17 00:00:00 2001 From: Shantanu Alshi Date: Thu, 2 Jan 2025 20:18:04 +0530 Subject: [PATCH 13/13] chore: change otel-config to use host.docker.internal Co-authored-by: Sven Grossmann --- generator/otel-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/otel-config.yaml b/generator/otel-config.yaml index 7696ec96..d4b97e3b 100644 --- a/generator/otel-config.yaml +++ b/generator/otel-config.yaml @@ -14,7 +14,7 @@ processors: exporters: otlphttp/logs: # change this depending on where you're running loki (can be made configurable) - endpoint: http://localhost:3100/otlp + endpoint: http://host.docker.internal:3100/otlp tls: insecure: true