Skip to content

Commit

Permalink
Merge branch 'main' into v2-reader
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 authored Nov 30, 2024
2 parents 840a679 + cedaeaa commit 24a53df
Show file tree
Hide file tree
Showing 126 changed files with 4,240 additions and 1,222 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ cmd/tracegen/tracegen-*
crossdock/crossdock-*

run-crossdock.log
proto-gen/.patched-otel-proto/
__pycache__
.asset-manifest.json
deploy/
Expand Down
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ linters:
# Checks usage of github.com/stretchr/testify.
- testifylint

# Detects the possibility to use variables/constants from the Go standard library.
- usestdlibvars

# TODO consider adding more linters, cf. https://olegk.dev/go-linters-configuration-the-right-version

linters-settings:
Expand Down
6 changes: 6 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ dir: "{{.InterfaceDir}}/mocks/"
mockname: "{{.InterfaceName}}"
filename: "{{.InterfaceName}}.go"
boilerplate-file: .mockery.header.txt

# Flags for future v3 compatibility.
# See https://github.com/vektra/mockery/issues/848
issue-845-fix: true
resolve-type-alias: false

packages:
github.com/jaegertracing/jaeger/cmd/collector/app/sanitizer/cache:
interfaces:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ Dependencies upgrades only.

#### 🚧 Experimental Features

