Skip to content

Commit

Permalink
Merge branch 'main' into refactor-span-store-interface-add-time-window
Browse files Browse the repository at this point in the history
  • Loading branch information
rim99 authored Nov 25, 2024
2 parents 6811b52 + ae0982e commit fec5af1
Show file tree
Hide file tree
Showing 35 changed files with 655 additions and 280 deletions.
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
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
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
26 changes: 7 additions & 19 deletions cmd/es-rollover/app/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ package app

import (
"errors"
"flag"
"net/http"
"testing"

"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"

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

Expand Down Expand Up @@ -73,22 +70,14 @@ func TestExecuteAction(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
v := viper.New()
tlsFlags := tlscfg.ClientFlagsConfig{Prefix: "es"}
command := cobra.Command{}
flags := &flag.FlagSet{}
tlsFlags.AddFlags(flags)
command.PersistentFlags().AddGoFlagSet(flags)
v.BindPFlags(command.PersistentFlags())
v, command := config.Viperize(AddFlags)
cmdLine := append([]string{"--es.tls.enabled=true"}, test.flags...)
err := command.ParseFlags(cmdLine)
require.NoError(t, err)
require.NoError(t, command.ParseFlags(cmdLine))
executedAction := false
err = ExecuteAction(ActionExecuteOptions{
Args: args,
Viper: v,
Logger: logger,
TLSFlags: tlsFlags,
err := ExecuteAction(ActionExecuteOptions{
Args: args,
Viper: v,
Logger: logger,
}, func(c client.Client, _ Config) Action {
assert.Equal(t, "https://localhost:9300", c.Endpoint)
transport, ok := c.Client.Transport.(*http.Transport)
Expand All @@ -101,7 +90,6 @@ func TestExecuteAction(t *testing.T) {
},
}
})

assert.Equal(t, test.expectedExecuteAction, executedAction)
if test.configError {
require.Error(t, err)
Expand Down
12 changes: 12 additions & 0 deletions cmd/es-rollover/app/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import (
"flag"

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

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

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

const (
indexPrefix = "index-prefix"
archive = "archive"
Expand All @@ -33,6 +38,7 @@ type Config struct {
Timeout int
SkipDependencies bool
AdaptiveSampling bool
TLSConfig configtls.ClientConfig
}

// AddFlags adds flags
Expand All @@ -46,6 +52,7 @@ func AddFlags(flags *flag.FlagSet) {
flags.Int(timeout, 120, "Number of seconds to wait for master node response")
flags.Bool(skipDependencies, false, "Disable rollover for dependencies index")
flags.Bool(adaptiveSampling, false, "Enable rollover for adaptive sampling index")
tlsFlagsCfg.AddFlags(flags)
}

// InitFromViper initializes config from viper.Viper.
Expand All @@ -62,4 +69,9 @@ func (c *Config) InitFromViper(v *viper.Viper) {
c.Timeout = v.GetInt(timeout)
c.SkipDependencies = v.GetBool(skipDependencies)
c.AdaptiveSampling = v.GetBool(adaptiveSampling)
opts, err := tlsFlagsCfg.InitFromViper(v)
if err != nil {
panic(err)
}
c.TLSConfig = opts.ToOtelClientConfig()
}
26 changes: 10 additions & 16 deletions cmd/es-rollover/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/jaegertracing/jaeger/cmd/es-rollover/app/lookback"
"github.com/jaegertracing/jaeger/cmd/es-rollover/app/rollover"
"github.com/jaegertracing/jaeger/pkg/config"
"github.com/jaegertracing/jaeger/pkg/config/tlscfg"
"github.com/jaegertracing/jaeger/pkg/es/client"
)

Expand All @@ -30,8 +29,6 @@ func main() {
Long: "Jaeger es-rollover manages Jaeger indices",
}

tlsFlags := tlscfg.ClientFlagsConfig{Prefix: "es"}

// Init command
initCfg := &initialize.Config{}
initCommand := &cobra.Command{
Expand All @@ -42,10 +39,9 @@ func main() {
SilenceUsage: true,
RunE: func(_ *cobra.Command, args []string) error {
return app.ExecuteAction(app.ActionExecuteOptions{
Args: args,
Viper: v,
Logger: logger,
TLSFlags: tlsFlags,
Args: args,
Viper: v,
Logger: logger,
}, func(c client.Client, cfg app.Config) app.Action {
initCfg.Config = cfg
initCfg.InitFromViper(v)
Expand Down Expand Up @@ -80,10 +76,9 @@ func main() {
RunE: func(_ *cobra.Command, args []string) error {
rolloverCfg.InitFromViper(v)
return app.ExecuteAction(app.ActionExecuteOptions{
Args: args,
Viper: v,
Logger: logger,
TLSFlags: tlsFlags,
Args: args,
Viper: v,
Logger: logger,
}, func(c client.Client, cfg app.Config) app.Action {
rolloverCfg.Config = cfg
rolloverCfg.InitFromViper(v)
Expand All @@ -109,10 +104,9 @@ func main() {
RunE: func(_ *cobra.Command, args []string) error {
lookbackCfg.InitFromViper(v)
return app.ExecuteAction(app.ActionExecuteOptions{
Args: args,
Viper: v,
Logger: logger,
TLSFlags: tlsFlags,
Args: args,
Viper: v,
Logger: logger,
}, func(c client.Client, cfg app.Config) app.Action {
lookbackCfg.Config = cfg
lookbackCfg.InitFromViper(v)
Expand All @@ -129,7 +123,7 @@ func main() {
},
}

addPersistentFlags(v, rootCmd, tlsFlags.AddFlags, app.AddFlags)
addPersistentFlags(v, rootCmd, app.AddFlags)
addSubCommand(v, rootCmd, initCommand, initCfg.AddFlags)
addSubCommand(v, rootCmd, rolloverCommand, rolloverCfg.AddFlags)
addSubCommand(v, rootCmd, lookbackCommand, lookbackCfg.AddFlags)
Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/status/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func Command(v *viper.Viper, adminPort int) *cobra.Command {
url := convert(v.GetString(statusHTTPHostPort))
ctx, cx := context.WithTimeout(context.Background(), time.Second)
defer cx()
req, _ := http.NewRequestWithContext(ctx, "GET", url, nil)
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
Expand Down
86 changes: 86 additions & 0 deletions cmd/jaeger/docs/migration/all-in-one-metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# ALL-IN-ONE METRICS
### Combined Metrics

| V1 Metric | V1 Labels | V2 Metric | V2 Labels |
|-----------|---------------|-----------|---------------|
| jaeger_query_latency | operation, result | jaeger_query_latency | operation, result |
| jaeger_query_responses | operation | jaeger_query_responses | operation |
| jaeger_query_requests_total | operation, result | jaeger_query_requests_total | operation, result |
| go_gc_duration_seconds | N/A | N/A | N/A |
| go_goroutines | N/A | N/A | N/A |
| go_info | version | N/A | N/A |
| go_memstats_alloc_bytes | N/A | N/A | N/A |
| go_memstats_alloc_bytes_total | N/A | N/A | N/A |
| go_memstats_buck_hash_sys_bytes | N/A | N/A | N/A |
| go_memstats_frees_total | N/A | N/A | N/A |
| go_memstats_gc_sys_bytes | N/A | N/A | N/A |
| go_memstats_heap_alloc_bytes | N/A | N/A | N/A |
| go_memstats_heap_idle_bytes | N/A | N/A | N/A |
| go_memstats_heap_inuse_bytes | N/A | N/A | N/A |
| go_memstats_heap_objects | N/A | N/A | N/A |
| go_memstats_heap_released_bytes | N/A | N/A | N/A |
| go_memstats_heap_sys_bytes | N/A | N/A | N/A |
| go_memstats_last_gc_time_seconds | N/A | N/A | N/A |
| go_memstats_lookups_total | N/A | N/A | N/A |
| go_memstats_mallocs_total | N/A | N/A | N/A |
| go_memstats_mcache_inuse_bytes | N/A | N/A | N/A |
| go_memstats_mcache_sys_bytes | N/A | N/A | N/A |
| go_memstats_mspan_inuse_bytes | N/A | N/A | N/A |
| go_memstats_mspan_sys_bytes | N/A | N/A | N/A |
| go_memstats_next_gc_bytes | N/A | N/A | N/A |
| go_memstats_other_sys_bytes | N/A | N/A | N/A |
| go_memstats_stack_inuse_bytes | N/A | N/A | N/A |
| go_memstats_stack_sys_bytes | N/A | N/A | N/A |
| go_memstats_sys_bytes | N/A | N/A | N/A |
| go_threads | N/A | N/A | N/A |
| jaeger_build_info | build_date, revision, version | N/A | N/A |
| jaeger_collector_batch_size | host | N/A | N/A |
| jaeger_collector_http_request_duration | method, path, status | N/A | N/A |
| jaeger_collector_http_server_errors_total | source, status | N/A | N/A |
| jaeger_collector_http_server_requests_total | type | N/A | N/A |
| jaeger_collector_in_queue_latency | host | N/A | N/A |
| jaeger_collector_queue_capacity | host | N/A | N/A |
| jaeger_collector_queue_length | host | N/A | N/A |
| jaeger_collector_save_latency | host | N/A | N/A |
| jaeger_collector_spans_bytes | host | N/A | N/A |
| jaeger_collector_spans_dropped_total | host | N/A | N/A |
| jaeger_collector_spans_received_total | debug, format, svc, transport | N/A | N/A |
| jaeger_collector_spans_rejected_total | debug, format, svc, transport | N/A | N/A |
| jaeger_collector_spans_saved_by_svc_total | debug, result, svc | N/A | N/A |
| jaeger_collector_spans_serviceNames | host | N/A | N/A |
| jaeger_collector_traces_received_total | debug, format, sampler_type, svc, transport | N/A | N/A |
| jaeger_collector_traces_rejected_total | debug, format, sampler_type, svc, transport | N/A | N/A |
| jaeger_collector_traces_saved_by_svc_total | debug, result, sampler_type, svc | N/A | N/A |
| process_cpu_seconds_total | N/A | N/A | N/A |
| process_max_fds | N/A | N/A | N/A |
| process_open_fds | N/A | N/A | N/A |
| process_resident_memory_bytes | N/A | N/A | N/A |
| process_start_time_seconds | N/A | N/A | N/A |
| process_virtual_memory_bytes | N/A | N/A | N/A |
| process_virtual_memory_max_bytes | N/A | N/A | N/A |
| N/A | N/A | exporter_send_failed_spans | exporter, service_instance_id, service_name, service_version |
| N/A | N/A | exporter_sent_spans | exporter, service_instance_id, service_name, service_version |
| N/A | N/A | process_cpu_seconds | service_instance_id, service_name, service_version |
| N/A | N/A | process_memory_rss | service_instance_id, service_name, service_version |
| N/A | N/A | process_runtime_heap_alloc_bytes | service_instance_id, service_name, service_version |
| N/A | N/A | process_runtime_total_alloc_bytes | service_instance_id, service_name, service_version |
| N/A | N/A | process_runtime_total_sys_memory_bytes | service_instance_id, service_name, service_version |
| N/A | N/A | process_uptime | service_instance_id, service_name, service_version |
| N/A | N/A | processor_batch_batch_send_size | processor, service_instance_id, service_name, service_version |
| N/A | N/A | processor_batch_batch_send_size_bytes | processor, service_instance_id, service_name, service_version |
| N/A | N/A | processor_batch_metadata_cardinality | processor, service_instance_id, service_name, service_version |
| N/A | N/A | processor_batch_timeout_trigger_send | processor, service_instance_id, service_name, service_version |
| N/A | N/A | receiver_accepted_spans | receiver, service_instance_id, service_name, service_version, transport |
| N/A | N/A | receiver_refused_spans | receiver, service_instance_id, service_name, service_version, transport |
| N/A | N/A | rpc_server_duration | rpc_grpc_status_code, rpc_method, rpc_service, rpc_system, service_instance_id, service_name, service_version |
| N/A | N/A | rpc_server_request_size | rpc_method, rpc_service, rpc_system, service_instance_id, service_name, service_version |
| N/A | N/A | rpc_server_requests_per_rpc | rpc_grpc_status_code, rpc_method, rpc_service, rpc_system, service_instance_id, service_name, service_version |
| N/A | N/A | rpc_server_response_size | rpc_method, rpc_service, rpc_system, service_instance_id, service_name, service_version |
| N/A | N/A | rpc_server_responses_per_rpc | rpc_grpc_status_code, rpc_method, rpc_service, rpc_system, service_instance_id, service_name, service_version |
| N/A | N/A | target_info | service_instance_id, service_name, service_version |
### Equivalent Metrics

| V1 Metric | V1 Labels | V2 Metric | V2 Labels |
|-----------|---------------|-----------|---------------|
| jaeger_collector_spans_rejected_total | debug, format, svc, transport | receiver_refused_spans | receiver, service_instance_id, service_name, service_version, transport |
| jaeger_build_info | build_date, revision, version | target_info | service_instance_id, service_name, service_version |
33 changes: 33 additions & 0 deletions cmd/jaeger/docs/migration/badger-metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# BADGER METRICS

### Combined Metrics

| V1 Metric | V1 Parameters | V2 Metric | V2 Parameters |
| ------------------------------------------ | ------------- | ---------------------------------------- | ------------- |
| jaeger_badger_compaction_current_num_lsm | N/A | jaeger_badger_compaction_current_num_lsm | N/A |
| jaeger_badger_get_num_memtable | N/A | jaeger_badger_get_num_memtable | N/A |
| jaeger_badger_get_num_user | N/A | jaeger_badger_get_num_user | N/A |
| jaeger_badger_get_with_result_num_user | N/A | jaeger_badger_get_with_result_num_user | N/A |
| jaeger_badger_iterator_num_user | N/A | jaeger_badger_iterator_num_user | N/A |
| jaeger_badger_put_num_user | N/A | jaeger_badger_put_num_user | N/A |
| jaeger_badger_read_bytes_lsm | N/A | jaeger_badger_read_bytes_lsm | N/A |
| jaeger_badger_read_bytes_vlog | N/A | jaeger_badger_read_bytes_vlog | N/A |
| jaeger_badger_read_num_vlog | N/A | jaeger_badger_read_num_vlog | N/A |
| jaeger_badger_size_bytes_lsm | N/A | jaeger_badger_size_bytes_lsm | N/A |
| jaeger_badger_size_bytes_vlog | N/A | jaeger_badger_size_bytes_vlog | N/A |
| jaeger_badger_write_bytes_l0 | N/A | jaeger_badger_write_bytes_l0 | N/A |
| jaeger_badger_write_bytes_user | N/A | jaeger_badger_write_bytes_user | N/A |
| jaeger_badger_write_bytes_vlog | N/A | jaeger_badger_write_bytes_vlog | N/A |
| jaeger_badger_write_num_vlog | N/A | jaeger_badger_write_num_vlog | N/A |
| jaeger_badger_write_pending_num_memtable | N/A | jaeger_badger_write_pending_num_memtable | N/A |
| jaeger_badger_key_log_bytes_available | N/A | N/A | N/A |
| jaeger_badger_storage_maintenance_last_run | N/A | N/A | N/A |
| jaeger_badger_storage_valueloggc_last_run | N/A | N/A | N/A |
| jaeger_badger_value_log_bytes_available | N/A | N/A | N/A |

### Equivalent Metrics

| V1 Metric | V1 Parameters | V2 Metric | V2 Parameters |
| ------------------------------------- | ------------------------------ | ---------------------- | ----------------------------------------------------------------------- |
| jaeger_collector_spans_rejected_total | debug, format, svc, transport | receiver_refused_spans | receiver, service_instance_id, service_name, service_version, transport |
| jaeger_build_info | build_date, revision, version | target_info | service_instance_id, service_name, service_version |
Loading

0 comments on commit fec5af1

Please sign in to comment.