diff --git a/.github/workflows/ci-e2e-elasticsearch.yml b/.github/workflows/ci-e2e-elasticsearch.yml
index 1cdda82eb59..e10491e736e 100644
--- a/.github/workflows/ci-e2e-elasticsearch.yml
+++ b/.github/workflows/ci-e2e-elasticsearch.yml
@@ -53,6 +53,11 @@ jobs:
with:
go-version: 1.23.x
+ - name: time settings
+ run: |
+ date
+ echo TZ="$TZ"
+
- uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- name: Run ${{ matrix.version.distribution }} integration tests
id: test-execution
diff --git a/.golangci.yml b/.golangci.yml
index e4c5b52b3e0..7c4e9314df8 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -96,6 +96,9 @@ linters:
# Reports ill-formed or insufficient nolint directives.
- nolintlint
+ # Checks that fmt.Sprintf can be replaced with a faster alternative.
+ - perfsprint
+
# Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
- revive
@@ -153,6 +156,17 @@ linters-settings:
- fieldalignment
# Disable shadow
- shadow
+ perfsprint:
+ # Optimizes even if it requires an int or uint type cast.
+ int-conversion: true
+ # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.
+ err-error: true
+ # Optimizes `fmt.Errorf`.
+ errorf: true
+ # Optimizes `fmt.Sprintf` with only one argument.
+ sprintf1: true
+ # Optimizes into strings concatenation.
+ strconcat: true
revive:
ignore-generated-header: true
severity: error
diff --git a/cmd/agent/app/agent_test.go b/cmd/agent/app/agent_test.go
index e11e88e2769..0cd3cb08d48 100644
--- a/cmd/agent/app/agent_test.go
+++ b/cmd/agent/app/agent_test.go
@@ -44,9 +44,7 @@ func TestAgentSamplingEndpoint(t *testing.T) {
}
select {
case err := <-errorch:
- if err != nil {
- t.Fatalf("error from agent: %s", err)
- }
+ require.NoError(t, err, "error from agent")
break wait_loop
default:
time.Sleep(time.Millisecond)
@@ -155,9 +153,7 @@ func TestStartStopRace(t *testing.T) {
// Before the bug was fixed this test was failing as expected when
// run with -race flag.
- if err := agent.Run(); err != nil {
- t.Fatalf("error from agent.Run(): %s", err)
- }
+ require.NoError(t, agent.Run())
t.Log("stopping agent")
agent.Stop()
@@ -192,9 +188,7 @@ func TestStartStopWithSocketBufferSet(t *testing.T) {
agent, err := cfg.CreateAgent(fakeCollectorProxy{}, zap.NewNop(), metricsFactory)
require.NoError(t, err)
- if err := agent.Run(); err != nil {
- t.Fatalf("error from agent.Run(): %s", err)
- }
+ require.NoError(t, agent.Run())
t.Log("stopping agent")
agent.Stop()
diff --git a/cmd/agent/app/builder_test.go b/cmd/agent/app/builder_test.go
index 2f8275fa3df..fa7bc913487 100644
--- a/cmd/agent/app/builder_test.go
+++ b/cmd/agent/app/builder_test.go
@@ -10,7 +10,6 @@ import (
"expvar"
"flag"
"fmt"
- "strings"
"testing"
"time"
@@ -150,9 +149,9 @@ func TestBuilderWithProcessorErrors(t *testing.T) {
_, err := cfg.CreateAgent(&fakeCollectorProxy{}, zap.NewNop(), metrics.NullFactory)
require.Error(t, err)
if testCase.err != "" {
- assert.Contains(t, err.Error(), testCase.err)
+ assert.ErrorContains(t, err, testCase.err)
} else if testCase.errContains != "" {
- assert.True(t, strings.Contains(err.Error(), testCase.errContains), "error must contain %s", testCase.errContains)
+ assert.ErrorContains(t, err, testCase.errContains, "error must contain %s", testCase.errContains)
}
}
}
diff --git a/cmd/agent/app/configmanager/grpc/manager_test.go b/cmd/agent/app/configmanager/grpc/manager_test.go
index b2b91cc1ce9..2a26fee436d 100644
--- a/cmd/agent/app/configmanager/grpc/manager_test.go
+++ b/cmd/agent/app/configmanager/grpc/manager_test.go
@@ -38,8 +38,7 @@ func TestSamplingManager_GetSamplingStrategy_error(t *testing.T) {
manager := NewConfigManager(conn)
resp, err := manager.GetSamplingStrategy(context.Background(), "any")
require.Nil(t, resp)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "failed to get sampling strategy")
+ assert.ErrorContains(t, err, "failed to get sampling strategy")
}
func TestSamplingManager_GetBaggageRestrictions(t *testing.T) {
diff --git a/cmd/agent/app/reporter/flags.go b/cmd/agent/app/reporter/flags.go
index 7ba521b983b..5dca6444f18 100644
--- a/cmd/agent/app/reporter/flags.go
+++ b/cmd/agent/app/reporter/flags.go
@@ -5,7 +5,6 @@ package reporter
import (
"flag"
- "fmt"
"github.com/spf13/viper"
"go.uber.org/zap"
@@ -34,7 +33,7 @@ type Options struct {
// AddFlags adds flags for Options.
func AddFlags(flagSet *flag.FlagSet) {
- flagSet.String(reporterType, string(GRPC), fmt.Sprintf("Reporter type to use e.g. %s", string(GRPC)))
+ flagSet.String(reporterType, string(GRPC), "Reporter type to use e.g. "+string(GRPC))
if !setupcontext.IsAllInOne() {
flagSet.String(agentTags, "", "One or more tags to be added to the Process tags of all spans passing through this agent. Ex: key1=value1,key2=${envVar:defaultValue}")
}
diff --git a/cmd/agent/app/reporter/grpc/builder_test.go b/cmd/agent/app/reporter/grpc/builder_test.go
index 71471543e20..9eb4ebdea33 100644
--- a/cmd/agent/app/reporter/grpc/builder_test.go
+++ b/cmd/agent/app/reporter/grpc/builder_test.go
@@ -128,8 +128,7 @@ func TestBuilderWithCollectors(t *testing.T) {
assert.Equal(t, conn.Target(), test.target)
}
} else {
- require.Error(t, err)
- assert.Contains(t, err.Error(), test.expectedError)
+ assert.ErrorContains(t, err, test.expectedError)
}
})
}
diff --git a/cmd/agent/app/reporter/grpc/flags_test.go b/cmd/agent/app/reporter/grpc/flags_test.go
index 6436cc847dc..4b2783aa4f9 100644
--- a/cmd/agent/app/reporter/grpc/flags_test.go
+++ b/cmd/agent/app/reporter/grpc/flags_test.go
@@ -57,6 +57,5 @@ func TestBindTLSFlagFailure(t *testing.T) {
})
require.NoError(t, err)
_, err = new(ConnBuilder).InitFromViper(v)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "failed to process TLS options")
+ assert.ErrorContains(t, err, "failed to process TLS options")
}
diff --git a/cmd/agent/app/reporter/grpc/reporter_test.go b/cmd/agent/app/reporter/grpc/reporter_test.go
index cf8fee506e8..32ed9253033 100644
--- a/cmd/agent/app/reporter/grpc/reporter_test.go
+++ b/cmd/agent/app/reporter/grpc/reporter_test.go
@@ -123,8 +123,7 @@ func TestReporter_SendFailure(t *testing.T) {
defer conn.Close()
rep := NewReporter(conn, nil, zap.NewNop())
err = rep.send(context.Background(), nil, nil)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "failed to export spans:")
+ assert.ErrorContains(t, err, "failed to export spans:")
}
func TestReporter_AddProcessTags_EmptyTags(t *testing.T) {
@@ -211,6 +210,6 @@ func TestReporter_MultitenantEmitBatch(t *testing.T) {
}
for _, test := range tests {
err = rep.EmitBatch(context.Background(), test.in)
- assert.Contains(t, err.Error(), test.err)
+ assert.ErrorContains(t, err, test.err)
}
}
diff --git a/cmd/anonymizer/app/uiconv/extractor_test.go b/cmd/anonymizer/app/uiconv/extractor_test.go
index 64f5bdd2c6e..5f06f338462 100644
--- a/cmd/anonymizer/app/uiconv/extractor_test.go
+++ b/cmd/anonymizer/app/uiconv/extractor_test.go
@@ -66,7 +66,7 @@ func TestExtractorTraceOutputFileError(t *testing.T) {
reader,
zap.NewNop(),
)
- require.Contains(t, err.Error(), "cannot create output file")
+ require.ErrorContains(t, err, "cannot create output file")
}
func TestExtractorTraceScanError(t *testing.T) {
@@ -86,7 +86,7 @@ func TestExtractorTraceScanError(t *testing.T) {
require.NoError(t, err)
err = extractor.Run()
- require.Contains(t, err.Error(), "failed when scanning the file")
+ require.ErrorContains(t, err, "failed when scanning the file")
}
func loadJSON(t *testing.T, fileName string, i any) {
diff --git a/cmd/anonymizer/app/uiconv/module_test.go b/cmd/anonymizer/app/uiconv/module_test.go
index 3dd05612a82..02b541cfb3c 100644
--- a/cmd/anonymizer/app/uiconv/module_test.go
+++ b/cmd/anonymizer/app/uiconv/module_test.go
@@ -46,7 +46,7 @@ func TestModule_TraceNonExistent(t *testing.T) {
TraceID: "2be38093ead7a083",
}
err := Extract(config, zap.NewNop())
- require.Contains(t, err.Error(), "cannot open captured file")
+ require.ErrorContains(t, err, "cannot open captured file")
}
func TestModule_TraceOutputFileError(t *testing.T) {
@@ -65,5 +65,5 @@ func TestModule_TraceOutputFileError(t *testing.T) {
defer os.Chmod("fixtures", 0o755)
err = Extract(config, zap.NewNop())
- require.Contains(t, err.Error(), "cannot create output file")
+ require.ErrorContains(t, err, "cannot create output file")
}
diff --git a/cmd/anonymizer/app/uiconv/reader.go b/cmd/anonymizer/app/uiconv/reader.go
index 749ea461a24..e9f2ae12686 100644
--- a/cmd/anonymizer/app/uiconv/reader.go
+++ b/cmd/anonymizer/app/uiconv/reader.go
@@ -6,6 +6,7 @@ package uiconv
import (
"bufio"
"encoding/json"
+ "errors"
"fmt"
"os"
@@ -14,7 +15,7 @@ import (
uimodel "github.com/jaegertracing/jaeger/model/json"
)
-var errNoMoreSpans = fmt.Errorf("no more spans")
+var errNoMoreSpans = errors.New("no more spans")
// spanReader loads previously captured spans from a file.
type spanReader struct {
@@ -53,7 +54,7 @@ func (r *spanReader) NextSpan() (*uimodel.Span, error) {
}
if b != '[' {
r.eofReached = true
- return nil, fmt.Errorf("file must begin with '['")
+ return nil, errors.New("file must begin with '['")
}
}
s, err := r.reader.ReadString('\n')
diff --git a/cmd/anonymizer/app/uiconv/reader_test.go b/cmd/anonymizer/app/uiconv/reader_test.go
index a02ea74e70f..d3ce8604eb3 100644
--- a/cmd/anonymizer/app/uiconv/reader_test.go
+++ b/cmd/anonymizer/app/uiconv/reader_test.go
@@ -39,7 +39,7 @@ func TestReaderTraceSuccess(t *testing.T) {
func TestReaderTraceNonExistent(t *testing.T) {
inputFile := "fixtures/trace_non_existent.json"
_, err := newSpanReader(inputFile, zap.NewNop())
- require.Contains(t, err.Error(), "cannot open captured file")
+ require.ErrorContains(t, err, "cannot open captured file")
}
func TestReaderTraceEmpty(t *testing.T) {
@@ -48,7 +48,7 @@ func TestReaderTraceEmpty(t *testing.T) {
require.NoError(t, err)
_, err = r.NextSpan()
- require.Contains(t, err.Error(), "cannot read file")
+ require.ErrorContains(t, err, "cannot read file")
assert.Equal(t, 0, r.spansRead)
assert.True(t, r.eofReached)
}
@@ -70,7 +70,7 @@ func TestReaderTraceInvalidJson(t *testing.T) {
require.NoError(t, err)
_, err = r.NextSpan()
- require.Contains(t, err.Error(), "cannot unmarshal span")
+ require.ErrorContains(t, err, "cannot unmarshal span")
assert.Equal(t, 0, r.spansRead)
assert.True(t, r.eofReached)
}
diff --git a/cmd/collector/app/collector_test.go b/cmd/collector/app/collector_test.go
index 5b199de22b0..35c0576d630 100644
--- a/cmd/collector/app/collector_test.go
+++ b/cmd/collector/app/collector_test.go
@@ -104,8 +104,7 @@ func TestCollector_StartErrors(t *testing.T) {
TenancyMgr: tm,
})
err := c.Start(options)
- require.Error(t, err)
- assert.Contains(t, err.Error(), expErr)
+ require.ErrorContains(t, err, expErr)
require.NoError(t, c.Close())
})
}
diff --git a/cmd/collector/app/flags/flags_test.go b/cmd/collector/app/flags/flags_test.go
index 82b7494c5d5..9d261465c09 100644
--- a/cmd/collector/app/flags/flags_test.go
+++ b/cmd/collector/app/flags/flags_test.go
@@ -65,8 +65,7 @@ func TestCollectorOptionsWithFailedTLSFlags(t *testing.T) {
})
require.NoError(t, err)
_, err = c.InitFromViper(v, zap.NewNop())
- require.Error(t, err)
- assert.Contains(t, err.Error(), "failed to parse")
+ assert.ErrorContains(t, err, "failed to parse")
})
}
}
@@ -91,8 +90,7 @@ func TestCollectorOptionsWithFlags_CheckTLSReloadInterval(t *testing.T) {
prefix + ".tls.reload-interval=24h",
})
if _, ok := otlpPrefixes[prefix]; !ok {
- require.Error(t, err)
- assert.Contains(t, err.Error(), "unknown flag")
+ assert.ErrorContains(t, err, "unknown flag")
} else {
require.NoError(t, err)
}
diff --git a/cmd/collector/app/handler/grpc_handler_test.go b/cmd/collector/app/handler/grpc_handler_test.go
index 6f9cb423304..2501ced7461 100644
--- a/cmd/collector/app/handler/grpc_handler_test.go
+++ b/cmd/collector/app/handler/grpc_handler_test.go
@@ -193,9 +193,8 @@ func TestPostSpansWithError(t *testing.T) {
},
},
})
- require.Error(t, err)
+ require.ErrorContains(t, err, test.expectedError)
require.Nil(t, r)
- assert.Contains(t, err.Error(), test.expectedError)
assert.Contains(t, logBuf.String(), test.expectedLog)
assert.Len(t, processor.getSpans(), 1)
})
diff --git a/cmd/collector/app/handler/http_thrift_handler_test.go b/cmd/collector/app/handler/http_thrift_handler_test.go
index 7048c4efbb4..08fa4d516dc 100644
--- a/cmd/collector/app/handler/http_thrift_handler_test.go
+++ b/cmd/collector/app/handler/http_thrift_handler_test.go
@@ -7,7 +7,7 @@ package handler
import (
"bytes"
"context"
- "fmt"
+ "errors"
"io"
"net/http"
"net/http/httptest"
@@ -79,7 +79,7 @@ func TestThriftFormat(t *testing.T) {
assert.EqualValues(t, http.StatusAccepted, statusCode)
assert.EqualValues(t, "", resBodyStr)
- handler.jaegerBatchesHandler.(*mockJaegerHandler).err = fmt.Errorf("Bad times ahead")
+ handler.jaegerBatchesHandler.(*mockJaegerHandler).err = errors.New("Bad times ahead")
statusCode, resBodyStr, err = postBytes("application/vnd.apache.thrift.binary", server.URL+`/api/traces`, someBytes)
require.NoError(t, err)
assert.EqualValues(t, http.StatusInternalServerError, statusCode)
@@ -161,7 +161,7 @@ func TestCannotReadBodyFromRequest(t *testing.T) {
type errReader struct{}
func (*errReader) Read([]byte) (int, error) {
- return 0, fmt.Errorf("Simulated error reading body")
+ return 0, errors.New("Simulated error reading body")
}
type dummyResponseWriter struct {
diff --git a/cmd/collector/app/handler/otlp_receiver_test.go b/cmd/collector/app/handler/otlp_receiver_test.go
index 45e24655ee3..1f18c3d07bb 100644
--- a/cmd/collector/app/handler/otlp_receiver_test.go
+++ b/cmd/collector/app/handler/otlp_receiver_test.go
@@ -92,16 +92,14 @@ func TestStartOtlpReceiver_Error(t *testing.T) {
opts := optionsWithPorts(":-1")
tm := &tenancy.Manager{}
_, err := StartOTLPReceiver(opts, logger, spanProcessor, tm)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "could not start the OTLP receiver")
+ require.ErrorContains(t, err, "could not start the OTLP receiver")
newTraces := func(consumer.ConsumeTracesFunc, ...consumer.Option) (consumer.Traces, error) {
return nil, errors.New("mock error")
}
f := otlpreceiver.NewFactory()
_, err = startOTLPReceiver(opts, logger, spanProcessor, &tenancy.Manager{}, f, newTraces, f.CreateTraces)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "could not create the OTLP consumer")
+ require.ErrorContains(t, err, "could not create the OTLP consumer")
createTracesReceiver := func(
context.Context, receiver.Settings, component.Config, consumer.Traces,
@@ -109,8 +107,7 @@ func TestStartOtlpReceiver_Error(t *testing.T) {
return nil, errors.New("mock error")
}
_, err = startOTLPReceiver(opts, logger, spanProcessor, &tenancy.Manager{}, f, consumer.NewTraces, createTracesReceiver)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "could not create the OTLP receiver")
+ assert.ErrorContains(t, err, "could not create the OTLP receiver")
}
func TestOtelHost_ReportFatalError(t *testing.T) {
diff --git a/cmd/collector/app/handler/zipkin_receiver_test.go b/cmd/collector/app/handler/zipkin_receiver_test.go
index 2304e9c5392..584dbc56cda 100644
--- a/cmd/collector/app/handler/zipkin_receiver_test.go
+++ b/cmd/collector/app/handler/zipkin_receiver_test.go
@@ -141,16 +141,14 @@ func TestStartZipkinReceiver_Error(t *testing.T) {
opts.Zipkin.HTTPHostPort = ":-1"
_, err := StartZipkinReceiver(opts, logger, spanProcessor, tm)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "could not start Zipkin receiver")
+ require.ErrorContains(t, err, "could not start Zipkin receiver")
newTraces := func(consumer.ConsumeTracesFunc, ...consumer.Option) (consumer.Traces, error) {
return nil, errors.New("mock error")
}
f := zipkinreceiver.NewFactory()
_, err = startZipkinReceiver(opts, logger, spanProcessor, tm, f, newTraces, f.CreateTraces)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "could not create Zipkin consumer")
+ require.ErrorContains(t, err, "could not create Zipkin consumer")
createTracesReceiver := func(
context.Context, receiver.Settings, component.Config, consumer.Traces,
@@ -158,6 +156,5 @@ func TestStartZipkinReceiver_Error(t *testing.T) {
return nil, errors.New("mock error")
}
_, err = startZipkinReceiver(opts, logger, spanProcessor, tm, f, consumer.NewTraces, createTracesReceiver)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "could not create Zipkin receiver")
+ assert.ErrorContains(t, err, "could not create Zipkin receiver")
}
diff --git a/cmd/collector/app/server/http_test.go b/cmd/collector/app/server/http_test.go
index fe2a1a9b4e0..46184bd8b89 100644
--- a/cmd/collector/app/server/http_test.go
+++ b/cmd/collector/app/server/http_test.go
@@ -9,6 +9,7 @@ import (
"net"
"net/http"
"net/http/httptest"
+ "strconv"
"testing"
"time"
@@ -207,7 +208,7 @@ func TestSpanCollectorHTTPS(t *testing.T) {
defer test.clientTLS.Close()
require.NoError(t, err0)
dialer := &net.Dialer{Timeout: 2 * time.Second}
- conn, clientError := tls.DialWithDialer(dialer, "tcp", "localhost:"+fmt.Sprintf("%d", ports.CollectorHTTP), clientTLSCfg)
+ conn, clientError := tls.DialWithDialer(dialer, "tcp", "localhost:"+strconv.Itoa(ports.CollectorHTTP), clientTLSCfg)
var clientClose func() error
clientClose = nil
if conn != nil {
@@ -230,7 +231,7 @@ func TestSpanCollectorHTTPS(t *testing.T) {
},
}
- response, requestError := client.Post("https://localhost:"+fmt.Sprintf("%d", ports.CollectorHTTP), "", nil)
+ response, requestError := client.Post("https://localhost:"+strconv.Itoa(ports.CollectorHTTP), "", nil)
if test.expectClientError {
require.Error(t, requestError)
diff --git a/cmd/collector/app/span_processor_test.go b/cmd/collector/app/span_processor_test.go
index fd76bfdc1a6..c57f73b4bd8 100644
--- a/cmd/collector/app/span_processor_test.go
+++ b/cmd/collector/app/span_processor_test.go
@@ -6,6 +6,7 @@ package app
import (
"context"
+ "errors"
"fmt"
"io"
"reflect"
@@ -250,7 +251,7 @@ func TestSpanProcessor(t *testing.T) {
func TestSpanProcessorErrors(t *testing.T) {
logger, logBuf := testutils.NewLogger()
w := &fakeSpanWriter{
- err: fmt.Errorf("some-error"),
+ err: errors.New("some-error"),
}
mb := metricstest.NewFactory(time.Hour)
defer mb.Backend.Stop()
diff --git a/cmd/es-index-cleaner/main.go b/cmd/es-index-cleaner/main.go
index 9efbdee874a..a0ea71775c2 100644
--- a/cmd/es-index-cleaner/main.go
+++ b/cmd/es-index-cleaner/main.go
@@ -5,6 +5,7 @@ package main
import (
"encoding/base64"
+ "errors"
"fmt"
"log"
"net/http"
@@ -33,7 +34,7 @@ func main() {
Long: "Jaeger es-index-cleaner removes Jaeger indices",
RunE: func(_ *cobra.Command, args []string) error {
if len(args) != 2 {
- return fmt.Errorf("wrong number of arguments")
+ return errors.New("wrong number of arguments")
}
numOfDays, err := strconv.Atoi(args[0])
if err != nil {
diff --git a/cmd/es-rollover/app/init/action.go b/cmd/es-rollover/app/init/action.go
index d44e28e850e..4651aba3ece 100644
--- a/cmd/es-rollover/app/init/action.go
+++ b/cmd/es-rollover/app/init/action.go
@@ -49,7 +49,7 @@ func (c Action) Do() error {
}
if c.Config.UseILM {
if version < ilmVersionSupport {
- return fmt.Errorf("ILM is supported only for ES version 7+")
+ return errors.New("ILM is supported only for ES version 7+")
}
policyExist, err := c.ILMClient.Exists(c.Config.ILMPolicyName)
if err != nil {
diff --git a/cmd/es-rollover/app/init/action_test.go b/cmd/es-rollover/app/init/action_test.go
index 8c4e4bb2a0d..0f87f579ea2 100644
--- a/cmd/es-rollover/app/init/action_test.go
+++ b/cmd/es-rollover/app/init/action_test.go
@@ -6,7 +6,6 @@ package init
import (
"errors"
"net/http"
- "strings"
"testing"
"github.com/stretchr/testify/assert"
@@ -69,7 +68,7 @@ func TestIndexCreateIfNotExist(t *testing.T) {
indexClient.On("CreateIndex", "jaeger-span").Return(test.returnErr)
err := createIndexIfNotExist(indexClient, "jaeger-span")
if test.containsError != "" {
- assert.True(t, strings.Contains(err.Error(), test.containsError))
+ assert.ErrorContains(t, err, test.containsError)
} else {
assert.Equal(t, test.expectedErr, err)
}
diff --git a/cmd/ingester/app/consumer/consumer_test.go b/cmd/ingester/app/consumer/consumer_test.go
index 05180ddd469..f69f2a78362 100644
--- a/cmd/ingester/app/consumer/consumer_test.go
+++ b/cmd/ingester/app/consumer/consumer_test.go
@@ -5,7 +5,7 @@ package consumer
import (
"errors"
- "fmt"
+ "strconv"
"sync"
"testing"
"time"
@@ -163,7 +163,7 @@ func TestSaramaConsumerWrapper_start_Messages(t *testing.T) {
tags := map[string]string{
"topic": topic,
- "partition": fmt.Sprint(partition),
+ "partition": strconv.Itoa(int(partition)),
}
localFactory.AssertCounterMetrics(t, metricstest.ExpectedMetric{
Name: "sarama-consumer.messages",
@@ -217,7 +217,7 @@ func TestSaramaConsumerWrapper_start_Errors(t *testing.T) {
tags := map[string]string{
"topic": topic,
- "partition": fmt.Sprint(partition),
+ "partition": strconv.Itoa(int(partition)),
}
localFactory.AssertCounterMetrics(t, metricstest.ExpectedMetric{
Name: "sarama-consumer.errors",
diff --git a/cmd/internal/docs/command_test.go b/cmd/internal/docs/command_test.go
index bc7ff951d05..fa28843b8c9 100644
--- a/cmd/internal/docs/command_test.go
+++ b/cmd/internal/docs/command_test.go
@@ -5,7 +5,6 @@ package docs
import (
"os"
- "strings"
"testing"
"github.com/spf13/cobra"
@@ -36,7 +35,7 @@ func TestOutputFormats(t *testing.T) {
if err == nil {
f, err := os.ReadFile(test.file)
require.NoError(t, err)
- assert.True(t, strings.Contains(string(f), "documentation"))
+ assert.Contains(t, string(f), "documentation")
} else {
assert.Equal(t, test.err, err.Error())
}
@@ -55,7 +54,7 @@ func TestDocsForParent(t *testing.T) {
require.NoError(t, err)
f, err := os.ReadFile("root_command.md")
require.NoError(t, err)
- assert.True(t, strings.Contains(string(f), "some description"))
+ assert.Contains(t, string(f), "some description")
}
func TestMain(m *testing.M) {
diff --git a/cmd/internal/env/command_test.go b/cmd/internal/env/command_test.go
index 392d8bc1605..e18152c39c1 100644
--- a/cmd/internal/env/command_test.go
+++ b/cmd/internal/env/command_test.go
@@ -5,7 +5,6 @@ package env
import (
"bytes"
- "strings"
"testing"
"github.com/stretchr/testify/assert"
@@ -18,8 +17,8 @@ func TestCommand(t *testing.T) {
buf := new(bytes.Buffer)
cmd.SetOut(buf)
cmd.Run(cmd, nil)
- assert.True(t, strings.Contains(buf.String(), "METRICS_BACKEND"))
- assert.True(t, strings.Contains(buf.String(), "SPAN_STORAGE"))
+ assert.Contains(t, buf.String(), "METRICS_BACKEND")
+ assert.Contains(t, buf.String(), "SPAN_STORAGE")
}
func TestMain(m *testing.M) {
diff --git a/cmd/internal/flags/admin_test.go b/cmd/internal/flags/admin_test.go
index 244795a3869..74eaaf525fe 100644
--- a/cmd/internal/flags/admin_test.go
+++ b/cmd/internal/flags/admin_test.go
@@ -95,8 +95,7 @@ func TestAdminWithFailedFlags(t *testing.T) {
})
require.NoError(t, err)
err = adminServer.initFromViper(v, logger)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "failed to parse admin server TLS options")
+ assert.ErrorContains(t, err, "failed to parse admin server TLS options")
}
func TestAdminServerTLS(t *testing.T) {
diff --git a/cmd/internal/flags/service_test.go b/cmd/internal/flags/service_test.go
index 2dbe07fee35..f50a2bbe97f 100644
--- a/cmd/internal/flags/service_test.go
+++ b/cmd/internal/flags/service_test.go
@@ -70,8 +70,7 @@ func TestStartErrors(t *testing.T) {
require.NoError(t, err)
err = s.Start(v)
if test.expErr != "" {
- require.Error(t, err)
- assert.Contains(t, err.Error(), test.expErr)
+ require.ErrorContains(t, err, test.expErr)
return
}
require.NoError(t, err)
diff --git a/cmd/internal/status/command.go b/cmd/internal/status/command.go
index ef8f3002784..02f2e48683a 100644
--- a/cmd/internal/status/command.go
+++ b/cmd/internal/status/command.go
@@ -58,7 +58,7 @@ func flags(flagSet *flag.FlagSet, adminPort int) *flag.FlagSet {
func convert(httpHostPort string) string {
if strings.HasPrefix(httpHostPort, ":") {
- return fmt.Sprintf("http://127.0.0.1%s", httpHostPort)
+ return "http://127.0.0.1" + httpHostPort
}
- return fmt.Sprintf("http://%s", httpHostPort)
+ return "http://" + httpHostPort
}
diff --git a/cmd/jaeger/config-badger.yaml b/cmd/jaeger/config-badger.yaml
index 3d222bf37bb..158e241cb53 100644
--- a/cmd/jaeger/config-badger.yaml
+++ b/cmd/jaeger/config-badger.yaml
@@ -5,6 +5,16 @@ service:
receivers: [otlp]
processors: [batch]
exporters: [jaeger_storage_exporter]
+ telemetry:
+ resource:
+ service.name: jaeger
+ metrics:
+ level: detailed
+ address: 0.0.0.0:8888
+ logs:
+ level: info
+ # TODO Initialize telemetery tracer once OTEL released new feature.
+ # https://github.com/open-telemetry/opentelemetry-collector/issues/10663
extensions:
healthcheckv2:
diff --git a/cmd/jaeger/config-cassandra.yaml b/cmd/jaeger/config-cassandra.yaml
index 0076fa48fd0..3ead38258c2 100644
--- a/cmd/jaeger/config-cassandra.yaml
+++ b/cmd/jaeger/config-cassandra.yaml
@@ -5,6 +5,16 @@ service:
receivers: [otlp]
processors: [batch]
exporters: [jaeger_storage_exporter]
+ telemetry:
+ resource:
+ service.name: jaeger
+ metrics:
+ level: detailed
+ address: 0.0.0.0:8888
+ logs:
+ level: debug
+ # TODO Initialize telemetery tracer once OTEL released new feature.
+ # https://github.com/open-telemetry/opentelemetry-collector/issues/10663
extensions:
healthcheckv2:
diff --git a/cmd/jaeger/config-elasticsearch.yaml b/cmd/jaeger/config-elasticsearch.yaml
index bae543e39ee..0883dc3b395 100644
--- a/cmd/jaeger/config-elasticsearch.yaml
+++ b/cmd/jaeger/config-elasticsearch.yaml
@@ -5,6 +5,16 @@ service:
receivers: [otlp]
processors: [batch]
exporters: [jaeger_storage_exporter]
+ telemetry:
+ resource:
+ service.name: jaeger
+ metrics:
+ level: detailed
+ address: 0.0.0.0:8888
+ logs:
+ level: debug
+ # TODO Initialize telemetery tracer once OTEL released new feature.
+ # https://github.com/open-telemetry/opentelemetry-collector/issues/10663
extensions:
healthcheckv2:
diff --git a/cmd/jaeger/config-kafka-collector.yaml b/cmd/jaeger/config-kafka-collector.yaml
index 28e178075a0..b04e05d177b 100644
--- a/cmd/jaeger/config-kafka-collector.yaml
+++ b/cmd/jaeger/config-kafka-collector.yaml
@@ -10,6 +10,7 @@ service:
service.name: jaeger_collector
metrics:
level: detailed
+ address: 0.0.0.0:8888
extensions:
healthcheckv2:
diff --git a/cmd/jaeger/config-kafka-ingester.yaml b/cmd/jaeger/config-kafka-ingester.yaml
index a16bc8a9490..e3947f531b7 100644
--- a/cmd/jaeger/config-kafka-ingester.yaml
+++ b/cmd/jaeger/config-kafka-ingester.yaml
@@ -6,8 +6,11 @@ service:
processors: [batch]
exporters: [jaeger_storage_exporter]
telemetry:
+ resource:
+ service.name: jaeger
metrics:
- address: 0.0.0.0:8889
+ level: detailed
+ address: 0.0.0.0:8888
logs:
level: debug
diff --git a/cmd/jaeger/config-opensearch.yaml b/cmd/jaeger/config-opensearch.yaml
index e6b65e121e5..1fe57d42c39 100644
--- a/cmd/jaeger/config-opensearch.yaml
+++ b/cmd/jaeger/config-opensearch.yaml
@@ -5,6 +5,16 @@ service:
receivers: [otlp]
processors: [batch]
exporters: [jaeger_storage_exporter]
+ telemetry:
+ resource:
+ service.name: jaeger
+ metrics:
+ level: detailed
+ address: 0.0.0.0:8888
+ logs:
+ level: debug
+ # TODO Initialize telemetery tracer once OTEL released new feature.
+ # https://github.com/open-telemetry/opentelemetry-collector/issues/10663
extensions:
healthcheckv2:
diff --git a/cmd/jaeger/config-remote-storage.yaml b/cmd/jaeger/config-remote-storage.yaml
index 1f5cc699df5..8402281c17b 100644
--- a/cmd/jaeger/config-remote-storage.yaml
+++ b/cmd/jaeger/config-remote-storage.yaml
@@ -5,6 +5,16 @@ service:
receivers: [otlp]
processors: [batch]
exporters: [jaeger_storage_exporter]
+ telemetry:
+ resource:
+ service.name: jaeger
+ metrics:
+ level: detailed
+ address: 0.0.0.0:8888
+ logs:
+ level: debug
+ # TODO Initialize telemetery tracer once OTEL released new feature.
+ # https://github.com/open-telemetry/opentelemetry-collector/issues/10663
extensions:
healthcheckv2:
diff --git a/cmd/jaeger/config-tail-sampling-always-sample.yaml b/cmd/jaeger/config-tail-sampling-always-sample.yaml
index 9f0f238f52b..cdba426ef10 100644
--- a/cmd/jaeger/config-tail-sampling-always-sample.yaml
+++ b/cmd/jaeger/config-tail-sampling-always-sample.yaml
@@ -6,8 +6,15 @@ service:
processors: [tail_sampling]
exporters: [jaeger_storage_exporter]
telemetry:
+ resource:
+ service.name: jaeger
+ metrics:
+ level: detailed
+ address: 0.0.0.0:8888
logs:
- level: DEBUG
+ level: debug
+ # TODO Initialize telemetery tracer once OTEL released new feature.
+ # https://github.com/open-telemetry/opentelemetry-collector/issues/10663
extensions:
healthcheckv2:
diff --git a/cmd/jaeger/config-tail-sampling-service-name-policy.yaml b/cmd/jaeger/config-tail-sampling-service-name-policy.yaml
index 4b7ffa1fa0a..97ee2a7e53f 100644
--- a/cmd/jaeger/config-tail-sampling-service-name-policy.yaml
+++ b/cmd/jaeger/config-tail-sampling-service-name-policy.yaml
@@ -6,8 +6,15 @@ service:
processors: [tail_sampling]
exporters: [jaeger_storage_exporter]
telemetry:
+ resource:
+ service.name: jaeger
+ metrics:
+ level: detailed
+ address: 0.0.0.0:8888
logs:
- level: DEBUG
+ level: debug
+ # TODO Initialize telemetery tracer once OTEL released new feature.
+ # https://github.com/open-telemetry/opentelemetry-collector/issues/10663
extensions:
healthcheckv2:
diff --git a/cmd/jaeger/config.yaml b/cmd/jaeger/config.yaml
index c1615d86460..2df3addb078 100644
--- a/cmd/jaeger/config.yaml
+++ b/cmd/jaeger/config.yaml
@@ -5,6 +5,16 @@ service:
receivers: [otlp, jaeger, zipkin]
processors: [batch, adaptive_sampling]
exporters: [jaeger_storage_exporter]
+ telemetry:
+ resource:
+ service.name: jaeger
+ metrics:
+ level: detailed
+ address: 0.0.0.0:8888
+ logs:
+ level: debug
+ # TODO Initialize telemetery tracer once OTEL released new feature.
+ # https://github.com/open-telemetry/opentelemetry-collector/issues/10663
extensions:
healthcheckv2:
diff --git a/cmd/jaeger/internal/all-in-one.yaml b/cmd/jaeger/internal/all-in-one.yaml
index bc5433b67c5..5417b95d133 100644
--- a/cmd/jaeger/internal/all-in-one.yaml
+++ b/cmd/jaeger/internal/all-in-one.yaml
@@ -11,6 +11,8 @@ service:
metrics:
level: detailed
address: 0.0.0.0:8888
+ logs:
+ level: info
# TODO Initialize telemetery tracer once OTEL released new feature.
# https://github.com/open-telemetry/opentelemetry-collector/issues/10663
diff --git a/cmd/jaeger/internal/exporters/storageexporter/exporter_test.go b/cmd/jaeger/internal/exporters/storageexporter/exporter_test.go
index 628eae6dfb3..5ebe56c90aa 100644
--- a/cmd/jaeger/internal/exporters/storageexporter/exporter_test.go
+++ b/cmd/jaeger/internal/exporters/storageexporter/exporter_test.go
@@ -75,7 +75,6 @@ func TestExporterStartBadNameError(t *testing.T) {
},
}
err := exp.start(context.Background(), host)
- require.Error(t, err)
require.ErrorContains(t, err, "cannot find storage factory")
}
@@ -95,7 +94,6 @@ func TestExporterStartBadSpanstoreError(t *testing.T) {
},
}
err := exp.start(context.Background(), host)
- require.Error(t, err)
require.ErrorContains(t, err, "mocked error")
}
diff --git a/cmd/jaeger/internal/extension/jaegerquery/server_test.go b/cmd/jaeger/internal/extension/jaegerquery/server_test.go
index e17875a707a..6fd95566e9f 100644
--- a/cmd/jaeger/internal/extension/jaegerquery/server_test.go
+++ b/cmd/jaeger/internal/extension/jaegerquery/server_test.go
@@ -5,6 +5,7 @@ package jaegerquery
import (
"context"
+ "errors"
"fmt"
"net/http"
"testing"
@@ -42,28 +43,28 @@ type fakeFactory struct {
func (ff fakeFactory) CreateDependencyReader() (dependencystore.Reader, error) {
if ff.name == "need-dependency-reader-error" {
- return nil, fmt.Errorf("test-error")
+ return nil, errors.New("test-error")
}
return &depsmocks.Reader{}, nil
}
func (ff fakeFactory) CreateSpanReader() (spanstore.Reader, error) {
if ff.name == "need-span-reader-error" {
- return nil, fmt.Errorf("test-error")
+ return nil, errors.New("test-error")
}
return &spanstoremocks.Reader{}, nil
}
func (ff fakeFactory) CreateSpanWriter() (spanstore.Writer, error) {
if ff.name == "need-span-writer-error" {
- return nil, fmt.Errorf("test-error")
+ return nil, errors.New("test-error")
}
return &spanstoremocks.Writer{}, nil
}
func (ff fakeFactory) Initialize(metrics.Factory, *zap.Logger) error {
if ff.name == "need-initialize-error" {
- return fmt.Errorf("test-error")
+ return errors.New("test-error")
}
return nil
}
@@ -75,14 +76,14 @@ type fakeMetricsFactory struct {
// Initialize implements storage.MetricsFactory.
func (fmf fakeMetricsFactory) Initialize(*zap.Logger) error {
if fmf.name == "need-initialize-error" {
- return fmt.Errorf("test-error")
+ return errors.New("test-error")
}
return nil
}
func (fmf fakeMetricsFactory) CreateMetricsReader() (metricsstore.Reader, error) {
if fmf.name == "need-metrics-reader-error" {
- return nil, fmt.Errorf("test-error")
+ return nil, errors.New("test-error")
}
return &metricsstoremocks.Reader{}, nil
}
diff --git a/cmd/jaeger/internal/extension/jaegerstorage/config.go b/cmd/jaeger/internal/extension/jaegerstorage/config.go
index 0ae2a59895b..5f5189841df 100644
--- a/cmd/jaeger/internal/extension/jaegerstorage/config.go
+++ b/cmd/jaeger/internal/extension/jaegerstorage/config.go
@@ -4,6 +4,7 @@
package jaegerstorage
import (
+ "errors"
"fmt"
"reflect"
"time"
@@ -96,7 +97,7 @@ func (cfg *Backend) Unmarshal(conf *confmap.Conf) error {
func (cfg *Config) Validate() error {
if len(cfg.Backends) == 0 {
- return fmt.Errorf("at least one storage is required")
+ return errors.New("at least one storage is required")
}
for name, b := range cfg.Backends {
empty := Backend{}
diff --git a/cmd/jaeger/internal/extension/jaegerstorage/extension_test.go b/cmd/jaeger/internal/extension/jaegerstorage/extension_test.go
index deac35b2b02..8b49292a600 100644
--- a/cmd/jaeger/internal/extension/jaegerstorage/extension_test.go
+++ b/cmd/jaeger/internal/extension/jaegerstorage/extension_test.go
@@ -6,7 +6,7 @@ package jaegerstorage
import (
"context"
"encoding/json"
- "fmt"
+ "errors"
"net/http"
"net/http/httptest"
"testing"
@@ -88,7 +88,7 @@ func TestStorageExtensionType(t *testing.T) {
}
func TestStorageFactoryBadShutdownError(t *testing.T) {
- shutdownError := fmt.Errorf("shutdown error")
+ shutdownError := errors.New("shutdown error")
ext := storageExt{
factories: map[string]storage.Factory{
"foo": errorFactory{closeErr: shutdownError},
diff --git a/cmd/jaeger/internal/integration/storagecleaner/extension_test.go b/cmd/jaeger/internal/integration/storagecleaner/extension_test.go
index d19b694b585..81191ff48ef 100644
--- a/cmd/jaeger/internal/integration/storagecleaner/extension_test.go
+++ b/cmd/jaeger/internal/integration/storagecleaner/extension_test.go
@@ -5,6 +5,7 @@ package storagecleaner
import (
"context"
+ "errors"
"fmt"
"net/http"
"sync/atomic"
@@ -78,7 +79,7 @@ func TestStorageCleanerExtension(t *testing.T) {
},
{
name: "good storage with error",
- factory: &PurgerFactory{err: fmt.Errorf("error")},
+ factory: &PurgerFactory{err: errors.New("error")},
status: http.StatusInternalServerError,
},
{
@@ -131,8 +132,7 @@ func TestGetStorageFactoryError(t *testing.T) {
factory: nil,
})
err := s.Start(context.Background(), host)
- require.Error(t, err)
- require.Contains(t, err.Error(), "cannot find storage factory")
+ require.ErrorContains(t, err, "cannot find storage factory")
}
func TestStorageExtensionStartError(t *testing.T) {
@@ -160,7 +160,7 @@ func TestStorageExtensionStartError(t *testing.T) {
assert.Eventually(t, func() bool {
return startStatus.Load() != nil
}, 5*time.Second, 100*time.Millisecond)
- require.Contains(t, startStatus.Load().Err().Error(), "error starting cleaner server")
+ require.ErrorContains(t, startStatus.Load().Err(), "error starting cleaner server")
}
type testHost struct {
diff --git a/cmd/jaeger/internal/sanitizer/utf8_test.go b/cmd/jaeger/internal/sanitizer/utf8_test.go
index 4956d7e8d62..29c65faf92e 100644
--- a/cmd/jaeger/internal/sanitizer/utf8_test.go
+++ b/cmd/jaeger/internal/sanitizer/utf8_test.go
@@ -43,7 +43,7 @@ var utf8EncodingTests = []struct {
key: invalidUTF8(),
value: "value",
expectedKey: "invalid-tag-key-1",
- expectedValue: getBytesValueFromString(fmt.Sprintf("%s:value", invalidUTF8())),
+ expectedValue: getBytesValueFromString(invalidUTF8() + ":value"),
},
{
name: "valid key + invalid value",
@@ -264,7 +264,7 @@ func TestUTF8Sanitizer_SanitizesNonStringAttributeValueWithInvalidKey(t *testing
Attributes().
Get("invalid-tag-key-1")
require.True(t, ok)
- require.EqualValues(t, getBytesValueFromString(fmt.Sprintf("%s:99", invalidUTF8())), value)
+ require.EqualValues(t, getBytesValueFromString(invalidUTF8()+":99"), value)
}
func TestUTF8Sanitizer_SanitizesMultipleAttributesWithInvalidKeys(t *testing.T) {
@@ -290,8 +290,8 @@ func TestUTF8Sanitizer_SanitizesMultipleAttributesWithInvalidKeys(t *testing.T)
require.Equal(t, 2, got.Len())
expectedValues := []pcommon.Value{
- getBytesValueFromString(fmt.Sprintf("%s:v1", k1)),
- getBytesValueFromString(fmt.Sprintf("%s:v2", k2)),
+ getBytesValueFromString(k1 + ":v1"),
+ getBytesValueFromString(k2 + ":v2"),
}
value, ok := got.
Get("invalid-tag-key-1")
diff --git a/cmd/query/app/apiv3/grpc_handler_test.go b/cmd/query/app/apiv3/grpc_handler_test.go
index c66646a6480..bb3c08d9b59 100644
--- a/cmd/query/app/apiv3/grpc_handler_test.go
+++ b/cmd/query/app/apiv3/grpc_handler_test.go
@@ -5,7 +5,7 @@ package apiv3
import (
"context"
- "fmt"
+ "errors"
"net"
"testing"
@@ -105,15 +105,14 @@ func TestGetTrace(t *testing.T) {
func TestGetTraceStorageError(t *testing.T) {
tsc := newTestServerClient(t)
tsc.reader.On("GetTrace", matchContext, matchTraceID).Return(
- nil, fmt.Errorf("storage_error")).Once()
+ nil, errors.New("storage_error")).Once()
getTraceStream, err := tsc.client.GetTrace(context.Background(), &api_v3.GetTraceRequest{
TraceId: "156",
})
require.NoError(t, err)
recv, err := getTraceStream.Recv()
- require.Error(t, err)
- assert.Contains(t, err.Error(), "storage_error")
+ require.ErrorContains(t, err, "storage_error")
assert.Nil(t, recv)
}
@@ -129,8 +128,7 @@ func TestGetTraceTraceIDError(t *testing.T) {
})
require.NoError(t, err)
recv, err := getTraceStream.Recv()
- require.Error(t, err)
- assert.Contains(t, err.Error(), "strconv.ParseUint:")
+ require.ErrorContains(t, err, "strconv.ParseUint:")
assert.Nil(t, recv)
}
@@ -170,8 +168,7 @@ func TestFindTracesQueryNil(t *testing.T) {
responseStream, err := tsc.client.FindTraces(context.Background(), &api_v3.FindTracesRequest{})
require.NoError(t, err)
recv, err := responseStream.Recv()
- require.Error(t, err)
- assert.Contains(t, err.Error(), "missing query")
+ require.ErrorContains(t, err, "missing query")
assert.Nil(t, recv)
responseStream, err = tsc.client.FindTraces(context.Background(), &api_v3.FindTracesRequest{
@@ -182,15 +179,14 @@ func TestFindTracesQueryNil(t *testing.T) {
})
require.NoError(t, err)
recv, err = responseStream.Recv()
- require.Error(t, err)
- assert.Contains(t, err.Error(), "start time min and max are required parameters")
+ require.ErrorContains(t, err, "start time min and max are required parameters")
assert.Nil(t, recv)
}
func TestFindTracesStorageError(t *testing.T) {
tsc := newTestServerClient(t)
tsc.reader.On("FindTraces", matchContext, mock.AnythingOfType("*spanstore.TraceQueryParameters")).Return(
- nil, fmt.Errorf("storage_error"), nil).Once()
+ nil, errors.New("storage_error"), nil).Once()
responseStream, err := tsc.client.FindTraces(context.Background(), &api_v3.FindTracesRequest{
Query: &api_v3.TraceQueryParameters{
@@ -202,8 +198,7 @@ func TestFindTracesStorageError(t *testing.T) {
})
require.NoError(t, err)
recv, err := responseStream.Recv()
- require.Error(t, err)
- assert.Contains(t, err.Error(), "storage_error")
+ require.ErrorContains(t, err, "storage_error")
assert.Nil(t, recv)
}
@@ -220,11 +215,10 @@ func TestGetServices(t *testing.T) {
func TestGetServicesStorageError(t *testing.T) {
tsc := newTestServerClient(t)
tsc.reader.On("GetServices", matchContext).Return(
- nil, fmt.Errorf("storage_error")).Once()
+ nil, errors.New("storage_error")).Once()
response, err := tsc.client.GetServices(context.Background(), &api_v3.GetServicesRequest{})
- require.Error(t, err)
- assert.Contains(t, err.Error(), "storage_error")
+ require.ErrorContains(t, err, "storage_error")
assert.Nil(t, response)
}
@@ -249,10 +243,9 @@ func TestGetOperations(t *testing.T) {
func TestGetOperationsStorageError(t *testing.T) {
tsc := newTestServerClient(t)
tsc.reader.On("GetOperations", matchContext, mock.AnythingOfType("spanstore.OperationQueryParameters")).Return(
- nil, fmt.Errorf("storage_error")).Once()
+ nil, errors.New("storage_error")).Once()
response, err := tsc.client.GetOperations(context.Background(), &api_v3.GetOperationsRequest{})
- require.Error(t, err)
- assert.Contains(t, err.Error(), "storage_error")
+ require.ErrorContains(t, err, "storage_error")
assert.Nil(t, response)
}
diff --git a/cmd/query/app/flags.go b/cmd/query/app/flags.go
index c3fd2e0cdab..df40f502ff2 100644
--- a/cmd/query/app/flags.go
+++ b/cmd/query/app/flags.go
@@ -161,7 +161,7 @@ func stringSliceAsHeader(slice []string) (http.Header, error) {
header, err := tp.ReadMIMEHeader()
if err != nil && !errors.Is(err, io.EOF) {
- return nil, fmt.Errorf("failed to parse headers")
+ return nil, errors.New("failed to parse headers")
}
return http.Header(header), nil
diff --git a/cmd/query/app/flags_test.go b/cmd/query/app/flags_test.go
index c8e623ed07c..14c6237953b 100644
--- a/cmd/query/app/flags_test.go
+++ b/cmd/query/app/flags_test.go
@@ -179,8 +179,7 @@ func TestQueryOptions_FailedTLSFlags(t *testing.T) {
})
require.NoError(t, err)
_, err = new(QueryOptions).InitFromViper(v, zap.NewNop())
- require.Error(t, err)
- assert.Contains(t, err.Error(), "failed to process "+test+" TLS options")
+ assert.ErrorContains(t, err, "failed to process "+test+" TLS options")
})
}
}
diff --git a/cmd/query/app/grpc_handler_test.go b/cmd/query/app/grpc_handler_test.go
index 6c83f01efec..016ee19b77f 100644
--- a/cmd/query/app/grpc_handler_test.go
+++ b/cmd/query/app/grpc_handler_test.go
@@ -7,7 +7,6 @@ package app
import (
"context"
"errors"
- "fmt"
"net"
"testing"
"time"
@@ -407,7 +406,7 @@ func TestFindTracesMissingQuery_GRPC(t *testing.T) {
func TestFindTracesFailure_GRPC(t *testing.T) {
withServerAndClient(t, func(server *grpcServer, client *grpcClient) {
- mockErrorGRPC := fmt.Errorf("whatsamattayou")
+ mockErrorGRPC := errors.New("whatsamattayou")
server.spanReader.On("FindTraces", mock.AnythingOfType("*context.valueCtx"), mock.AnythingOfType("*spanstore.TraceQueryParameters")).
Return(nil, mockErrorGRPC).Once()
@@ -1152,7 +1151,7 @@ func TestTenancyContextFlowGRPC(t *testing.T) {
assert.Equal(t, expected.expectedTrace.Spans[0].TraceID, spanResChunk.Spans[0].TraceID)
}
if expected.expectedTraceErr != nil {
- assert.Contains(t, err.Error(), expected.expectedTraceErr.Error())
+ assert.ErrorContains(t, err, expected.expectedTraceErr.Error())
}
})
}
diff --git a/cmd/query/app/http_handler_test.go b/cmd/query/app/http_handler_test.go
index 54ebd5ea732..5da9482af87 100644
--- a/cmd/query/app/http_handler_test.go
+++ b/cmd/query/app/http_handler_test.go
@@ -214,7 +214,7 @@ func TestLogOnServerError(t *testing.T) {
type httpResponseErrWriter struct{}
func (*httpResponseErrWriter) Write([]byte) (int, error) {
- return 0, fmt.Errorf("failed to write")
+ return 0, errors.New("failed to write")
}
func (*httpResponseErrWriter) WriteHeader(int /* statusCode */) {}
func (*httpResponseErrWriter) Header() http.Header {
@@ -468,7 +468,7 @@ func TestSearchModelConversionFailure(t *testing.T) {
func TestSearchDBFailure(t *testing.T) {
ts := initializeTestServer(t)
ts.spanReader.On("FindTraces", mock.AnythingOfType("*context.valueCtx"), mock.AnythingOfType("*spanstore.TraceQueryParameters")).
- Return(nil, fmt.Errorf("whatsamattayou")).Once()
+ Return(nil, errors.New("whatsamattayou")).Once()
var response structuredResponse
err := getJSON(ts.server.URL+`/api/traces?service=service&start=0&end=0&operation=operation&limit=200&minDuration=20ms`, &response)
@@ -779,8 +779,7 @@ func TestMetricsReaderError(t *testing.T) {
err := getJSON(ts.server.URL+tc.urlPath, &response)
// Verify
- require.Error(t, err)
- assert.Contains(t, err.Error(), tc.wantErrorMessage)
+ assert.ErrorContains(t, err, tc.wantErrorMessage)
})
}
}
@@ -814,8 +813,7 @@ func TestMetricsQueryDisabled(t *testing.T) {
err := getJSON(ts.server.URL+tc.urlPath, &response)
// Verify
- require.Error(t, err)
- assert.Contains(t, err.Error(), tc.wantErrorMessage)
+ assert.ErrorContains(t, err, tc.wantErrorMessage)
})
}
}
@@ -993,7 +991,7 @@ func TestSearchTenancyFlowTenantHTTP(t *testing.T) {
ts.server.URL+`/api/traces?traceID=1&traceID=2`,
map[string]string{"x-tenant": "megacorp"},
&responseMegacorp)
- assert.Contains(t, err.Error(), "storage error")
+ require.ErrorContains(t, err, "storage error")
assert.Empty(t, responseMegacorp.Errors)
assert.Nil(t, responseMegacorp.Data)
}
diff --git a/cmd/query/app/query_parser_test.go b/cmd/query/app/query_parser_test.go
index e671cc6163d..de5e4496807 100644
--- a/cmd/query/app/query_parser_test.go
+++ b/cmd/query/app/query_parser_test.go
@@ -305,8 +305,7 @@ func TestParameterErrors(t *testing.T) {
err := getJSON(ts.server.URL+tc.urlPath, &response)
// Verify
- require.Error(t, err)
- assert.Contains(t, err.Error(), tc.wantErrorMessage)
+ assert.ErrorContains(t, err, tc.wantErrorMessage)
})
}
}
diff --git a/cmd/query/app/static_handler_test.go b/cmd/query/app/static_handler_test.go
index 40175546d63..fa644ebad9b 100644
--- a/cmd/query/app/static_handler_test.go
+++ b/cmd/query/app/static_handler_test.go
@@ -6,6 +6,7 @@ package app
import (
"encoding/json"
+ "errors"
"fmt"
"io"
"net/http"
@@ -32,8 +33,7 @@ func TestNotExistingUiConfig(t *testing.T) {
handler, err := NewStaticAssetsHandler("/foo/bar", StaticAssetsHandlerOptions{
Logger: zap.NewNop(),
})
- require.Error(t, err)
- assert.Contains(t, err.Error(), "no such file or directory")
+ require.ErrorContains(t, err, "no such file or directory")
assert.Nil(t, handler)
}
@@ -169,8 +169,7 @@ func TestNewStaticAssetsHandlerErrors(t *testing.T) {
BasePath: base,
Logger: zap.NewNop(),
})
- require.Errorf(t, err, "basePath=%s", base)
- assert.Contains(t, err.Error(), "invalid base path")
+ assert.ErrorContainsf(t, err, "invalid base path", "basePath=%s", base)
}
}
@@ -311,7 +310,7 @@ type fakeFile struct {
}
func (*fakeFile) Read([]byte) (n int, err error) {
- return 0, fmt.Errorf("read error")
+ return 0, errors.New("read error")
}
func TestLoadIndexHTMLReadError(t *testing.T) {
diff --git a/cmd/remote-storage/app/flags_test.go b/cmd/remote-storage/app/flags_test.go
index 2d90c3ae560..206a9f7dfa6 100644
--- a/cmd/remote-storage/app/flags_test.go
+++ b/cmd/remote-storage/app/flags_test.go
@@ -31,6 +31,5 @@ func TestFailedTLSFlags(t *testing.T) {
})
require.NoError(t, err)
_, err = new(Options).InitFromViper(v, zap.NewNop())
- require.Error(t, err)
- assert.Contains(t, err.Error(), "failed to process gRPC TLS options")
+ assert.ErrorContains(t, err, "failed to process gRPC TLS options")
}
diff --git a/cmd/remote-storage/app/server_test.go b/cmd/remote-storage/app/server_test.go
index 5b29c0b842e..292266dd9ce 100644
--- a/cmd/remote-storage/app/server_test.go
+++ b/cmd/remote-storage/app/server_test.go
@@ -55,16 +55,13 @@ func TestNewServer_CreateStorageErrors(t *testing.T) {
)
}
_, err := f()
- require.Error(t, err)
- assert.Contains(t, err.Error(), "no reader")
+ require.ErrorContains(t, err, "no reader")
_, err = f()
- require.Error(t, err)
- assert.Contains(t, err.Error(), "no writer")
+ require.ErrorContains(t, err, "no writer")
_, err = f()
- require.Error(t, err)
- assert.Contains(t, err.Error(), "no deps")
+ require.ErrorContains(t, err, "no deps")
s, err := f()
require.NoError(t, err)
@@ -127,8 +124,7 @@ func TestNewServer_TLSConfigError(t *testing.T) {
tenancy.NewManager(&tenancy.Options{}),
telset,
)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "invalid TLS config")
+ assert.ErrorContains(t, err, "invalid TLS config")
}
func TestCreateGRPCHandler(t *testing.T) {
@@ -138,8 +134,7 @@ func TestCreateGRPCHandler(t *testing.T) {
storageMocks.writer.On("WriteSpan", mock.Anything, mock.Anything).Return(errors.New("writer error"))
_, err = h.WriteSpan(context.Background(), &storage_v1.WriteSpanRequest{})
- require.Error(t, err)
- assert.Contains(t, err.Error(), "writer error")
+ require.ErrorContains(t, err, "writer error")
storageMocks.depReader.On(
"GetDependencies",
@@ -148,20 +143,16 @@ func TestCreateGRPCHandler(t *testing.T) {
mock.Anything, // lookback
).Return(nil, errors.New("deps error"))
_, err = h.GetDependencies(context.Background(), &storage_v1.GetDependenciesRequest{})
- require.Error(t, err)
- assert.Contains(t, err.Error(), "deps error")
+ require.ErrorContains(t, err, "deps error")
err = h.GetArchiveTrace(nil, nil)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "not implemented")
+ require.ErrorContains(t, err, "not implemented")
_, err = h.WriteArchiveSpan(context.Background(), nil)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "not implemented")
+ require.ErrorContains(t, err, "not implemented")
err = h.WriteSpanStream(nil)
- require.Error(t, err)
- assert.Contains(t, err.Error(), "not implemented")
+ assert.ErrorContains(t, err, "not implemented")
}
var testCases = []struct {
diff --git a/crossdock/docker-compose.yml b/crossdock/docker-compose.yml
index 59707a96d07..a476f075f58 100644
--- a/crossdock/docker-compose.yml
+++ b/crossdock/docker-compose.yml
@@ -55,6 +55,7 @@ services:
- "8080"
environment:
- JAEGER_COLLECTOR_HC_HOST_PORT=jaeger-collector:${JAEGER_COLLECTOR_HC_PORT}
+ - JAEGER_COLLECTOR_HOST_PORT=jaeger-collector:${JAEGER_COLLECTOR_HOST_PORT}
depends_on:
- jaeger-query
- jaeger-collector
diff --git a/crossdock/main.go b/crossdock/main.go
index 531ef0fc630..f4833886a42 100644
--- a/crossdock/main.go
+++ b/crossdock/main.go
@@ -19,9 +19,8 @@ import (
const (
behaviorEndToEnd = "endtoend"
- envAgentHostPort = "JAEGER_AGENT_HOST_PORT"
- envQueryHostPort = "JAEGER_QUERY_HOST_PORT"
-
+ envCollectorSamplingHostPort = "JAEGER_COLLECTOR_HOST_PORT"
+ envQueryHostPort = "JAEGER_QUERY_HOST_PORT"
envQueryHealthcheckHostPort = "JAEGER_QUERY_HC_HOST_PORT"
envCollectorHealthcheckHostPort = "JAEGER_COLLECTOR_HC_HOST_PORT"
)
@@ -29,9 +28,8 @@ const (
var (
logger, _ = zap.NewDevelopment()
- agentHostPort string
- queryHostPort string
-
+ collectorSamplingHostPort string
+ queryHostPort string
queryHealthcheckHostPort string
collectorHealthcheckHostPort string
)
@@ -44,7 +42,7 @@ type clientHandler struct {
}
func main() {
- agentHostPort = getEnv(envAgentHostPort, "jaeger-agent:5778")
+ collectorSamplingHostPort = getEnv(envCollectorSamplingHostPort, "jaeger-collector:14268")
queryHostPort = getEnv(envQueryHostPort, "jaeger-query:16686")
queryHealthcheckHostPort = getEnv(envQueryHealthcheckHostPort, "jaeger-query:16687")
collectorHealthcheckHostPort = getEnv(envCollectorHealthcheckHostPort, "jaeger-collector:14269")
@@ -78,9 +76,9 @@ func (h *clientHandler) initialize() {
httpHealthCheck(logger, "jaeger-collector", "http://"+collectorHealthcheckHostPort)
queryService := services.NewQueryService("http://"+queryHostPort, logger)
- agentService := services.NewAgentService("http://"+agentHostPort, logger)
+ collectorService := services.NewCollectorService("http://"+collectorSamplingHostPort, logger)
- traceHandler := services.NewTraceHandler(queryService, agentService, logger)
+ traceHandler := services.NewTraceHandler(queryService, collectorService, logger)
behaviors := crossdock.Behaviors{
behaviorEndToEnd: traceHandler.EndToEndTest,
}
diff --git a/crossdock/services/agent.go b/crossdock/services/agent.go
index 126ad17f429..6104ae74a5a 100644
--- a/crossdock/services/agent.go
+++ b/crossdock/services/agent.go
@@ -18,30 +18,36 @@ import (
var errSamplingRateMissing = errors.New("sampling rate is missing")
-// AgentService is the service used to report traces to the collector.
-type AgentService interface {
+// CollectorService is the service used to report traces to the collector.
+type CollectorService interface {
GetSamplingRate(service, operation string) (float64, error)
}
-type agentService struct {
+type collectorService struct {
url string
logger *zap.Logger
}
-// NewAgentService returns an instance of AgentService.
-func NewAgentService(url string, logger *zap.Logger) AgentService {
- return &agentService{
+// NewCollectorService returns an instance of CollectorService.
+func NewCollectorService(url string, logger *zap.Logger) CollectorService {
+ logger.Info("Initializing Collector Service",
+ zap.String("url", url))
+ return &collectorService{
url: url,
logger: logger,
}
}
func getSamplingURL(url string) string {
- return url + "/sampling?service=%s"
+ return url + "/api/sampling?service=%s"
}
// GetSamplingRate returns the sampling rate for the service-operation from the agent service.
-func (s *agentService) GetSamplingRate(service, operation string) (float64, error) {
+func (s *collectorService) GetSamplingRate(service, operation string) (float64, error) {
+ s.logger.Info("Getting sampling rate",
+ zap.String("url", s.url),
+ zap.String("service", service),
+ zap.String("operation", operation))
url := fmt.Sprintf(getSamplingURL(s.url), getTracerServiceName(service))
resp, err := http.Get(url)
if err != nil {
@@ -52,7 +58,7 @@ func (s *agentService) GetSamplingRate(service, operation string) (float64, erro
if err != nil {
return 0, err
}
- s.logger.Info("Retrieved sampling rates from agent", zap.String("body", string(body)))
+ s.logger.Info("Retrieved sampling rates from collector", zap.String("body", string(body)))
response, err := p2json.SamplingStrategyResponseFromJSON(body)
if err != nil {
diff --git a/crossdock/services/agent_test.go b/crossdock/services/agent_test.go
index ac1099a0756..98dbf8e0995 100644
--- a/crossdock/services/agent_test.go
+++ b/crossdock/services/agent_test.go
@@ -52,10 +52,14 @@ func TestGetSamplingRateInternal(t *testing.T) {
}
}
-type testAgentHandler struct{}
+type testAgentHandler struct {
+ logger *zap.Logger
+}
-func (*testAgentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+func (h *testAgentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
svc := r.FormValue("service")
+ h.logger.Info("Handling sampling request",
+ zap.String("service", svc))
body := []byte("bad json")
if svc == "crossdock-svc" {
response := api_v2.SamplingStrategyResponse{
@@ -77,16 +81,19 @@ func (*testAgentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func TestGetSamplingRate(t *testing.T) {
- handler := &testAgentHandler{}
+ logger := zap.NewExample()
+ handler := &testAgentHandler{logger: logger}
server := httptest.NewServer(handler)
defer server.Close()
// Test with no http server
- agent := NewAgentService("", zap.NewNop())
+ agent := NewCollectorService("", zap.NewNop())
_, err := agent.GetSamplingRate("svc", "op")
require.Error(t, err)
- agent = NewAgentService(server.URL, zap.NewNop())
+ agent = NewCollectorService(server.URL, zap.NewNop())
+ logger.Info("Testing with mock server",
+ zap.String("url", server.URL))
rate, err := agent.GetSamplingRate("svc", "op")
require.NoError(t, err)
assert.InDelta(t, 1.0, rate, 0.01)
@@ -100,7 +107,7 @@ func TestGetSamplingRateReadAllErr(t *testing.T) {
w.Header().Set("Content-Length", "1")
}))
defer server.Close()
- agent := NewAgentService(server.URL, zap.NewNop())
+ agent := NewCollectorService(server.URL, zap.NewNop())
_, err := agent.GetSamplingRate("svc", "op")
require.EqualError(t, err, "unexpected EOF")
}
diff --git a/crossdock/services/common.go b/crossdock/services/common.go
index 891d9fd1a0e..93140ba9adb 100644
--- a/crossdock/services/common.go
+++ b/crossdock/services/common.go
@@ -4,10 +4,6 @@
package services
-import (
- "fmt"
-)
-
func getTracerServiceName(service string) string {
- return fmt.Sprintf("crossdock-%s", service)
+ return "crossdock-" + service
}
diff --git a/crossdock/services/tracehandler.go b/crossdock/services/tracehandler.go
index 0b386781bf1..a1f29686722 100644
--- a/crossdock/services/tracehandler.go
+++ b/crossdock/services/tracehandler.go
@@ -46,7 +46,7 @@ type testFunc func(service string, request *traceRequest) ([]*ui.Trace, error)
// TraceHandler handles creating traces and verifying them
type TraceHandler struct {
query QueryService
- agent AgentService
+ agent CollectorService
logger *zap.Logger
getClientURL func(service string) string
getTags func() map[string]string
@@ -57,7 +57,7 @@ type TraceHandler struct {
}
// NewTraceHandler returns a TraceHandler that can create traces and verify them
-func NewTraceHandler(query QueryService, agent AgentService, logger *zap.Logger) *TraceHandler {
+func NewTraceHandler(query QueryService, agent CollectorService, logger *zap.Logger) *TraceHandler {
return &TraceHandler{
query: query,
agent: agent,
@@ -174,7 +174,7 @@ func validateAdaptiveSamplingTraces(expected *traceRequest, actual []*ui.Trace)
return fmt.Errorf("%s tag value should be '%s'", samplerTypeKey, jaeger.SamplerTypeProbabilistic)
}
if isDefaultProbability(probability) {
- return fmt.Errorf("adaptive sampling probability not used")
+ return errors.New("adaptive sampling probability not used")
}
}
return nil
@@ -201,7 +201,7 @@ func (h *TraceHandler) createAndRetrieveTraces(service string, request *traceReq
}
traces := h.getTraces(service, request.Operation, request.Tags)
if len(traces) == 0 {
- return nil, fmt.Errorf("could not retrieve traces from query service")
+ return nil, errors.New("could not retrieve traces from query service")
}
return traces, nil
}
@@ -261,7 +261,7 @@ func validateTraces(expected *traceRequest, actual []*ui.Trace) error {
}
tags := convertTagsIntoMap(trace.Spans[0].Tags)
if !expectedTagsExist(expected.Tags, tags) {
- return fmt.Errorf("expected tags not found")
+ return errors.New("expected tags not found")
}
}
return nil
diff --git a/crossdock/services/tracehandler_test.go b/crossdock/services/tracehandler_test.go
index baf3634d8b9..64c35e3cf8e 100644
--- a/crossdock/services/tracehandler_test.go
+++ b/crossdock/services/tracehandler_test.go
@@ -7,10 +7,10 @@ package services
import (
"encoding/json"
"errors"
- "fmt"
"io"
"net/http"
"net/http/httptest"
+ "strconv"
"sync"
"testing"
"time"
@@ -414,7 +414,7 @@ func TestAdaptiveSamplingTestInternal(t *testing.T) {
}
for i, test := range tests {
- t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
+ t.Run(strconv.Itoa(i), func(t *testing.T) {
query := &mocks.QueryService{}
agent := &mocks.AgentService{}
diff --git a/docker-compose/monitor/Makefile b/docker-compose/monitor/Makefile
index b4bee22b110..821307a2018 100644
--- a/docker-compose/monitor/Makefile
+++ b/docker-compose/monitor/Makefile
@@ -39,4 +39,3 @@ clean-all: clean-jaeger
docker rmi -f jaegertracing/all-in-one:latest ; \
docker rmi -f otel/opentelemetry-collector-contrib:latest ; \
docker rmi -f prom/prometheus:latest ; \
- docker rmi -f grafana/grafana:latest
diff --git a/docker-compose/monitor/README.md b/docker-compose/monitor/README.md
index a126eb89669..2dfc46e9e9a 100644
--- a/docker-compose/monitor/README.md
+++ b/docker-compose/monitor/README.md
@@ -18,7 +18,6 @@ This environment consists the following backend components:
- [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/): vendor agnostic integration layer for traces and metrics. Its main role in this particular development environment is to receive Jaeger spans, forward these spans untouched to Jaeger All-in-one while simultaneously aggregating metrics out of this span data. To learn more about span metrics aggregation, please refer to the [spanmetrics connector documentation][spanmetricsconnectorreadme].
- [Prometheus](https://prometheus.io/): a metrics collection and query engine, used to scrape metrics computed by OpenTelemetry Collector, and presents an API for Jaeger All-in-one to query these metrics.
-
The following diagram illustrates the relationship between these components:
![SPM diagram](./diagram.png)
diff --git a/docker-compose/monitor/grafana.ini b/docker-compose/monitor/grafana.ini
deleted file mode 100644
index a9d59418ea8..00000000000
--- a/docker-compose/monitor/grafana.ini
+++ /dev/null
@@ -1,1327 +0,0 @@
-##################### Grafana Configuration Defaults #####################
-#
-# Do not modify this file in grafana installs
-#
-
-# possible values : production, development
-app_mode = production
-
-# instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty
-instance_name = ${HOSTNAME}
-
-# force migration will run migrations that might cause dataloss
-force_migration = false
-
-#################################### Paths ###############################
-[paths]
-# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)
-data = data
-
-# Temporary files in `data` directory older than given duration will be removed
-temp_data_lifetime = 24h
-
-# Directory where grafana can store logs
-logs = data/log
-
-# Directory where grafana will automatically scan and look for plugins
-plugins = data/plugins
-
-# folder that contains provisioning config files that grafana will apply on startup and while running.
-provisioning = conf/provisioning
-
-#################################### Server ##############################
-[server]
-# Protocol (http, https, h2, socket)
-protocol = http
-
-# The ip address to bind to, empty will bind to all interfaces
-http_addr =
-
-# The http port to use
-http_port = 3000
-
-# The public facing domain name used to access grafana from a browser
-domain = localhost
-
-# Redirect to correct domain if host header does not match domain
-# Prevents DNS rebinding attacks
-enforce_domain = false
-
-# The full public facing url
-root_url = %(protocol)s://%(domain)s:%(http_port)s/
-
-# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
-serve_from_sub_path = false
-
-# Log web requests
-router_logging = false
-
-# the path relative working path
-static_root_path = public
-
-# enable gzip
-enable_gzip = false
-
-# https certs & key file
-cert_file =
-cert_key =
-
-# Unix socket path
-socket = /tmp/grafana.sock
-
-# CDN Url
-cdn_url =
-
-# Sets the maximum time in minutes before timing out read of an incoming request and closing idle connections.
-# `0` means there is no timeout for reading the request.
-read_timeout = 0
-
-#################################### Database ############################
-[database]
-# You can configure the database connection by specifying type, host, name, user and password
-# as separate properties or as on string using the url property.
-
-# Either "mysql", "postgres" or "sqlite3", it's your choice
-type = sqlite3
-host = 127.0.0.1:3306
-name = grafana
-user = root
-# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
-password =
-# Use either URL or the previous fields to configure the database
-# Example: mysql://user:secret@host:port/database
-url =
-
-# Max idle conn setting default is 2
-max_idle_conn = 2
-
-# Max conn setting default is 0 (mean not set)
-max_open_conn =
-
-# Connection Max Lifetime default is 14400 (means 14400 seconds or 4 hours)
-conn_max_lifetime = 14400
-
-# Set to true to log the sql calls and execution times.
-log_queries =
-
-# For "postgres", use either "disable", "require" or "verify-full"
-# For "mysql", use either "true", "false", or "skip-verify".
-ssl_mode = disable
-
-# Database drivers may support different transaction isolation levels.
-# Currently, only "mysql" driver supports isolation levels.
-# If the value is empty - driver's default isolation level is applied.
-# For "mysql" use "READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ" or "SERIALIZABLE".
-isolation_level =
-
-ca_cert_path =
-client_key_path =
-client_cert_path =
-server_cert_name =
-
-# For "sqlite3" only, path relative to data_path setting
-path = grafana.db
-
-# For "sqlite3" only. cache mode setting used for connecting to the database
-cache_mode = private
-
-# For "mysql" only if migrationLocking feature toggle is set. How many seconds to wait before failing to lock the database for the migrations, default is 0.
-locking_attempt_timeout_sec = 0
-
-#################################### Cache server #############################
-[remote_cache]
-# Either "redis", "memcached" or "database" default is "database"
-type = database
-
-# cache connectionstring options
-# database: will use Grafana primary database.
-# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=0,ssl=false`. Only addr is required. ssl may be 'true', 'false', or 'insecure'.
-# memcache: 127.0.0.1:11211
-connstr =
-
-#################################### Data proxy ###########################
-[dataproxy]
-
-# This enables data proxy logging, default is false
-logging = false
-
-# How long the data proxy waits to read the headers of the response before timing out, default is 30 seconds.
-# This setting also applies to core backend HTTP data sources where query requests use an HTTP client with timeout set.
-timeout = 30
-
-# How long the data proxy waits to establish a TCP connection before timing out, default is 10 seconds.
-dialTimeout = 10
-
-# How many seconds the data proxy waits before sending a keepalive request.
-keep_alive_seconds = 30
-
-# How many seconds the data proxy waits for a successful TLS Handshake before timing out.
-tls_handshake_timeout_seconds = 10
-
-# How many seconds the data proxy will wait for a server's first response headers after
-# fully writing the request headers if the request has an "Expect: 100-continue"
-# header. A value of 0 will result in the body being sent immediately, without
-# waiting for the server to approve.
-expect_continue_timeout_seconds = 1
-
-# Optionally limits the total number of connections per host, including connections in the dialing,
-# active, and idle states. On limit violation, dials will block.
-# A value of zero (0) means no limit.
-max_conns_per_host = 0
-
-# The maximum number of idle connections that Grafana will keep alive.
-max_idle_connections = 100
-
-# How many seconds the data proxy keeps an idle connection open before timing out.
-idle_conn_timeout_seconds = 90
-
-# If enabled and user is not anonymous, data proxy will add X-Grafana-User header with username into the request.
-send_user_header = false
-
-# Limit the amount of bytes that will be read/accepted from responses of outgoing HTTP requests.
-response_limit = 0
-
-# Limits the number of rows that Grafana will process from SQL data sources.
-row_limit = 1000000
-
-#################################### Analytics ###########################
-[analytics]
-# Server reporting, sends usage counters to stats.grafana.org every 24 hours.
-# No ip addresses are being tracked, only simple counters to track
-# running instances, dashboard and error counts. It is very helpful to us.
-# Change this option to false to disable reporting.
-reporting_enabled = true
-
-# The name of the distributor of the Grafana instance. Ex hosted-grafana, grafana-labs
-reporting_distributor = grafana-labs
-
-# Set to false to disable all checks to https://grafana.com
-# for new versions of grafana. The check is used
-# in some UI views to notify that a grafana update exists.
-# This option does not cause any auto updates, nor send any information
-# only a GET request to https://raw.githubusercontent.com/grafana/grafana/main/latest.json to get the latest version.
-check_for_updates = true
-
-# Set to false to disable all checks to https://grafana.com
-# for new versions of plugins. The check is used
-# in some UI views to notify that a plugin update exists.
-# This option does not cause any auto updates, nor send any information
-# only a GET request to https://grafana.com to get the latest versions.
-check_for_plugin_updates = true
-
-# Google Analytics universal tracking code, only enabled if you specify an id here
-google_analytics_ua_id =
-
-# Google Analytics 4 tracking code, only enabled if you specify an id here
-google_analytics_4_id =
-
-# Google Tag Manager ID, only enabled if you specify an id here
-google_tag_manager_id =
-
-# Rudderstack write key, enabled only if rudderstack_data_plane_url is also set
-rudderstack_write_key =
-
-# Rudderstack data plane url, enabled only if rudderstack_write_key is also set
-rudderstack_data_plane_url =
-
-# Rudderstack SDK url, optional, only valid if rudderstack_write_key and rudderstack_data_plane_url is also set
-rudderstack_sdk_url =
-
-# Rudderstack Config url, optional, used by Rudderstack SDK to fetch source config
-rudderstack_config_url =
-
-# Application Insights connection string. Specify an URL string to enable this feature.
-application_insights_connection_string =
-
-# Optional. Specifies an Application Insights endpoint URL where the endpoint string is wrapped in backticks ``.
-application_insights_endpoint_url =
-
-# Controls if the UI contains any links to user feedback forms
-feedback_links_enabled = true
-
-#################################### Security ############################
-[security]
-# disable creation of admin user on first start of grafana
-disable_initial_admin_creation = false
-
-# default admin user, created on startup
-admin_user = admin
-
-# default admin password, can be changed before first start of grafana, or in profile settings
-admin_password = admin
-
-# default admin email, created on startup
-admin_email = admin@localhost
-
-# used for signing
-secret_key = SW2YcwTIb9zpOOhoPsMm
-
-# current key provider used for envelope encryption, default to static value specified by secret_key
-encryption_provider = secretKey.v1
-
-# list of configured key providers, space separated (Enterprise only): e.g., awskms.v1 azurekv.v1
-available_encryption_providers =
-
-# disable gravatar profile images
-disable_gravatar = false
-
-# data source proxy whitelist (ip_or_domain:port separated by spaces)
-data_source_proxy_whitelist =
-
-# disable protection against brute force login attempts
-disable_brute_force_login_protection = false
-
-# set to true if you host Grafana behind HTTPS. default is false.
-cookie_secure = false
-
-# set cookie SameSite attribute. defaults to `lax`. can be set to "lax", "strict", "none" and "disabled"
-cookie_samesite = lax
-
-# set to true if you want to allow browsers to render Grafana in a ,