* Implement telemetery struct for v1 components initialization ([@Wise-Wizard](https://github.com/Wise-Wizard) in [#5695](https://github.com/jaegertracing/jaeger/pull/5695))
* Implement telemetry struct for v1 components initialization ([@Wise-Wizard](https://github.com/Wise-Wizard) in [#5695](https://github.com/jaegertracing/jaeger/pull/5695))
* Support default configs for storage backends ([@yurishkuro](https://github.com/yurishkuro) in [#5691](https://github.com/jaegertracing/jaeger/pull/5691))
* Simplify configs organization ([@yurishkuro](https://github.com/yurishkuro) in [#5690](https://github.com/jaegertracing/jaeger/pull/5690))
* Create metrics.factory adapter for otel metrics ([@Wise-Wizard](https://github.com/Wise-Wizard) in [#5661](https://github.com/jaegertracing/jaeger/pull/5661))
Expand Down
17 changes: 13 additions & 4 deletions Makefile.Protobuf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
# instead of the go_package's declared by the imported protof files.
#

DOCKER=docker
DOCKER_PROTOBUF_VERSION=0.5.0
DOCKER_PROTOBUF=jaegertracing/protobuf:$(DOCKER_PROTOBUF_VERSION)
PROTOC := docker run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD} ${DOCKER_PROTOBUF} --proto_path=${PWD}
PROTOC := ${DOCKER} run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD} ${DOCKER_PROTOBUF} --proto_path=${PWD}

PATCHED_OTEL_PROTO_DIR = proto-gen/.patched-otel-proto

PROTO_INCLUDES := \
-Iidl/proto/api_v2 \
-Iidl/proto/api_v3 \
-Imodel/proto/metrics \
-I/usr/include/github.com/gogo/protobuf

Expand Down Expand Up @@ -127,9 +127,18 @@ proto-zipkin:
# Note that the .pb.go types must be generated into the same internal package $(API_V3_PATH)
# where a manually defined traces.go file is located.
API_V3_PATH=cmd/query/app/internal/api_v3
API_V3_PATCHED_DIR=proto-gen/.patched/api_v3
API_V3_PATCHED=$(API_V3_PATCHED_DIR)/query_service.proto
.PHONY: patch-api-v3
patch-api-v3:
mkdir -p $(API_V3_PATCHED_DIR)
cat idl/proto/api_v3/query_service.proto | \
$(SED) -f ./proto-gen/patch-api-v3.sed \
> $(API_V3_PATCHED)

.PHONY: proto-api-v3
proto-api-v3:
$(call proto_compile, $(API_V3_PATH), idl/proto/api_v3/query_service.proto, -Iidl/opentelemetry-proto)
proto-api-v3: patch-api-v3
$(call proto_compile, $(API_V3_PATH), $(API_V3_PATCHED), -I$(API_V3_PATCHED_DIR) -Iidl/opentelemetry-proto)
@echo "🏗️ replace TracesData with internal custom type"
$(SED) -i 's/v1.TracesData/TracesData/g' $(API_V3_PATH)/query_service.pb.go
@echo "🏗️ remove OTEL import because we're not using any other OTLP types"
Expand Down
41 changes: 21 additions & 20 deletions cmd/all-in-one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import (

"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
noopmetric "go.opentelemetry.io/otel/metric/noop"
_ "go.uber.org/automaxprocs"
"go.uber.org/zap"

Expand All @@ -33,17 +31,19 @@ import (
"github.com/jaegertracing/jaeger/pkg/config"
"github.com/jaegertracing/jaeger/pkg/jtracer"
"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/pkg/telemetery"
"github.com/jaegertracing/jaeger/pkg/telemetry"
"github.com/jaegertracing/jaeger/pkg/tenancy"
"github.com/jaegertracing/jaeger/pkg/version"
metricsPlugin "github.com/jaegertracing/jaeger/plugin/metrics"
ss "github.com/jaegertracing/jaeger/plugin/sampling/strategyprovider"
"github.com/jaegertracing/jaeger/plugin/storage"
"github.com/jaegertracing/jaeger/ports"
"github.com/jaegertracing/jaeger/storage/dependencystore"
metricsstoreMetrics "github.com/jaegertracing/jaeger/storage/metricsstore/metrics"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
"github.com/jaegertracing/jaeger/storage_v2/spanstore"

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / spm (v1, all-in-one)

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / hotrod (docker, v1)

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / crossdock

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / all-in-one (v1)

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-arm64

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-s390x

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-ppc64le

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / docker-images

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-windows-amd64

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-amd64

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-darwin-arm64

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-darwin-amd64

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / hotrod (k8s, v1)

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / lint

other declaration of spanstore

Check failure on line 43 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / unit-tests

other declaration of spanstore
"github.com/jaegertracing/jaeger/storage/metricsstore/metricstoremetrics"
"github.com/jaegertracing/jaeger/storage/spanstore"

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / spm (v1, all-in-one)

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / spm (v1, all-in-one)

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / hotrod (docker, v1)

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / hotrod (docker, v1)

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / crossdock

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / crossdock

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / all-in-one (v1)

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / all-in-one (v1)

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-arm64

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-arm64

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-s390x

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-s390x

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-ppc64le

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-ppc64le

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / docker-images

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / docker-images

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-windows-amd64

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-windows-amd64

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-amd64

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-amd64

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-darwin-arm64

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-darwin-arm64

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-darwin-amd64

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-darwin-amd64

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / hotrod (k8s, v1)

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / hotrod (k8s, v1)

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / lint

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / lint

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / unit-tests

spanstore redeclared in this block

Check failure on line 45 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / unit-tests

"github.com/jaegertracing/jaeger/storage/spanstore" imported and not used
"github.com/jaegertracing/jaeger/storage/spanstore/spanstoremetrics"
)

// all-in-one/main is a standalone full-stack jaeger backend, backed by a memory store
Expand Down Expand Up @@ -96,8 +96,16 @@ by default uses only in-memory database.`,
logger.Fatal("Failed to initialize tracer", zap.Error(err))
}

baseTelset := telemetry.Settings{
Logger: svc.Logger,
TracerProvider: tracer.OTEL,
Metrics: baseFactory,
MeterProvider: noopmetric.NewMeterProvider(),
ReportStatus: telemetry.HCAdapter(svc.HC()),
}

storageFactory.InitFromViper(v, logger)
if err := storageFactory.Initialize(baseFactory, logger); err != nil {
if err := storageFactory.Initialize(baseTelset.Metrics, baseTelset.Logger); err != nil {
logger.Fatal("Failed to init storage factory", zap.Error(err))
}

Expand Down Expand Up @@ -160,20 +168,13 @@ by default uses only in-memory database.`,
log.Fatal(err)
}

telset := telemetery.Setting{
Logger: svc.Logger,
TracerProvider: tracer.OTEL,
Metrics: queryMetricsFactory,
ReportStatus: telemetery.HCAdapter(svc.HC()),
LeveledMeterProvider: func(_ configtelemetry.Level) metric.MeterProvider {
return noop.NewMeterProvider()
},
}
// query
queryTelset := baseTelset // copy
queryTelset.Metrics = queryMetricsFactory
querySrv := startQuery(
svc, qOpts, qOpts.BuildQueryServiceOptions(storageFactory, logger),
traceReader, dependencyReader, metricsQueryService,
tm, telset,
tm, queryTelset,
)

svc.RunAndThen(func() {
Expand Down Expand Up @@ -223,10 +224,10 @@ func startQuery(
depReader dependencystore.Reader,
metricsQueryService querysvc.MetricsQueryService,
tm *tenancy.Manager,
telset telemetery.Setting,
telset telemetry.Settings,
) *queryApp.Server {
// TODO: decorate trace reader with metrics
qs := querysvc.NewQueryService(traceReader, depReader, *queryOpts)
spanReader = spanstoremetrics.NewReaderDecorator(spanReader, telset.Metrics)

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / spm (v1, all-in-one)

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / hotrod (docker, v1)

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / crossdock

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / all-in-one (v1)

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-arm64

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-s390x

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-ppc64le

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / docker-images

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-windows-amd64

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-amd64

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-darwin-arm64

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-darwin-amd64

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / hotrod (k8s, v1)

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / lint

undefined: spanReader

Check failure on line 229 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / unit-tests

undefined: spanReader
qs := querysvc.NewQueryService(spanReader, depReader, *queryOpts)

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / spm (v1, all-in-one)

undefined: spanReader

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / hotrod (docker, v1)

undefined: spanReader

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / crossdock

undefined: spanReader

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / all-in-one (v1)

undefined: spanReader

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-arm64

undefined: spanReader

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-s390x

undefined: spanReader

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-ppc64le

undefined: spanReader

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / docker-images

undefined: spanReader

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-windows-amd64

undefined: spanReader

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-linux-amd64

undefined: spanReader

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-darwin-arm64

undefined: spanReader

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / build-binaries-darwin-amd64

undefined: spanReader

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / hotrod (k8s, v1)

undefined: spanReader

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / lint

undefined: spanReader (typecheck)

Check failure on line 230 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / unit-tests

undefined: spanReader

server, err := queryApp.NewServer(context.Background(), qs, metricsQueryService, qOpts, tm, telset)
if err != nil {
Expand Down Expand Up @@ -257,5 +258,5 @@ func createMetricsQueryService(
}

// Decorate the metrics reader with metrics instrumentation.
return metricsstoreMetrics.NewReadMetricsDecorator(reader, metricsReaderMetricsFactory), nil
return metricstoremetrics.NewReaderDecorator(reader, metricsReaderMetricsFactory), nil
}
5 changes: 3 additions & 2 deletions cmd/anonymizer/app/anonymizer/anonymizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package anonymizer

import (
"net/http"
"os"
"path/filepath"
"testing"
Expand All @@ -18,7 +19,7 @@ import (

var tags = []model.KeyValue{
model.Bool("error", true),
model.String("http.method", "POST"),
model.String("http.method", http.MethodPost),
model.Bool("foobar", true),
}

Expand Down Expand Up @@ -127,7 +128,7 @@ func TestAnonymizer_SaveMapping(t *testing.T) {
func TestAnonymizer_FilterStandardTags(t *testing.T) {
expected := []model.KeyValue{
model.Bool("error", true),
model.String("http.method", "POST"),
model.String("http.method", http.MethodPost),
}
actual := filterStandardTags(tags)
assert.Equal(t, expected, actual)
Expand Down
3 changes: 2 additions & 1 deletion cmd/anonymizer/app/writer/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package writer

import (
"net/http"
"testing"
"time"

Expand All @@ -15,7 +16,7 @@ import (

var tags = []model.KeyValue{
model.Bool("error", true),
model.String("http.method", "POST"),
model.String("http.method", http.MethodPost),
model.Bool("foobar", true),
}

Expand Down
7 changes: 6 additions & 1 deletion cmd/collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/jaegertracing/jaeger/cmd/internal/status"
"github.com/jaegertracing/jaeger/pkg/config"
"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/pkg/telemetry"
"github.com/jaegertracing/jaeger/pkg/tenancy"
"github.com/jaegertracing/jaeger/pkg/version"
ss "github.com/jaegertracing/jaeger/plugin/sampling/strategyprovider"
Expand Down Expand Up @@ -63,8 +64,12 @@ func main() {
metricsFactory := baseFactory.Namespace(metrics.NSOptions{Name: "collector"})
version.NewInfoMetrics(metricsFactory)

baseTelset := telemetry.NoopSettings()
baseTelset.Logger = svc.Logger
baseTelset.Metrics = baseFactory

storageFactory.InitFromViper(v, logger)
if err := storageFactory.Initialize(baseFactory, logger); err != nil {
if err := storageFactory.Initialize(baseTelset.Metrics, baseTelset.Logger); err != nil {
logger.Fatal("Failed to init storage factory", zap.Error(err))
}
spanWriter, err := storageFactory.CreateSpanWriter()
Expand Down
12 changes: 12 additions & 0 deletions cmd/es-index-cleaner/app/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"flag"

"github.com/spf13/viper"
"go.opentelemetry.io/collector/config/configtls"

"github.com/jaegertracing/jaeger/pkg/config/tlscfg"
)

const (
Expand All @@ -19,6 +22,8 @@ const (
password = "es.password"
)

var tlsFlagsCfg = tlscfg.ClientFlagsConfig{Prefix: "es"}

// Config holds configuration for index cleaner binary.
type Config struct {
IndexPrefix string
Expand All @@ -29,6 +34,7 @@ type Config struct {
Username string
Password string
TLSEnabled bool
TLSConfig configtls.ClientConfig
}

// AddFlags adds flags for TLS to the FlagSet.
Expand All @@ -40,6 +46,7 @@ func (*Config) AddFlags(flags *flag.FlagSet) {
flags.String(indexDateSeparator, "-", "Index date separator")
flags.String(username, "", "The username required by storage")
flags.String(password, "", "The password required by storage")
tlsFlagsCfg.AddFlags(flags)
}

// InitFromViper initializes config from viper.Viper.
Expand All @@ -55,4 +62,9 @@ func (c *Config) InitFromViper(v *viper.Viper) {
c.IndexDateSeparator = v.GetString(indexDateSeparator)
c.Username = v.GetString(username)
c.Password = v.GetString(password)
opts, err := tlsFlagsCfg.InitFromViper(v)
if err != nil {
panic(err)
}
c.TLSConfig = opts.ToOtelClientConfig()
}
17 changes: 6 additions & 11 deletions cmd/es-index-cleaner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package main

import (
"context"
"encoding/base64"
"errors"
"fmt"
Expand All @@ -18,15 +19,13 @@ import (

"github.com/jaegertracing/jaeger/cmd/es-index-cleaner/app"
"github.com/jaegertracing/jaeger/pkg/config"
"github.com/jaegertracing/jaeger/pkg/config/tlscfg"
"github.com/jaegertracing/jaeger/pkg/es/client"
)

func main() {
logger, _ := zap.NewProduction()
v := viper.New()
cfg := &app.Config{}
tlsFlags := tlscfg.ClientFlagsConfig{Prefix: "es"}

command := &cobra.Command{
Use: "jaeger-es-index-cleaner NUM_OF_DAYS http://HOSTNAME:PORT",
Expand All @@ -42,21 +41,18 @@ func main() {
}

cfg.InitFromViper(v)
tlsOpts, err := tlsFlags.InitFromViper(v)
if err != nil {
return err
}
tlsCfg, err := tlsOpts.Config(logger)

ctx := context.Background()
tlscfg, err := cfg.TLSConfig.LoadTLSConfig(ctx)
if err != nil {
return err
return fmt.Errorf("error loading tls config : %w", err)
}
defer tlsOpts.Close()

c := &http.Client{
Timeout: time.Duration(cfg.MasterNodeTimeoutSeconds) * time.Second,
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: tlsCfg,
TLSClientConfig: tlscfg,
},
}
i := client.IndicesClient{
Expand Down Expand Up @@ -101,7 +97,6 @@ func main() {
v,
command,
cfg.AddFlags,
tlsFlags.AddFlags,
)

if err := command.Execute(); err != nil {
Expand Down
21 changes: 9 additions & 12 deletions cmd/es-rollover/app/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
package app

import (
"context"
"crypto/tls"
"fmt"
"net/http"
"time"

"github.com/spf13/viper"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/pkg/config/tlscfg"
"github.com/jaegertracing/jaeger/pkg/es/client"
)

Expand All @@ -37,10 +38,9 @@ type Action interface {

// ActionExecuteOptions are the options passed to the execute action function
type ActionExecuteOptions struct {
Args []string
Viper *viper.Viper
Logger *zap.Logger
TLSFlags tlscfg.ClientFlagsConfig
Args []string
Viper *viper.Viper
Logger *zap.Logger
}

// ActionCreatorFunction type is the function type in charge of create the action to be executed
Expand All @@ -50,15 +50,12 @@ type ActionCreatorFunction func(client.Client, Config) Action
func ExecuteAction(opts ActionExecuteOptions, createAction ActionCreatorFunction) error {
cfg := Config{}
cfg.InitFromViper(opts.Viper)
tlsOpts, err := opts.TLSFlags.InitFromViper(opts.Viper)
if err != nil {
return err
}
tlsCfg, err := tlsOpts.Config(opts.Logger)

ctx := context.Background()
tlsCfg, err := cfg.TLSConfig.LoadTLSConfig(ctx)
if err != nil {
return err
return fmt.Errorf("TLS configuration failed: %w", err)
}
defer tlsOpts.Close()

esClient := newESClient(opts.Args[0], &cfg, tlsCfg)
action := createAction(esClient, cfg)
Expand Down
Loading

0 comments on commit 24a53df

Please sign in to comment.