diff --git a/.golangci.yml b/.golangci.yml index 7c4e9314df8..5427041391e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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: diff --git a/.mockery.yaml b/.mockery.yaml index 48f9c27d4b9..cf4e9f0b10c 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -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: diff --git a/Makefile.Protobuf.mk b/Makefile.Protobuf.mk index 10ba6af1cb1..bb10b7d8ad0 100644 --- a/Makefile.Protobuf.mk +++ b/Makefile.Protobuf.mk @@ -14,9 +14,10 @@ # 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 diff --git a/cmd/anonymizer/app/anonymizer/anonymizer_test.go b/cmd/anonymizer/app/anonymizer/anonymizer_test.go index 431cc0162a6..6d2f219c062 100644 --- a/cmd/anonymizer/app/anonymizer/anonymizer_test.go +++ b/cmd/anonymizer/app/anonymizer/anonymizer_test.go @@ -4,6 +4,7 @@ package anonymizer import ( + "net/http" "os" "path/filepath" "testing" @@ -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), } @@ -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) diff --git a/cmd/anonymizer/app/writer/writer_test.go b/cmd/anonymizer/app/writer/writer_test.go index c6e11434ccc..dc746f16b63 100644 --- a/cmd/anonymizer/app/writer/writer_test.go +++ b/cmd/anonymizer/app/writer/writer_test.go @@ -4,6 +4,7 @@ package writer import ( + "net/http" "testing" "time" @@ -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), } diff --git a/cmd/internal/status/command.go b/cmd/internal/status/command.go index 02f2e48683a..355719ae4a0 100644 --- a/cmd/internal/status/command.go +++ b/cmd/internal/status/command.go @@ -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 diff --git a/cmd/jaeger/docs/migration/all-in-one-metrics.md b/cmd/jaeger/docs/migration/all-in-one-metrics.md new file mode 100644 index 00000000000..28f165b2be3 --- /dev/null +++ b/cmd/jaeger/docs/migration/all-in-one-metrics.md @@ -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 | diff --git a/cmd/jaeger/docs/migration/badger-metrics.md b/cmd/jaeger/docs/migration/badger-metrics.md new file mode 100644 index 00000000000..65656e44c6a --- /dev/null +++ b/cmd/jaeger/docs/migration/badger-metrics.md @@ -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 | diff --git a/cmd/jaeger/docs/migration/cassandra-metrics.md b/cmd/jaeger/docs/migration/cassandra-metrics.md new file mode 100644 index 00000000000..95d453f7ca3 --- /dev/null +++ b/cmd/jaeger/docs/migration/cassandra-metrics.md @@ -0,0 +1,22 @@ +# CASSANDRA METRICS +### Combined Metrics + +| V1 Metric | V1 Parameters | V2 Metric | V2 Parameters | +|-----------|---------------|-----------|---------------| +| jaeger_cassandra_attempts_total | table | jaeger_cassandra_attempts_total | table | +| jaeger_cassandra_errors_total | table | jaeger_cassandra_errors_total | table | +| jaeger_cassandra_inserts_total | table | jaeger_cassandra_inserts_total | table | +| jaeger_cassandra_latency_err | table | jaeger_cassandra_latency_err | table | +| jaeger_cassandra_latency_ok | table | jaeger_cassandra_latency_ok | table | +| jaeger_cassandra_read_attempts_total | table | jaeger_cassandra_read_attempts_total | table | +| jaeger_cassandra_read_errors_total | table | jaeger_cassandra_read_errors_total | table | +| jaeger_cassandra_read_inserts_total | table | jaeger_cassandra_read_inserts_total | table | +| jaeger_cassandra_read_latency_err | table | jaeger_cassandra_read_latency_err | table | +| jaeger_cassandra_read_latency_ok | table | jaeger_cassandra_read_latency_ok | table | +| jaeger_cassandra_tag_index_skipped_total | N/A | jaeger_cassandra_tag_index_skipped_total | 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 | diff --git a/cmd/jaeger/docs/migration/elasticsearch-metrics.md b/cmd/jaeger/docs/migration/elasticsearch-metrics.md new file mode 100644 index 00000000000..9b5a0a0b608 --- /dev/null +++ b/cmd/jaeger/docs/migration/elasticsearch-metrics.md @@ -0,0 +1,21 @@ +# ELASTICSEARCH METRICS +### Combined Metrics + +| V1 Metric | V1 Parameters | V2 Metric | V2 Parameters | +|-----------|---------------|-----------|---------------| +| jaeger_bulk_index_attempts_total | N/A | jaeger_bulk_index_attempts_total | N/A | +| jaeger_bulk_index_errors_total | N/A | jaeger_bulk_index_errors_total | N/A | +| jaeger_bulk_index_inserts_total | N/A | jaeger_bulk_index_inserts_total | N/A | +| jaeger_bulk_index_latency_err | N/A | jaeger_bulk_index_latency_err | N/A | +| jaeger_bulk_index_latency_ok | N/A | jaeger_bulk_index_latency_ok | N/A | +| jaeger_index_create_attempts_total | N/A | jaeger_index_create_attempts_total | N/A | +| jaeger_index_create_errors_total | N/A | jaeger_index_create_errors_total | N/A | +| jaeger_index_create_inserts_total | N/A | jaeger_index_create_inserts_total | N/A | +| jaeger_index_create_latency_err | N/A | jaeger_index_create_latency_err | N/A | +| jaeger_index_create_latency_ok | N/A | jaeger_index_create_latency_ok | 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 | diff --git a/cmd/jaeger/docs/migration/opensearch-metrics.md b/cmd/jaeger/docs/migration/opensearch-metrics.md new file mode 100644 index 00000000000..aa5052c270b --- /dev/null +++ b/cmd/jaeger/docs/migration/opensearch-metrics.md @@ -0,0 +1,21 @@ +# OPENSEARCH METRICS +### Combined Metrics + +| V1 Metric | V1 Parameters | V2 Metric | V2 Parameters | +|-----------|---------------|-----------|---------------| +| jaeger_bulk_index_attempts_total | N/A | jaeger_bulk_index_attempts_total | N/A | +| jaeger_bulk_index_errors_total | N/A | jaeger_bulk_index_errors_total | N/A | +| jaeger_bulk_index_inserts_total | N/A | jaeger_bulk_index_inserts_total | N/A | +| jaeger_bulk_index_latency_err | N/A | jaeger_bulk_index_latency_err | N/A | +| jaeger_bulk_index_latency_ok | N/A | jaeger_bulk_index_latency_ok | N/A | +| jaeger_index_create_attempts_total | N/A | jaeger_index_create_attempts_total | N/A | +| jaeger_index_create_errors_total | N/A | jaeger_index_create_errors_total | N/A | +| jaeger_index_create_inserts_total | N/A | jaeger_index_create_inserts_total | N/A | +| jaeger_index_create_latency_err | N/A | jaeger_index_create_latency_err | N/A | +| jaeger_index_create_latency_ok | N/A | jaeger_index_create_latency_ok | 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 | diff --git a/cmd/query/app/server.go b/cmd/query/app/server.go index 70dcecd86f4..8e971a6eb3e 100644 --- a/cmd/query/app/server.go +++ b/cmd/query/app/server.go @@ -228,15 +228,6 @@ func createHTTPServer( staticHandlerCloser: staticHandlerCloser, } - // TODO why doesn't OTEL helper do that already? - if queryOpts.HTTP.TLSSetting != nil { - tlsCfg, err := queryOpts.HTTP.TLSSetting.LoadTLSConfig(ctx) // This checks if the certificates are correctly provided - if err != nil { - return nil, errors.Join(err, staticHandlerCloser.Close()) - } - server.TLSConfig = tlsCfg - } - return server, nil } @@ -327,12 +318,7 @@ func (s *Server) Start(ctx context.Context) error { go func() { defer s.bgFinished.Done() s.Logger.Info("Starting HTTP server", zap.Int("port", httpPort), zap.String("addr", s.queryOptions.HTTP.Endpoint)) - var err error - if s.queryOptions.HTTP.TLSSetting != nil { - err = s.httpServer.ServeTLS(s.httpConn, "", "") - } else { - err = s.httpServer.Serve(s.httpConn) - } + err := s.httpServer.Serve(s.httpConn) if err != nil && !errors.Is(err, http.ErrServerClosed) && !errors.Is(err, cmux.ErrListenerClosed) && !errors.Is(err, cmux.ErrServerClosed) { s.Logger.Error("Could not start HTTP server", zap.Error(err)) s.ReportStatus(componentstatus.NewFatalErrorEvent(err)) diff --git a/cmd/query/app/server_test.go b/cmd/query/app/server_test.go index 1bbc9993724..7a7d1bed674 100644 --- a/cmd/query/app/server_test.go +++ b/cmd/query/app/server_test.go @@ -6,7 +6,6 @@ package app import ( "bytes" "context" - "crypto/tls" "fmt" "net" "net/http" @@ -108,7 +107,7 @@ func TestCreateTLSGrpcServerError(t *testing.T) { require.Error(t, err) } -func TestCreateTLSHttpServerError(t *testing.T) { +func TestStartTLSHttpServerError(t *testing.T) { tlsCfg := configtls.ServerConfig{ ClientCAFile: "invalid/path", Config: configtls.Config{ @@ -117,12 +116,16 @@ func TestCreateTLSHttpServerError(t *testing.T) { }, } telset := initTelSet(zaptest.NewLogger(t), jtracer.NoOp(), healthcheck.New()) - _, err := NewServer(context.Background(), &querysvc.QueryService{}, nil, + s, err := NewServer(context.Background(), &querysvc.QueryService{}, nil, &QueryOptions{ HTTP: confighttp.ServerConfig{Endpoint: ":8080", TLSSetting: &tlsCfg}, GRPC: configgrpc.ServerConfig{NetAddr: confignet.AddrConfig{Endpoint: ":8081", Transport: confignet.TransportTypeTCP}}, }, tenancy.NewManager(&tenancy.Options{}), telset) - require.Error(t, err) + require.NoError(t, err) + require.Error(t, s.Start(context.Background())) + t.Cleanup(func() { + require.NoError(t, s.Close()) + }) } var testCases = []struct { @@ -131,7 +134,6 @@ var testCases = []struct { HTTPTLSEnabled bool GRPCTLSEnabled bool clientTLS configtls.ClientConfig - expectError bool expectClientError bool expectServerFail bool }{ @@ -143,7 +145,6 @@ var testCases = []struct { clientTLS: configtls.ClientConfig{ Insecure: true, }, - expectError: false, expectClientError: false, expectServerFail: false, }, @@ -161,7 +162,6 @@ var testCases = []struct { Insecure: true, ServerName: "example.com", }, - expectError: true, expectClientError: true, expectServerFail: false, }, @@ -182,7 +182,6 @@ var testCases = []struct { CAFile: testCertKeyLocation + "/example-CA-cert.pem", }, }, - expectError: true, expectClientError: true, expectServerFail: false, }, @@ -203,7 +202,6 @@ var testCases = []struct { CAFile: testCertKeyLocation + "/example-CA-cert.pem", }, }, - expectError: false, expectClientError: false, expectServerFail: false, }, @@ -225,7 +223,6 @@ var testCases = []struct { CAFile: testCertKeyLocation + "/example-CA-cert.pem", }, }, - expectError: false, expectServerFail: false, expectClientError: true, }, @@ -249,7 +246,6 @@ var testCases = []struct { KeyFile: testCertKeyLocation + "/example-client-key.pem", }, }, - expectError: false, expectServerFail: false, expectClientError: false, }, @@ -274,7 +270,6 @@ var testCases = []struct { KeyFile: testCertKeyLocation + "/example-client-key.pem", }, }, - expectError: false, expectServerFail: false, expectClientError: true, }, @@ -298,7 +293,6 @@ var testCases = []struct { KeyFile: testCertKeyLocation + "/example-client-key.pem", }, }, - expectError: false, expectServerFail: false, expectClientError: false, }, @@ -322,7 +316,6 @@ var testCases = []struct { KeyFile: testCertKeyLocation + "/example-client-key.pem", }, }, - expectError: false, expectServerFail: false, expectClientError: false, }, @@ -358,7 +351,6 @@ func TestServerHTTPTLS(t *testing.T) { HTTPTLSEnabled bool GRPCTLSEnabled bool clientTLS configtls.ClientConfig - expectError bool expectClientError bool expectServerFail bool }, testlen) @@ -411,41 +403,9 @@ func TestServerHTTPTLS(t *testing.T) { require.NoError(t, server.Close()) }) - var clientError error - var clientClose func() error - var clientTLSCfg *tls.Config - - if serverOptions.HTTP.TLSSetting != nil { - var err0 error - clientTLSCfg, err0 = test.clientTLS.LoadTLSConfig(context.Background()) - - require.NoError(t, err0) - dialer := &net.Dialer{Timeout: 2 * time.Second} - conn, err1 := tls.DialWithDialer(dialer, "tcp", server.HTTPAddr(), clientTLSCfg) - clientError = err1 - clientClose = nil - if conn != nil { - clientClose = conn.Close - } - } else { - conn, err1 := net.DialTimeout("tcp", server.HTTPAddr(), 2*time.Second) - clientError = err1 - clientClose = nil - if conn != nil { - clientClose = conn.Close - } - } - - if test.expectError { - require.Error(t, clientError) - } else { - require.NoError(t, clientError) - } - if clientClose != nil { - require.NoError(t, clientClose()) - } - - if test.HTTPTLSEnabled && test.TLS.ClientCAFile != "" { + if test.HTTPTLSEnabled { + clientTLSCfg, err := test.clientTLS.LoadTLSConfig(context.Background()) + require.NoError(t, err) client := &http.Client{ Transport: &http.Transport{ TLSClientConfig: clientTLSCfg, @@ -457,15 +417,18 @@ func TestServerHTTPTLS(t *testing.T) { require.NoError(t, err) req.Header.Add("Accept", "application/json") - resp, err2 := client.Do(req) - if err2 == nil { - resp.Body.Close() - } + resp, err := client.Do(req) + t.Cleanup(func() { + if err == nil { + resp.Body.Close() + } + }) if test.expectClientError { - require.Error(t, err2) + require.Error(t, err) } else { - require.NoError(t, err2) + require.NoError(t, err) + require.Equal(t, http.StatusOK, resp.StatusCode) } } }) @@ -498,7 +461,6 @@ func TestServerGRPCTLS(t *testing.T) { HTTPTLSEnabled bool GRPCTLSEnabled bool clientTLS configtls.ClientConfig - expectError bool expectClientError bool expectServerFail bool }, testlen) @@ -798,12 +760,12 @@ func TestServerHTTPTenancy(t *testing.T) { { name: "no tenant", // no value for tenant header - status: 401, + status: http.StatusUnauthorized, }, { name: "tenant", tenant: "acme", - status: 200, + status: http.StatusOK, }, } diff --git a/crossdock/main.go b/crossdock/main.go index f4833886a42..686f6ff515d 100644 --- a/crossdock/main.go +++ b/crossdock/main.go @@ -52,7 +52,7 @@ func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { // when method is HEAD, report back with a 200 when ready to run tests - if r.Method == "HEAD" { + if r.Method == http.MethodHead { if !handler.isInitialized() { http.Error(w, "Components not ready", http.StatusServiceUnavailable) } @@ -92,7 +92,7 @@ func (h *clientHandler) isInitialized() bool { } func is2xxStatusCode(statusCode int) bool { - return statusCode >= 200 && statusCode <= 299 + return statusCode >= http.StatusOK && statusCode < http.StatusMultipleChoices } func httpHealthCheck(logger *zap.Logger, service, healthURL string) { diff --git a/examples/hotrod/pkg/tracing/http.go b/examples/hotrod/pkg/tracing/http.go index 0e938ba60b8..a37d7e70df2 100644 --- a/examples/hotrod/pkg/tracing/http.go +++ b/examples/hotrod/pkg/tracing/http.go @@ -48,7 +48,7 @@ func (c *HTTPClient) GetJSON(ctx context.Context, _ string /* endpoint */, url s defer res.Body.Close() - if res.StatusCode >= 400 { + if res.StatusCode >= http.StatusBadRequest { body, err := io.ReadAll(res.Body) if err != nil { return err diff --git a/examples/hotrod/pkg/tracing/rpcmetrics/metrics.go b/examples/hotrod/pkg/tracing/rpcmetrics/metrics.go index 48556e92170..5daa89f21de 100644 --- a/examples/hotrod/pkg/tracing/rpcmetrics/metrics.go +++ b/examples/hotrod/pkg/tracing/rpcmetrics/metrics.go @@ -5,6 +5,7 @@ package rpcmetrics import ( + "net/http" "sync" "github.com/jaegertracing/jaeger/pkg/metrics" @@ -45,13 +46,13 @@ type Metrics struct { func (m *Metrics) recordHTTPStatusCode(statusCode int64) { switch { - case statusCode >= 200 && statusCode < 300: + case statusCode >= http.StatusOK && statusCode < http.StatusMultipleChoices: m.HTTPStatusCode2xx.Inc(1) - case statusCode >= 300 && statusCode < 400: + case statusCode >= http.StatusMultipleChoices && statusCode < http.StatusBadRequest: m.HTTPStatusCode3xx.Inc(1) - case statusCode >= 400 && statusCode < 500: + case statusCode >= http.StatusBadRequest && statusCode < http.StatusInternalServerError: m.HTTPStatusCode4xx.Inc(1) - case statusCode >= 500 && statusCode < 600: + case statusCode >= http.StatusInternalServerError && statusCode < 600: m.HTTPStatusCode5xx.Inc(1) } } diff --git a/go.mod b/go.mod index 795f27a87da..97037398784 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,7 @@ require ( github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.19.0 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.10.0 github.com/uber/jaeger-client-go v2.30.0+incompatible github.com/xdg-go/scram v1.1.2 go.opentelemetry.io/collector/component v0.114.0 diff --git a/go.sum b/go.sum index 43c7988e6fc..ed3c415d9c4 100644 --- a/go.sum +++ b/go.sum @@ -555,8 +555,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= diff --git a/internal/tools/go.mod b/internal/tools/go.mod index faab7b9fed5..76cfbb14e05 100644 --- a/internal/tools/go.mod +++ b/internal/tools/go.mod @@ -5,7 +5,7 @@ go 1.23.0 require ( github.com/golangci/golangci-lint v1.62.0 github.com/josephspurrier/goversioninfo v1.4.1 - github.com/vektra/mockery/v2 v2.48.0 + github.com/vektra/mockery/v2 v2.49.0 mvdan.cc/gofumpt v0.7.0 ) diff --git a/internal/tools/go.sum b/internal/tools/go.sum index b15dc412e55..8961289417a 100644 --- a/internal/tools/go.sum +++ b/internal/tools/go.sum @@ -567,8 +567,8 @@ github.com/uudashr/gocognit v1.1.3 h1:l+a111VcDbKfynh+airAy/DJQKaXh2m9vkoysMPSZy github.com/uudashr/gocognit v1.1.3/go.mod h1:aKH8/e8xbTRBwjbCkwZ8qt4l2EpKXl31KMHgSS+lZ2U= github.com/uudashr/iface v1.2.0 h1:ECJjh5q/1Zmnv/2yFpWV6H3oMg5+Mo+vL0aqw9Gjazo= github.com/uudashr/iface v1.2.0/go.mod h1:Ux/7d/rAF3owK4m53cTVXL4YoVHKNqnoOeQHn2xrlp0= -github.com/vektra/mockery/v2 v2.48.0 h1:pBhvOqRbBVAAtg6SWiLzJhm1FqGptBObiNSRA3l8cFo= -github.com/vektra/mockery/v2 v2.48.0/go.mod h1:xO2DeYemEPC2tCzIZ+a1tifZ/7Laf/Chxg3vlc+oDsI= +github.com/vektra/mockery/v2 v2.49.0 h1:KFJKqRa0zd4h+ntM+JFr9Z6fIz++CUgAAogPWnwTwJY= +github.com/vektra/mockery/v2 v2.49.0/go.mod h1:xO2DeYemEPC2tCzIZ+a1tifZ/7Laf/Chxg3vlc+oDsI= github.com/xen0n/gosmopolitan v1.2.2 h1:/p2KTnMzwRexIW8GlKawsTWOxn7UHA+jCMF/V8HHtvU= github.com/xen0n/gosmopolitan v1.2.2/go.mod h1:7XX7Mj61uLYrj0qmeN0zi7XDon9JRAEhYQqAPLVNTeg= github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM= diff --git a/model/adjuster/sort_tags_and_log_fields_test.go b/model/adjuster/sort_tags_and_log_fields_test.go index 4d31c7248b6..afd1983cac0 100644 --- a/model/adjuster/sort_tags_and_log_fields_test.go +++ b/model/adjuster/sort_tags_and_log_fields_test.go @@ -5,6 +5,7 @@ package adjuster import ( + "net/http" "testing" "github.com/stretchr/testify/assert" @@ -88,7 +89,7 @@ func TestSortTagsAndLogFieldsDoesSortFields(t *testing.T) { func TestSortTagsAndLogFieldsDoesSortTags(t *testing.T) { testCases := []model.KeyValues{ { - model.String("http.method", "GET"), + model.String("http.method", http.MethodGet), model.String("http.url", "http://wikipedia.org"), model.Int64("http.status_code", 200), model.String("guid:x-request-id", "f61defd2-7a77-11ef-b54f-4fbb67a6d181"), diff --git a/pkg/bearertoken/transport_test.go b/pkg/bearertoken/transport_test.go index b578934cb38..e03ca8dd8a0 100644 --- a/pkg/bearertoken/transport_test.go +++ b/pkg/bearertoken/transport_test.go @@ -78,7 +78,7 @@ func TestRoundTripper(t *testing.T) { t.Run(tc.name, func(t *testing.T) { server := httptest.NewServer(nil) defer server.Close() - req, err := http.NewRequestWithContext(tc.requestContext, "GET", server.URL, nil) + req, err := http.NewRequestWithContext(tc.requestContext, http.MethodGet, server.URL, nil) require.NoError(t, err) tr := RoundTripper{ diff --git a/pkg/clientcfg/clientcfghttp/handler_test.go b/pkg/clientcfg/clientcfghttp/handler_test.go index 296468b458d..fa16f52d71c 100644 --- a/pkg/clientcfg/clientcfghttp/handler_test.go +++ b/pkg/clientcfg/clientcfghttp/handler_test.go @@ -283,14 +283,14 @@ func TestHTTPHandlerErrors(t *testing.T) { withServer("", probabilistic(0.001), restrictions("luggage", 10), withGorilla, func(ts *testServer) { handler := ts.handler - req := httptest.NewRequest("GET", "http://localhost:80/?service=X", nil) + req := httptest.NewRequest(http.MethodGet, "http://localhost:80/?service=X", nil) w := &mockWriter{header: make(http.Header)} handler.serveSamplingHTTP(w, req, handler.encodeThriftLegacy) ts.metricsFactory.AssertCounterMetrics(t, metricstest.ExpectedMetric{Name: "http-server.errors", Tags: map[string]string{"source": "write", "status": "5xx"}, Value: 1}) - req = httptest.NewRequest("GET", "http://localhost:80/baggageRestrictions?service=X", nil) + req = httptest.NewRequest(http.MethodGet, "http://localhost:80/baggageRestrictions?service=X", nil) handler.serveBaggageHTTP(w, req) ts.metricsFactory.AssertCounterMetrics(t, diff --git a/pkg/es/wrapper/wrapper.go b/pkg/es/wrapper/wrapper.go index cdca19fd768..e34b8c49590 100644 --- a/pkg/es/wrapper/wrapper.go +++ b/pkg/es/wrapper/wrapper.go @@ -7,6 +7,7 @@ package eswrapper import ( "context" "fmt" + "net/http" "strings" esV8 "github.com/elastic/go-elasticsearch/v8" @@ -193,7 +194,7 @@ func (c TemplateCreatorWrapperV8) Do(context.Context) (*elastic.IndicesPutTempla if err != nil { return nil, fmt.Errorf("error creating index template %s: %w", c.templateName, err) } - if resp.StatusCode != 200 { + if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("error creating index template %s: %s", c.templateName, resp) } return nil, nil // no response expected by span writer diff --git a/pkg/version/handler.go b/pkg/version/handler.go index bb094af94a9..a92cd11ff3b 100644 --- a/pkg/version/handler.go +++ b/pkg/version/handler.go @@ -18,7 +18,7 @@ func RegisterHandler(mu *http.ServeMux, logger *zap.Logger) { logger.Fatal("Could not get Jaeger version", zap.Error(err)) } mu.HandleFunc("/version", func(w http.ResponseWriter, _ *http.Request) { - w.WriteHeader(200) + w.WriteHeader(http.StatusOK) w.Write(jsonData) }) } diff --git a/plugin/sampling/strategyprovider/adaptive/aggregator_test.go b/plugin/sampling/strategyprovider/adaptive/aggregator_test.go index eec8ab76892..a2145f80c35 100644 --- a/plugin/sampling/strategyprovider/adaptive/aggregator_test.go +++ b/plugin/sampling/strategyprovider/adaptive/aggregator_test.go @@ -4,6 +4,7 @@ package adaptive import ( + "net/http" "testing" "time" @@ -37,12 +38,12 @@ func TestAggregator(t *testing.T) { a, err := NewAggregator(testOpts, logger, metricsFactory, mockEP, mockStorage) require.NoError(t, err) - a.RecordThroughput("A", "GET", model.SamplerTypeProbabilistic, 0.001) - a.RecordThroughput("B", "POST", model.SamplerTypeProbabilistic, 0.001) - a.RecordThroughput("C", "GET", model.SamplerTypeProbabilistic, 0.001) - a.RecordThroughput("A", "POST", model.SamplerTypeProbabilistic, 0.001) - a.RecordThroughput("A", "GET", model.SamplerTypeProbabilistic, 0.001) - a.RecordThroughput("A", "GET", model.SamplerTypeLowerBound, 0.001) + a.RecordThroughput("A", http.MethodGet, model.SamplerTypeProbabilistic, 0.001) + a.RecordThroughput("B", http.MethodPost, model.SamplerTypeProbabilistic, 0.001) + a.RecordThroughput("C", http.MethodGet, model.SamplerTypeProbabilistic, 0.001) + a.RecordThroughput("A", http.MethodPost, model.SamplerTypeProbabilistic, 0.001) + a.RecordThroughput("A", http.MethodGet, model.SamplerTypeProbabilistic, 0.001) + a.RecordThroughput("A", http.MethodGet, model.SamplerTypeLowerBound, 0.001) a.Start() defer a.Close() @@ -74,17 +75,17 @@ func TestIncrementThroughput(t *testing.T) { require.NoError(t, err) // 20 different probabilities for i := 0; i < 20; i++ { - a.RecordThroughput("A", "GET", model.SamplerTypeProbabilistic, 0.001*float64(i)) + a.RecordThroughput("A", http.MethodGet, model.SamplerTypeProbabilistic, 0.001*float64(i)) } - assert.Len(t, a.(*aggregator).currentThroughput["A"]["GET"].Probabilities, 10) + assert.Len(t, a.(*aggregator).currentThroughput["A"][http.MethodGet].Probabilities, 10) a, err = NewAggregator(testOpts, logger, metricsFactory, mockEP, mockStorage) require.NoError(t, err) // 20 of the same probabilities for i := 0; i < 20; i++ { - a.RecordThroughput("A", "GET", model.SamplerTypeProbabilistic, 0.001) + a.RecordThroughput("A", http.MethodGet, model.SamplerTypeProbabilistic, 0.001) } - assert.Len(t, a.(*aggregator).currentThroughput["A"]["GET"].Probabilities, 1) + assert.Len(t, a.(*aggregator).currentThroughput["A"][http.MethodGet].Probabilities, 1) } func TestLowerboundThroughput(t *testing.T) { @@ -100,9 +101,9 @@ func TestLowerboundThroughput(t *testing.T) { a, err := NewAggregator(testOpts, logger, metricsFactory, mockEP, mockStorage) require.NoError(t, err) - a.RecordThroughput("A", "GET", model.SamplerTypeLowerBound, 0.001) - assert.EqualValues(t, 0, a.(*aggregator).currentThroughput["A"]["GET"].Count) - assert.Empty(t, a.(*aggregator).currentThroughput["A"]["GET"].Probabilities["0.001000"]) + a.RecordThroughput("A", http.MethodGet, model.SamplerTypeLowerBound, 0.001) + assert.EqualValues(t, 0, a.(*aggregator).currentThroughput["A"][http.MethodGet].Count) + assert.Empty(t, a.(*aggregator).currentThroughput["A"][http.MethodGet].Probabilities["0.001000"]) } func TestRecordThroughput(t *testing.T) { @@ -132,7 +133,7 @@ func TestRecordThroughput(t *testing.T) { require.Empty(t, a.(*aggregator).currentThroughput) // Testing span with service name and operation but no probabilistic sampling tags - span.OperationName = "GET" + span.OperationName = http.MethodGet a.HandleRootSpan(span, logger) require.Empty(t, a.(*aggregator).currentThroughput) @@ -142,7 +143,7 @@ func TestRecordThroughput(t *testing.T) { model.String("sampler.param", "0.001"), } a.HandleRootSpan(span, logger) - assert.EqualValues(t, 1, a.(*aggregator).currentThroughput["A"]["GET"].Count) + assert.EqualValues(t, 1, a.(*aggregator).currentThroughput["A"][http.MethodGet].Count) } func TestRecordThroughputFunc(t *testing.T) { @@ -173,7 +174,7 @@ func TestRecordThroughputFunc(t *testing.T) { require.Empty(t, a.(*aggregator).currentThroughput) // Testing span with service name and operation but no probabilistic sampling tags - span.OperationName = "GET" + span.OperationName = http.MethodGet a.HandleRootSpan(span, logger) require.Empty(t, a.(*aggregator).currentThroughput) @@ -183,5 +184,5 @@ func TestRecordThroughputFunc(t *testing.T) { model.String("sampler.param", "0.001"), } a.HandleRootSpan(span, logger) - assert.EqualValues(t, 1, a.(*aggregator).currentThroughput["A"]["GET"].Count) + assert.EqualValues(t, 1, a.(*aggregator).currentThroughput["A"][http.MethodGet].Count) } diff --git a/plugin/sampling/strategyprovider/adaptive/post_aggregator_test.go b/plugin/sampling/strategyprovider/adaptive/post_aggregator_test.go index 6a0f71b1eb6..fd0da089ac6 100644 --- a/plugin/sampling/strategyprovider/adaptive/post_aggregator_test.go +++ b/plugin/sampling/strategyprovider/adaptive/post_aggregator_test.go @@ -5,6 +5,7 @@ package adaptive import ( "errors" + "net/http" "testing" "time" @@ -24,10 +25,10 @@ import ( func testThroughputs() []*model.Throughput { return []*model.Throughput{ - {Service: "svcA", Operation: "GET", Count: 4, Probabilities: map[string]struct{}{"0.1": {}}}, - {Service: "svcA", Operation: "GET", Count: 4, Probabilities: map[string]struct{}{"0.2": {}}}, - {Service: "svcA", Operation: "PUT", Count: 5, Probabilities: map[string]struct{}{"0.1": {}}}, - {Service: "svcB", Operation: "GET", Count: 3, Probabilities: map[string]struct{}{"0.1": {}}}, + {Service: "svcA", Operation: http.MethodGet, Count: 4, Probabilities: map[string]struct{}{"0.1": {}}}, + {Service: "svcA", Operation: http.MethodGet, Count: 4, Probabilities: map[string]struct{}{"0.2": {}}}, + {Service: "svcA", Operation: http.MethodPut, Count: 5, Probabilities: map[string]struct{}{"0.1": {}}}, + {Service: "svcB", Operation: http.MethodGet, Count: 3, Probabilities: map[string]struct{}{"0.1": {}}}, } } @@ -36,12 +37,12 @@ func testThroughputBuckets() []*throughputBucket { { throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "GET": {Count: 45}, - "PUT": {Count: 60}, + http.MethodGet: {Count: 45}, + http.MethodPut: {Count: 60}, }, "svcB": map[string]*model.Throughput{ - "GET": {Count: 30}, - "PUT": {Count: 15}, + http.MethodGet: {Count: 30}, + http.MethodPut: {Count: 15}, }, }, interval: 60 * time.Second, @@ -49,10 +50,10 @@ func testThroughputBuckets() []*throughputBucket { { throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "GET": {Count: 30}, + http.MethodGet: {Count: 30}, }, "svcB": map[string]*model.Throughput{ - "GET": {Count: 45}, + http.MethodGet: {Count: 45}, }, }, interval: 60 * time.Second, @@ -87,12 +88,12 @@ func TestAggregateThroughput(t *testing.T) { require.True(t, ok) require.Len(t, throughput, 2) - opThroughput, ok := throughput["GET"] + opThroughput, ok := throughput[http.MethodGet] require.True(t, ok) assert.Equal(t, int64(8), opThroughput.Count) assert.Equal(t, map[string]struct{}{"0.1": {}, "0.2": {}}, opThroughput.Probabilities) - opThroughput, ok = throughput["PUT"] + opThroughput, ok = throughput[http.MethodPut] require.True(t, ok) assert.Equal(t, int64(5), opThroughput.Count) assert.Equal(t, map[string]struct{}{"0.1": {}}, opThroughput.Probabilities) @@ -101,7 +102,7 @@ func TestAggregateThroughput(t *testing.T) { require.True(t, ok) require.Len(t, throughput, 1) - opThroughput, ok = throughput["GET"] + opThroughput, ok = throughput[http.MethodGet] require.True(t, ok) assert.Equal(t, int64(3), opThroughput.Count) assert.Equal(t, map[string]struct{}{"0.1": {}}, opThroughput.Probabilities) @@ -112,7 +113,7 @@ func TestInitializeThroughput(t *testing.T) { mockStorage.On("GetThroughput", time.Time{}.Add(time.Minute*19), time.Time{}.Add(time.Minute*20)). Return(testThroughputs(), nil) mockStorage.On("GetThroughput", time.Time{}.Add(time.Minute*18), time.Time{}.Add(time.Minute*19)). - Return([]*model.Throughput{{Service: "svcA", Operation: "GET", Count: 7}}, nil) + Return([]*model.Throughput{{Service: "svcA", Operation: http.MethodGet, Count: 7}}, nil) mockStorage.On("GetThroughput", time.Time{}.Add(time.Minute*17), time.Time{}.Add(time.Minute*18)). Return([]*model.Throughput{}, nil) p := &PostAggregator{storage: mockStorage, Options: Options{CalculationInterval: time.Minute, AggregationBuckets: 3}} @@ -154,22 +155,22 @@ func TestGenerateOperationQPS(t *testing.T) { require.True(t, ok) require.Len(t, opQPS, 2) - assert.Equal(t, []float64{0.75, 0.5}, opQPS["GET"]) - assert.Equal(t, []float64{1.0}, opQPS["PUT"]) + assert.Equal(t, []float64{0.75, 0.5}, opQPS[http.MethodGet]) + assert.Equal(t, []float64{1.0}, opQPS[http.MethodPut]) opQPS, ok = svcOpQPS["svcB"] require.True(t, ok) require.Len(t, opQPS, 2) - assert.Equal(t, []float64{0.5, 0.75}, opQPS["GET"]) - assert.Equal(t, []float64{0.25}, opQPS["PUT"]) + assert.Equal(t, []float64{0.5, 0.75}, opQPS[http.MethodGet]) + assert.Equal(t, []float64{0.25}, opQPS[http.MethodPut]) // Test using the previous QPS if the throughput is not provided p.prependThroughputBucket( &throughputBucket{ throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "GET": {Count: 30}, + http.MethodGet: {Count: 30}, }, }, interval: 60 * time.Second, @@ -182,15 +183,15 @@ func TestGenerateOperationQPS(t *testing.T) { require.True(t, ok) require.Len(t, opQPS, 2) - assert.Equal(t, []float64{0.5, 0.75, 0.5}, opQPS["GET"]) - assert.Equal(t, []float64{1.0}, opQPS["PUT"]) + assert.Equal(t, []float64{0.5, 0.75, 0.5}, opQPS[http.MethodGet]) + assert.Equal(t, []float64{1.0}, opQPS[http.MethodPut]) opQPS, ok = svcOpQPS["svcB"] require.True(t, ok) require.Len(t, opQPS, 2) - assert.Equal(t, []float64{0.5, 0.75}, opQPS["GET"]) - assert.Equal(t, []float64{0.25}, opQPS["PUT"]) + assert.Equal(t, []float64{0.5, 0.75}, opQPS[http.MethodGet]) + assert.Equal(t, []float64{0.25}, opQPS[http.MethodPut]) } func TestGenerateOperationQPS_UseMostRecentBucketOnly(t *testing.T) { @@ -202,14 +203,14 @@ func TestGenerateOperationQPS_UseMostRecentBucketOnly(t *testing.T) { require.True(t, ok) require.Len(t, opQPS, 2) - assert.Equal(t, []float64{0.75}, opQPS["GET"]) - assert.Equal(t, []float64{1.0}, opQPS["PUT"]) + assert.Equal(t, []float64{0.75}, opQPS[http.MethodGet]) + assert.Equal(t, []float64{1.0}, opQPS[http.MethodPut]) p.prependThroughputBucket( &throughputBucket{ throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "GET": {Count: 30}, + http.MethodGet: {Count: 30}, }, }, interval: 60 * time.Second, @@ -223,8 +224,8 @@ func TestGenerateOperationQPS_UseMostRecentBucketOnly(t *testing.T) { require.True(t, ok) require.Len(t, opQPS, 2) - assert.Equal(t, []float64{0.5}, opQPS["GET"]) - assert.Equal(t, []float64{1.0}, opQPS["PUT"]) + assert.Equal(t, []float64{0.5}, opQPS[http.MethodGet]) + assert.Equal(t, []float64{1.0}, opQPS[http.MethodPut]) } func TestCalculateWeightedQPS(t *testing.T) { @@ -239,14 +240,14 @@ func TestCalculateProbability(t *testing.T) { { throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "GET": {Probabilities: map[string]struct{}{"0.500000": {}}}, + http.MethodGet: {Probabilities: map[string]struct{}{"0.500000": {}}}, }, }, }, } probabilities := model.ServiceOperationProbabilities{ "svcA": map[string]float64{ - "GET": 0.5, + http.MethodGet: 0.5, }, } cfg := Options{ @@ -269,12 +270,12 @@ func TestCalculateProbability(t *testing.T) { expectedProbability float64 errMsg string }{ - {"svcA", "GET", 2.0, 0.25, "modify existing probability"}, - {"svcA", "PUT", 2.0, 0.0005, "modify default probability"}, - {"svcB", "GET", 0.9, 0.001, "qps within equivalence threshold"}, - {"svcB", "PUT", 0.000001, 1.0, "test max probability"}, - {"svcB", "DELETE", 1000000000, 0.00001, "test min probability"}, - {"svcB", "DELETE", 0.0, 0.002, "test 0 qps"}, + {"svcA", http.MethodGet, 2.0, 0.25, "modify existing probability"}, + {"svcA", http.MethodPut, 2.0, 0.0005, "modify default probability"}, + {"svcB", http.MethodGet, 0.9, 0.001, "qps within equivalence threshold"}, + {"svcB", http.MethodPut, 0.000001, 1.0, "test max probability"}, + {"svcB", http.MethodDelete, 1000000000, 0.00001, "test min probability"}, + {"svcB", http.MethodDelete, 0.0, 0.002, "test 0 qps"}, } for _, test := range tests { probability := p.calculateProbability(test.service, test.operation, test.qps) @@ -285,13 +286,13 @@ func TestCalculateProbability(t *testing.T) { func TestCalculateProbabilitiesAndQPS(t *testing.T) { prevProbabilities := model.ServiceOperationProbabilities{ "svcB": map[string]float64{ - "GET": 0.16, - "PUT": 0.03, + http.MethodGet: 0.16, + http.MethodPut: 0.03, }, } qps := model.ServiceOperationQPS{ "svcB": map[string]float64{ - "GET": 0.625, + http.MethodGet: 0.625, }, } mets := metricstest.NewFactory(0) @@ -309,12 +310,12 @@ func TestCalculateProbabilitiesAndQPS(t *testing.T) { probabilities, qps := p.calculateProbabilitiesAndQPS() require.Len(t, probabilities, 2) - assert.Equal(t, map[string]float64{"GET": 0.00136, "PUT": 0.001}, probabilities["svcA"]) - assert.Equal(t, map[string]float64{"GET": 0.16, "PUT": 0.03}, probabilities["svcB"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.00136, http.MethodPut: 0.001}, probabilities["svcA"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.16, http.MethodPut: 0.03}, probabilities["svcB"]) require.Len(t, qps, 2) - assert.Equal(t, map[string]float64{"GET": 0.7352941176470588, "PUT": 1}, qps["svcA"]) - assert.Equal(t, map[string]float64{"GET": 0.5147058823529411, "PUT": 0.25}, qps["svcB"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.7352941176470588, http.MethodPut: 1}, qps["svcA"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.5147058823529411, http.MethodPut: 0.25}, qps["svcB"]) _, gauges := mets.Backend.Snapshot() assert.EqualValues(t, 4, gauges["test"]) @@ -477,11 +478,11 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { { throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "GET": {Count: 3, Probabilities: map[string]struct{}{"0.001000": {}}}, - "PUT": {Count: 60, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodGet: {Count: 3, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodPut: {Count: 60, Probabilities: map[string]struct{}{"0.001000": {}}}, }, "svcB": map[string]*model.Throughput{ - "PUT": {Count: 15, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodPut: {Count: 15, Probabilities: map[string]struct{}{"0.001000": {}}}, }, }, interval: 60 * time.Second, @@ -506,8 +507,8 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { probabilities, qps := p.calculateProbabilitiesAndQPS() require.Len(t, probabilities, 2) - assert.Equal(t, map[string]float64{"GET": 0.002, "PUT": 0.001}, probabilities["svcA"]) - assert.Equal(t, map[string]float64{"PUT": 0.002}, probabilities["svcB"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.002, http.MethodPut: 0.001}, probabilities["svcA"]) + assert.Equal(t, map[string]float64{http.MethodPut: 0.002}, probabilities["svcB"]) p.probabilities = probabilities p.qps = qps @@ -518,11 +519,11 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { p.prependThroughputBucket(&throughputBucket{ throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "PUT": {Count: 60, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodPut: {Count: 60, Probabilities: map[string]struct{}{"0.001000": {}}}, }, "svcB": map[string]*model.Throughput{ - "GET": {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, - "PUT": {Count: 0, Probabilities: map[string]struct{}{"0.002000": {}}}, + http.MethodGet: {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodPut: {Count: 0, Probabilities: map[string]struct{}{"0.002000": {}}}, }, }, interval: 60 * time.Second, @@ -531,8 +532,8 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { probabilities, qps = p.calculateProbabilitiesAndQPS() require.Len(t, probabilities, 2) - assert.Equal(t, map[string]float64{"GET": 0.002, "PUT": 0.001}, probabilities["svcA"]) - assert.Equal(t, map[string]float64{"PUT": 0.004, "GET": 0.002}, probabilities["svcB"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.002, http.MethodPut: 0.001}, probabilities["svcA"]) + assert.Equal(t, map[string]float64{http.MethodPut: 0.004, http.MethodGet: 0.002}, probabilities["svcB"]) p.probabilities = probabilities p.qps = qps @@ -543,11 +544,11 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { p.prependThroughputBucket(&throughputBucket{ throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "GET": {Count: 0, Probabilities: map[string]struct{}{"0.002000": {}}}, - "PUT": {Count: 60, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodGet: {Count: 0, Probabilities: map[string]struct{}{"0.002000": {}}}, + http.MethodPut: {Count: 60, Probabilities: map[string]struct{}{"0.001000": {}}}, }, "svcB": map[string]*model.Throughput{ - "GET": {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodGet: {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, }, }, interval: 60 * time.Second, @@ -556,8 +557,8 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { probabilities, qps = p.calculateProbabilitiesAndQPS() require.Len(t, probabilities, 2) - assert.Equal(t, map[string]float64{"GET": 0.004, "PUT": 0.001}, probabilities["svcA"]) - assert.Equal(t, map[string]float64{"PUT": 0.008, "GET": 0.002}, probabilities["svcB"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.004, http.MethodPut: 0.001}, probabilities["svcA"]) + assert.Equal(t, map[string]float64{http.MethodPut: 0.008, http.MethodGet: 0.002}, probabilities["svcB"]) p.probabilities = probabilities p.qps = qps @@ -567,12 +568,12 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { p.prependThroughputBucket(&throughputBucket{ throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "GET": {Count: 1, Probabilities: map[string]struct{}{"0.004000": {}}}, - "PUT": {Count: 60, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodGet: {Count: 1, Probabilities: map[string]struct{}{"0.004000": {}}}, + http.MethodPut: {Count: 60, Probabilities: map[string]struct{}{"0.001000": {}}}, }, "svcB": map[string]*model.Throughput{ - "GET": {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, - "PUT": {Count: 15, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodGet: {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodPut: {Count: 15, Probabilities: map[string]struct{}{"0.001000": {}}}, }, }, interval: 60 * time.Second, @@ -581,8 +582,8 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { probabilities, qps = p.calculateProbabilitiesAndQPS() require.Len(t, probabilities, 2) - assert.Equal(t, map[string]float64{"GET": 0.008, "PUT": 0.001}, probabilities["svcA"]) - assert.Equal(t, map[string]float64{"PUT": 0.008, "GET": 0.002}, probabilities["svcB"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.008, http.MethodPut: 0.001}, probabilities["svcA"]) + assert.Equal(t, map[string]float64{http.MethodPut: 0.008, http.MethodGet: 0.002}, probabilities["svcB"]) p.probabilities = probabilities p.qps = qps @@ -591,11 +592,11 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { p.prependThroughputBucket(&throughputBucket{ throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "PUT": {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodPut: {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, }, "svcB": map[string]*model.Throughput{ - "GET": {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, - "PUT": {Count: 15, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodGet: {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodPut: {Count: 15, Probabilities: map[string]struct{}{"0.001000": {}}}, }, }, interval: 60 * time.Second, @@ -604,8 +605,8 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { probabilities, qps = p.calculateProbabilitiesAndQPS() require.Len(t, probabilities, 2) - assert.Equal(t, map[string]float64{"GET": 0.016, "PUT": 0.001468867216804201}, probabilities["svcA"]) - assert.Equal(t, map[string]float64{"PUT": 0.008, "GET": 0.002}, probabilities["svcB"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.016, http.MethodPut: 0.001468867216804201}, probabilities["svcA"]) + assert.Equal(t, map[string]float64{http.MethodPut: 0.008, http.MethodGet: 0.002}, probabilities["svcB"]) p.probabilities = probabilities p.qps = qps @@ -615,11 +616,11 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { p.prependThroughputBucket(&throughputBucket{ throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "PUT": {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodPut: {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, }, "svcB": map[string]*model.Throughput{ - "GET": {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, - "PUT": {Count: 1, Probabilities: map[string]struct{}{"0.008000": {}}}, + http.MethodGet: {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodPut: {Count: 1, Probabilities: map[string]struct{}{"0.008000": {}}}, }, }, interval: 60 * time.Second, @@ -628,8 +629,8 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { probabilities, qps = p.calculateProbabilitiesAndQPS() require.Len(t, probabilities, 2) - assert.Equal(t, map[string]float64{"GET": 0.032, "PUT": 0.001468867216804201}, probabilities["svcA"]) - assert.Equal(t, map[string]float64{"PUT": 0.016, "GET": 0.002}, probabilities["svcB"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.032, http.MethodPut: 0.001468867216804201}, probabilities["svcA"]) + assert.Equal(t, map[string]float64{http.MethodPut: 0.016, http.MethodGet: 0.002}, probabilities["svcB"]) p.probabilities = probabilities p.qps = qps @@ -639,10 +640,10 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { p.prependThroughputBucket(&throughputBucket{ throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "PUT": {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodPut: {Count: 30, Probabilities: map[string]struct{}{"0.001000": {}}}, }, "svcB": map[string]*model.Throughput{ - "GET": {Count: 15, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodGet: {Count: 15, Probabilities: map[string]struct{}{"0.001000": {}}}, }, }, interval: 60 * time.Second, @@ -651,8 +652,8 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { probabilities, qps = p.calculateProbabilitiesAndQPS() require.Len(t, probabilities, 2) - assert.Equal(t, map[string]float64{"GET": 0.064, "PUT": 0.001468867216804201}, probabilities["svcA"]) - assert.Equal(t, map[string]float64{"PUT": 0.032, "GET": 0.002}, probabilities["svcB"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.064, http.MethodPut: 0.001468867216804201}, probabilities["svcA"]) + assert.Equal(t, map[string]float64{http.MethodPut: 0.032, http.MethodGet: 0.002}, probabilities["svcB"]) p.probabilities = probabilities p.qps = qps @@ -662,10 +663,10 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { p.prependThroughputBucket(&throughputBucket{ throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "PUT": {Count: 20, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodPut: {Count: 20, Probabilities: map[string]struct{}{"0.001000": {}}}, }, "svcB": map[string]*model.Throughput{ - "GET": {Count: 10, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodGet: {Count: 10, Probabilities: map[string]struct{}{"0.001000": {}}}, }, }, interval: 60 * time.Second, @@ -674,8 +675,8 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { probabilities, qps = p.calculateProbabilitiesAndQPS() require.Len(t, probabilities, 2) - assert.Equal(t, map[string]float64{"GET": 0.128, "PUT": 0.001468867216804201}, probabilities["svcA"]) - assert.Equal(t, map[string]float64{"PUT": 0.064, "GET": 0.002}, probabilities["svcB"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.128, http.MethodPut: 0.001468867216804201}, probabilities["svcA"]) + assert.Equal(t, map[string]float64{http.MethodPut: 0.064, http.MethodGet: 0.002}, probabilities["svcB"]) p.probabilities = probabilities p.qps = qps @@ -685,12 +686,12 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { p.prependThroughputBucket(&throughputBucket{ throughput: serviceOperationThroughput{ "svcA": map[string]*model.Throughput{ - "PUT": {Count: 20, Probabilities: map[string]struct{}{"0.001000": {}}}, - "GET": {Count: 120, Probabilities: map[string]struct{}{"0.128000": {}}}, + http.MethodPut: {Count: 20, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodGet: {Count: 120, Probabilities: map[string]struct{}{"0.128000": {}}}, }, "svcB": map[string]*model.Throughput{ - "PUT": {Count: 60, Probabilities: map[string]struct{}{"0.064000": {}}}, - "GET": {Count: 10, Probabilities: map[string]struct{}{"0.001000": {}}}, + http.MethodPut: {Count: 60, Probabilities: map[string]struct{}{"0.064000": {}}}, + http.MethodGet: {Count: 10, Probabilities: map[string]struct{}{"0.001000": {}}}, }, }, interval: 60 * time.Second, @@ -699,8 +700,8 @@ func TestCalculateProbabilitiesAndQPSMultiple(t *testing.T) { probabilities, qps = p.calculateProbabilitiesAndQPS() require.Len(t, probabilities, 2) - assert.Equal(t, map[string]float64{"GET": 0.0882586677054928, "PUT": 0.001468867216804201}, probabilities["svcA"]) - assert.Equal(t, map[string]float64{"PUT": 0.09587513707888091, "GET": 0.002}, probabilities["svcB"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.0882586677054928, http.MethodPut: 0.001468867216804201}, probabilities["svcA"]) + assert.Equal(t, map[string]float64{http.MethodPut: 0.09587513707888091, http.MethodGet: 0.002}, probabilities["svcB"]) p.probabilities = probabilities p.qps = qps diff --git a/plugin/sampling/strategyprovider/adaptive/provider_test.go b/plugin/sampling/strategyprovider/adaptive/provider_test.go index 8a26d8fc34d..1342cd21790 100644 --- a/plugin/sampling/strategyprovider/adaptive/provider_test.go +++ b/plugin/sampling/strategyprovider/adaptive/provider_test.go @@ -5,6 +5,7 @@ package adaptive import ( "context" + "net/http" "testing" "time" @@ -68,10 +69,10 @@ func TestProviderRealisticRunCalculationLoop(t *testing.T) { logger := zap.NewNop() // NB: This is an extremely long test since it uses near realistic (1/6th scale) processor config values testThroughputs := []*model.Throughput{ - {Service: "svcA", Operation: "GET", Count: 10}, - {Service: "svcA", Operation: "POST", Count: 9}, - {Service: "svcA", Operation: "PUT", Count: 5}, - {Service: "svcA", Operation: "DELETE", Count: 20}, + {Service: "svcA", Operation: http.MethodGet, Count: 10}, + {Service: "svcA", Operation: http.MethodPost, Count: 9}, + {Service: "svcA", Operation: http.MethodPut, Count: 5}, + {Service: "svcA", Operation: http.MethodDelete, Count: 20}, } mockStorage := &smocks.Store{} mockStorage.On("GetThroughput", mock.AnythingOfType("time.Time"), mock.AnythingOfType("time.Time")). @@ -110,16 +111,16 @@ func TestProviderRealisticRunCalculationLoop(t *testing.T) { for _, s := range strategies { switch s.Operation { - case "GET": + case http.MethodGet: assert.InDelta(t, 0.001, s.ProbabilisticSampling.SamplingRate, 1e-4, "Already at 1QPS, no probability change") - case "POST": + case http.MethodPost: assert.InDelta(t, 0.001, s.ProbabilisticSampling.SamplingRate, 1e-4, "Within epsilon of 1QPS, no probability change") - case "PUT": + case http.MethodPut: assert.InEpsilon(t, 0.002, s.ProbabilisticSampling.SamplingRate, 0.025, "Under sampled, double probability") - case "DELETE": + case http.MethodDelete: assert.InEpsilon(t, 0.0005, s.ProbabilisticSampling.SamplingRate, 0.025, "Over sampled, halve probability") } @@ -129,7 +130,7 @@ func TestProviderRealisticRunCalculationLoop(t *testing.T) { func TestProviderGenerateStrategyResponses(t *testing.T) { probabilities := model.ServiceOperationProbabilities{ "svcA": map[string]float64{ - "GET": 0.5, + http.MethodGet: 0.5, }, } p := &Provider{ @@ -149,7 +150,7 @@ func TestProviderGenerateStrategyResponses(t *testing.T) { DefaultLowerBoundTracesPerSecond: 0.0001, PerOperationStrategies: []*api_v2.OperationSamplingStrategy{ { - Operation: "GET", + Operation: http.MethodGet, ProbabilisticSampling: &api_v2.ProbabilisticSamplingStrategy{ SamplingRate: 0.5, }, diff --git a/plugin/sampling/strategyprovider/static/provider.go b/plugin/sampling/strategyprovider/static/provider.go index 56890ed63c0..8c801de8f79 100644 --- a/plugin/sampling/strategyprovider/static/provider.go +++ b/plugin/sampling/strategyprovider/static/provider.go @@ -104,7 +104,7 @@ func (h *samplingProvider) downloadSamplingStrategies(samplingURL string) ([]byt ctx, cx := context.WithTimeout(context.Background(), time.Second) defer cx() - req, err := http.NewRequestWithContext(ctx, "GET", samplingURL, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, samplingURL, nil) if err != nil { return nil, fmt.Errorf("cannot construct HTTP request: %w", err) } diff --git a/plugin/sampling/strategyprovider/static/provider_test.go b/plugin/sampling/strategyprovider/static/provider_test.go index ba7992f18f8..783caeb5c54 100644 --- a/plugin/sampling/strategyprovider/static/provider_test.go +++ b/plugin/sampling/strategyprovider/static/provider_test.go @@ -73,15 +73,15 @@ func mockStrategyServer(t *testing.T) (*httptest.Server, *atomic.Pointer[string] return case "/bad-status": - w.WriteHeader(404) + w.WriteHeader(http.StatusNotFound) return case "/service-unavailable": - w.WriteHeader(503) + w.WriteHeader(http.StatusServiceUnavailable) return default: - w.WriteHeader(200) + w.WriteHeader(http.StatusOK) w.Header().Set("Content-Type", "application/json") w.Write([]byte(*strategy.Load())) } diff --git a/plugin/storage/cassandra/samplingstore/storage_test.go b/plugin/storage/cassandra/samplingstore/storage_test.go index 238d9723f56..774ffeb5422 100644 --- a/plugin/storage/cassandra/samplingstore/storage_test.go +++ b/plugin/storage/cassandra/samplingstore/storage_test.go @@ -6,6 +6,7 @@ package samplingstore import ( "errors" + "net/http" "testing" "time" @@ -329,12 +330,12 @@ func TestStringToThroughput(t *testing.T) { func TestProbabilitiesAndQPSToString(t *testing.T) { probabilities := model.ServiceOperationProbabilities{ "svc,1": map[string]float64{ - "GET": 0.001, + http.MethodGet: 0.001, }, } qps := model.ServiceOperationQPS{ "svc,1": map[string]float64{ - "GET": 62.3, + http.MethodGet: 62.3, }, } str := probabilitiesAndQPSToString(probabilities, qps) @@ -348,17 +349,17 @@ func TestStringToProbabilitiesAndQPS(t *testing.T) { assert.Len(t, probabilities, 2) assert.Equal(t, map[string]*model.ProbabilityAndQPS{ - "GET": { + http.MethodGet: { Probability: 0.001, QPS: 63.2, }, - "PUT": { + http.MethodPut: { Probability: 0.002, QPS: 0.0, }, }, probabilities["svc1"]) assert.Equal(t, map[string]*model.ProbabilityAndQPS{ - "GET": { + http.MethodGet: { Probability: 0.5, QPS: 34.2, }, @@ -371,8 +372,8 @@ func TestStringToProbabilities(t *testing.T) { probabilities := s.stringToProbabilities(testStr) assert.Len(t, probabilities, 2) - assert.Equal(t, map[string]float64{"GET": 0.001, "PUT": 0.002}, probabilities["svc1"]) - assert.Equal(t, map[string]float64{"GET": 0.5}, probabilities["svc2"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.001, http.MethodPut: 0.002}, probabilities["svc1"]) + assert.Equal(t, map[string]float64{http.MethodGet: 0.5}, probabilities["svc2"]) } func TestProbabilitiesSetToString(t *testing.T) { diff --git a/plugin/storage/es/options_test.go b/plugin/storage/es/options_test.go index 33d933b5830..87b2ce11d7f 100644 --- a/plugin/storage/es/options_test.go +++ b/plugin/storage/es/options_test.go @@ -5,6 +5,7 @@ package es import ( + "net/http" "testing" "time" @@ -117,7 +118,7 @@ func TestOptionsWithFlags(t *testing.T) { assert.Equal(t, "2006.01.02", aux.Indices.Services.DateLayout) assert.Equal(t, "2006.01.02.15", aux.Indices.Spans.DateLayout) assert.True(t, primary.UseILM) - assert.Equal(t, "POST", aux.SendGetBodyAs) + assert.Equal(t, http.MethodPost, aux.SendGetBodyAs) } func TestEmptyRemoteReadClusters(t *testing.T) { diff --git a/plugin/storage/grpc/proto/storage.proto b/plugin/storage/grpc/proto/storage.proto index 51c804948fb..7491b665043 100644 --- a/plugin/storage/grpc/proto/storage.proto +++ b/plugin/storage/grpc/proto/storage.proto @@ -72,6 +72,14 @@ message GetTraceRequest { (gogoproto.customtype) = "github.com/jaegertracing/jaeger/model.TraceID", (gogoproto.customname) = "TraceID" ]; + google.protobuf.Timestamp start_time = 2 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; + google.protobuf.Timestamp end_time = 3 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; } message GetServicesRequest {} diff --git a/plugin/storage/grpc/proto/storage_test.proto b/plugin/storage/grpc/proto/storage_test.proto index b279e05dbab..49d001975c4 100644 --- a/plugin/storage/grpc/proto/storage_test.proto +++ b/plugin/storage/grpc/proto/storage_test.proto @@ -18,6 +18,10 @@ package storageprototest; option go_package = "./storageprototest"; +import "google/protobuf/timestamp.proto"; + message GetTraceRequest { bytes trace_id = 1; + google.protobuf.Timestamp start_time = 2; + google.protobuf.Timestamp end_time = 3; } diff --git a/plugin/storage/grpc/proto/storage_v1/storage_test.go b/plugin/storage/grpc/proto/storage_v1/storage_test.go index 6d5be333e76..12aff133c26 100644 --- a/plugin/storage/grpc/proto/storage_v1/storage_test.go +++ b/plugin/storage/grpc/proto/storage_v1/storage_test.go @@ -10,6 +10,7 @@ import ( "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "google.golang.org/protobuf/types/known/timestamppb" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/testutils" @@ -31,9 +32,15 @@ func TestGetTraceRequestMarshalProto(t *testing.T) { } for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - ref1 := storage_v1.GetTraceRequest{TraceID: model.NewTraceID(2, 3)} + ref1 := storage_v1.GetTraceRequest{ + TraceID: model.NewTraceID(2, 3), + StartTime: time.Unix(1, 2).UTC(), + EndTime: time.Unix(3, 4).UTC(), + } ref2 := storageprototest.GetTraceRequest{ - TraceId: []byte{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3}, + TraceId: []byte{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3}, + StartTime: timestamppb.New(time.Unix(1, 2).UTC()), + EndTime: timestamppb.New(time.Unix(3, 4).UTC()), } d1, err := testCase.marshal(&ref1) require.NoError(t, err) diff --git a/plugin/storage/grpc/proto/storageprototest/storage_test.pb.go b/plugin/storage/grpc/proto/storageprototest/storage_test.pb.go index 369e573cf8f..d2c84edaec3 100644 --- a/plugin/storage/grpc/proto/storageprototest/storage_test.pb.go +++ b/plugin/storage/grpc/proto/storageprototest/storage_test.pb.go @@ -23,6 +23,7 @@ package storageprototest import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) @@ -39,7 +40,9 @@ type GetTraceRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TraceId []byte `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` + TraceId []byte `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` + StartTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` + EndTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"` } func (x *GetTraceRequest) Reset() { @@ -81,17 +84,40 @@ func (x *GetTraceRequest) GetTraceId() []byte { return nil } +func (x *GetTraceRequest) GetStartTime() *timestamppb.Timestamp { + if x != nil { + return x.StartTime + } + return nil +} + +func (x *GetTraceRequest) GetEndTime() *timestamppb.Timestamp { + if x != nil { + return x.EndTime + } + return nil +} + var File_storage_test_proto protoreflect.FileDescriptor var file_storage_test_proto_rawDesc = []byte{ 0x0a, 0x12, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x74, 0x65, 0x73, 0x74, 0x22, 0x2c, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, - 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, 0x61, - 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x74, 0x72, 0x61, - 0x63, 0x65, 0x49, 0x64, 0x42, 0x14, 0x5a, 0x12, 0x2e, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, - 0x65, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x74, 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x74, 0x6f, 0x74, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9e, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x54, + 0x72, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x74, + 0x72, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x74, + 0x72, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x39, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, + 0x65, 0x12, 0x35, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x42, 0x14, 0x5a, 0x12, 0x2e, 0x2f, 0x73, 0x74, + 0x6f, 0x72, 0x61, 0x67, 0x65, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x74, 0x65, 0x73, 0x74, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -108,14 +134,17 @@ func file_storage_test_proto_rawDescGZIP() []byte { var file_storage_test_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_storage_test_proto_goTypes = []interface{}{ - (*GetTraceRequest)(nil), // 0: storageprototest.GetTraceRequest + (*GetTraceRequest)(nil), // 0: storageprototest.GetTraceRequest + (*timestamppb.Timestamp)(nil), // 1: google.protobuf.Timestamp } var file_storage_test_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 1, // 0: storageprototest.GetTraceRequest.start_time:type_name -> google.protobuf.Timestamp + 1, // 1: storageprototest.GetTraceRequest.end_time:type_name -> google.protobuf.Timestamp + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_storage_test_proto_init() } diff --git a/proto-gen/storage_v1/storage.pb.go b/proto-gen/storage_v1/storage.pb.go index 5564abb7ed4..72e11ee49ce 100644 --- a/proto-gen/storage_v1/storage.pb.go +++ b/proto-gen/storage_v1/storage.pb.go @@ -304,6 +304,8 @@ var xxx_messageInfo_CloseWriterResponse proto.InternalMessageInfo type GetTraceRequest struct { TraceID github_com_jaegertracing_jaeger_model.TraceID `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3,customtype=github.com/jaegertracing/jaeger/model.TraceID" json:"trace_id"` + StartTime time.Time `protobuf:"bytes,2,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time"` + EndTime time.Time `protobuf:"bytes,3,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -342,6 +344,20 @@ func (m *GetTraceRequest) XXX_DiscardUnknown() { var xxx_messageInfo_GetTraceRequest proto.InternalMessageInfo +func (m *GetTraceRequest) GetStartTime() time.Time { + if m != nil { + return m.StartTime + } + return time.Time{} +} + +func (m *GetTraceRequest) GetEndTime() time.Time { + if m != nil { + return m.EndTime + } + return time.Time{} +} + type GetServicesRequest struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -1006,77 +1022,78 @@ func init() { func init() { proto.RegisterFile("storage.proto", fileDescriptor_0d2c4ccf1453ffdb) } var fileDescriptor_0d2c4ccf1453ffdb = []byte{ - // 1117 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x6f, 0xdc, 0xc4, - 0x1b, 0xfe, 0x39, 0xd9, 0x6d, 0x76, 0xdf, 0xdd, 0xb4, 0xc9, 0xec, 0xf6, 0x57, 0xd7, 0xd0, 0x24, - 0x18, 0x9a, 0x04, 0x04, 0xde, 0x66, 0x39, 0x80, 0xa0, 0x08, 0x9a, 0x3f, 0x8d, 0x02, 0x14, 0x8a, - 0x13, 0xb5, 0x12, 0x85, 0xac, 0x66, 0xe3, 0xc1, 0x19, 0xb2, 0x1e, 0x6f, 0xed, 0xf1, 0x2a, 0x11, - 0xe2, 0xc6, 0x07, 0xe0, 0xc8, 0x89, 0x13, 0x12, 0xdf, 0x83, 0x53, 0x8f, 0x9c, 0x39, 0x04, 0x94, - 0x2b, 0x5f, 0x02, 0x79, 0x66, 0xec, 0xd8, 0x6b, 0x2b, 0x49, 0xa3, 0xdc, 0x3c, 0xef, 0x3c, 0xf3, - 0xbc, 0xff, 0x66, 0x9e, 0xd7, 0x30, 0x1d, 0x72, 0x3f, 0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e, 0xe5, 0x3c, 0xe7, 0x6e, 0xdb, 0xae, - 0xf8, 0xb5, 0x53, 0xbb, 0x57, 0x7f, 0xe9, 0xba, 0x3f, 0x69, 0xa0, 0xe7, 0xff, 0x8d, 0x33, 0xce, - 0xf7, 0x85, 0xf3, 0xec, 0x36, 0x7a, 0xb3, 0xdc, 0x79, 0xc9, 0xef, 0xbf, 0xf1, 0xd6, 0x45, 0xa0, - 0xaa, 0x02, 0x11, 0x20, 0xe9, 0x33, 0xab, 0xab, 0x71, 0xcb, 0x73, 0xeb, 0x52, 0xd1, 0x28, 0x0a, - 0x74, 0x69, 0xcb, 0xcb, 0x04, 0x7b, 0x55, 0x7f, 0x71, 0x32, 0xa7, 0xfd, 0x79, 0x32, 0xa7, 0xfd, - 0x73, 0x32, 0xa7, 0x7d, 0x0d, 0x0a, 0xde, 0x1b, 0xad, 0xf4, 0xaf, 0x89, 0x29, 0xff, 0xee, 0x7f, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x6c, 0xa3, 0xc0, 0x72, 0x65, 0x0d, 0x00, 0x00, + // 1128 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x4f, 0x73, 0xdb, 0x44, + 0x14, 0x47, 0xb1, 0xdd, 0xd8, 0xcf, 0x4e, 0x9b, 0xac, 0x5d, 0xaa, 0x0a, 0x9a, 0x04, 0x41, 0x93, + 0xc0, 0x80, 0xdc, 0x98, 0x03, 0x0c, 0x94, 0x81, 0xe6, 0x4f, 0x33, 0x01, 0x0a, 0x45, 0xc9, 0xb4, + 0x33, 0x14, 0xe2, 0x59, 0x47, 0x8b, 0x22, 0x62, 0xad, 0x5c, 0x69, 0xe5, 0x49, 0x86, 0xe1, 0xc6, + 0x07, 0xe0, 0xc8, 0x89, 0x13, 0x33, 0x7c, 0x0f, 0x4e, 0x3d, 0x72, 0xe6, 0x10, 0x98, 0x5c, 0xb9, + 0xf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xe6, 0xd6, 0xf9, + 0xd3, 0xd3, 0x87, 0x56, 0x7a, 0x08, 0xa0, 0x85, 0xd3, 0xe8, 0x4f, 0x66, 0x8f, 0xb6, 0x78, 0x26, + 0x4e, 0xb6, 0xda, 0x01, 0xdc, 0xb8, 0x97, 0x7f, 0x76, 0xb2, 0xe6, 0xdf, 0xca, 0xcf, 0xcc, 0x94, + 0xfe, 0x12, 0x3b, 0xad, 0x77, 0x98, 0xb1, 0x9c, 0xe9, 0xb6, 0x1d, 0xfe, 0x81, 0x29, 0xb5, 0x97, + 0xdf, 0x74, 0xbd, 0x9f, 0x14, 0x50, 0xb3, 0x9f, 0xe8, 0x29, 0xe3, 0x7b, 0xdc, 0x78, 0x5a, 0x8d, + 0xde, 0x2c, 0x37, 0x5e, 0xf2, 0x2f, 0x44, 0x7b, 0xeb, 0x3c, 0x50, 0x99, 0x81, 0x10, 0x90, 0xb0, + 0x99, 0x9e, 0xab, 0x51, 0xc9, 0x33, 0xe7, 0xd2, 0xa1, 0x51, 0x1c, 0xd0, 0xa5, 0x25, 0x2f, 0x1b, + 0xd8, 0x2b, 0xea, 0xb3, 0xe3, 0x59, 0xe5, 0xcf, 0xe3, 0x59, 0xe5, 0x9f, 0xe3, 0x59, 0xe5, 0x6b, + 0x90, 0xf0, 0xfe, 0x78, 0x79, 0x70, 0x85, 0x6f, 0xf9, 0x77, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, + 0x4d, 0x42, 0xc0, 0x41, 0xec, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2125,6 +2142,22 @@ func (m *GetTraceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } + n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.EndTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.EndTime):]) + if err4 != nil { + return 0, err4 + } + i -= n4 + i = encodeVarintStorage(dAtA, i, uint64(n4)) + i-- + dAtA[i] = 0x1a + n5, err5 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime):]) + if err5 != nil { + return 0, err5 + } + i -= n5 + i = encodeVarintStorage(dAtA, i, uint64(n5)) + i-- + dAtA[i] = 0x12 { size := m.TraceID.Size() i -= size @@ -2362,37 +2395,37 @@ func (m *TraceQueryParameters) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x40 } - n4, err4 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.DurationMax, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.DurationMax):]) - if err4 != nil { - return 0, err4 - } - i -= n4 - i = encodeVarintStorage(dAtA, i, uint64(n4)) - i-- - dAtA[i] = 0x3a - n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.DurationMin, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.DurationMin):]) - if err5 != nil { - return 0, err5 - } - i -= n5 - i = encodeVarintStorage(dAtA, i, uint64(n5)) - i-- - dAtA[i] = 0x32 - n6, err6 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTimeMax, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTimeMax):]) + n6, err6 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.DurationMax, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.DurationMax):]) if err6 != nil { return 0, err6 } i -= n6 i = encodeVarintStorage(dAtA, i, uint64(n6)) i-- - dAtA[i] = 0x2a - n7, err7 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTimeMin, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTimeMin):]) + dAtA[i] = 0x3a + n7, err7 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.DurationMin, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.DurationMin):]) if err7 != nil { return 0, err7 } i -= n7 i = encodeVarintStorage(dAtA, i, uint64(n7)) i-- + dAtA[i] = 0x32 + n8, err8 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTimeMax, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTimeMax):]) + if err8 != nil { + return 0, err8 + } + i -= n8 + i = encodeVarintStorage(dAtA, i, uint64(n8)) + i-- + dAtA[i] = 0x2a + n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTimeMin, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTimeMin):]) + if err9 != nil { + return 0, err9 + } + i -= n9 + i = encodeVarintStorage(dAtA, i, uint64(n9)) + i-- dAtA[i] = 0x22 if len(m.Tags) > 0 { for k := range m.Tags { @@ -2779,6 +2812,10 @@ func (m *GetTraceRequest) Size() (n int) { _ = l l = m.TraceID.Size() n += 1 + l + sovStorage(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime) + n += 1 + l + sovStorage(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.EndTime) + n += 1 + l + sovStorage(uint64(l)) if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -3529,6 +3566,72 @@ func (m *GetTraceRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStorage + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStorage + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStorage + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStorage + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.EndTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipStorage(dAtA[iNdEx:]) diff --git a/scripts/compare_metrics.py b/scripts/compare_metrics.py deleted file mode 100755 index 36fe190d592..00000000000 --- a/scripts/compare_metrics.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (c) 2024 The Jaeger Authors. -# SPDX-License-Identifier: Apache-2.0 - -import json - -v1_metrics_path = "./V1_Metrics.json" -v2_metrics_path = "./V2_Metrics.json" - -with open(v1_metrics_path, 'r') as file: - v1_metrics = json.load(file) - -with open(v2_metrics_path, 'r') as file: - v2_metrics = json.load(file) - -# Extract names and labels of the metrics -def extract_metrics_with_labels(metrics, strip_prefix=None): - result = {} - for metric in metrics: - name = metric['name'] - if strip_prefix and name.startswith(strip_prefix): - name = name[len(strip_prefix):] - labels = {} - if 'metrics' in metric and 'labels' in metric['metrics'][0]: - labels = metric['metrics'][0]['labels'] - result[name] = labels - return result - - -v1_metrics_with_labels = extract_metrics_with_labels(v1_metrics) -v2_metrics_with_labels = extract_metrics_with_labels( - v2_metrics, strip_prefix="otelcol_") - -# Compare the metrics names and labels -common_metrics = {} -v1_only_metrics = {} -v2_only_metrics = {} - -for name, labels in v1_metrics_with_labels.items(): - if name in v2_metrics_with_labels: - common_metrics[name] = labels - elif not name.startswith("jaeger_agent"): - v1_only_metrics[name] = labels - -for name, labels in v2_metrics_with_labels.items(): - if name not in v1_metrics_with_labels: - v2_only_metrics[name] = labels - -differences = { - "common_metrics": common_metrics, - "v1_only_metrics": v1_only_metrics, - "v2_only_metrics": v2_only_metrics -} - -# Write the differences to a new JSON file -differences_path = "./differences.json" -with open(differences_path, 'w') as file: - json.dump(differences, file, indent=4) - -print(f"Differences written to {differences_path}") diff --git a/scripts/utils/compare_metrics.py b/scripts/utils/compare_metrics.py new file mode 100755 index 00000000000..390f2b7d470 --- /dev/null +++ b/scripts/utils/compare_metrics.py @@ -0,0 +1,130 @@ +# Copyright (c) 2024 The Jaeger Authors. +# SPDX-License-Identifier: Apache-2.0 + +import json +import argparse +import subprocess + +#Instructions of use: + +# To generate V1_Metrics.json and V2_Metrics.json, run the following commands: +# i.e for elastic search first run the following command: +# docker compose -f docker-compose/elasticsearch/v7/docker-compose.yml up +# 1. Generate V1_Metrics.json and V2_Metrics.json by the following commands: +# V1 binary cmd: SPAN_STORAGE_TYPE=elasticsearch go run -tags=ui ./cmd/all-in-one +# extract the metrics by running the following command: +# prom2json http://localhost:14269/metrics > V1_Metrics.json +# Stop the v1 binary and for v2 binary run the following command: +# go run -tags ui ./cmd/jaeger/main.go --config ./cmd/jaeger/config-elasticsearch.yaml +# extract the metrics by running the following command: +# prom2json http://localhost:8888/metrics > V2_Metrics.json +# it is first recomended to generate the differences for all-in-one.json by running the following command: +# python3 compare_metrics.py --out md --is_storage F +# rename that file to all_in_one.json and use it to filter out the overlapping metrics by using the is_storage falg to T +# 2. Run the script with the following command: +# python3 compare_metrics.py --out {json or md} --is_storage {T or F} +# 3. The script will compare the metrics in V1_Metrics.json and V2_Metrics.json and output the differences to differences.json + + +# Extract names and labels of the metrics +def extract_metrics_with_labels(metrics, strip_prefix=None): + result = {} + for metric in metrics: + + name = metric['name'] + print(name) + if strip_prefix and name.startswith(strip_prefix): + name = name[len(strip_prefix):] + labels = {} + if 'metrics' in metric and 'labels' in metric['metrics'][0]: + labels = metric['metrics'][0]['labels'] + result[name] = labels + return result + +def remove_overlapping_metrics(all_in_one_data, other_json_data): + """Remove overlapping metrics found in all_in-one.json from another JSON.""" + # Loop through v1 and v2 metrics to remove overlaps + for metric_category in ['common_metrics', 'v1_only_metrics', 'v2_only_metrics']: + if metric_category in all_in_one_data and metric_category in other_json_data: + for metric in all_in_one_data[metric_category]: + if metric in other_json_data[metric_category]: + del other_json_data[metric_category][metric] + + return other_json_data + + +# Your current compare_metrics.py logic goes here +def main(): + parser = argparse.ArgumentParser(description='Compare metrics and output format.') + parser.add_argument('--out', choices=['json', 'md'], default='json', + help='Output format: json (default) or md') + parser.add_argument('--is_storage', choices=['T','F'],default='F', help='Remove overlapping storage metrics') + # Parse the arguments + args = parser.parse_args() + + # Call your existing compare logic here + print("Running metric comparison...") + v1_metrics_path = "" #Add the path to the V1_Metrics.json file + v2_metrics_path = "" #Add the path to the V2_Metrics.json file + + with open(v1_metrics_path, 'r') as file: + v1_metrics = json.load(file) + + with open(v2_metrics_path, 'r') as file: + v2_metrics = json.load(file) + + v1_metrics_with_labels = extract_metrics_with_labels(v1_metrics) + v2_metrics_with_labels = extract_metrics_with_labels( + v2_metrics, strip_prefix="otelcol_") + + # Compare the metrics names and labels + common_metrics = {} + v1_only_metrics = {} + v2_only_metrics = {} + + for name, labels in v1_metrics_with_labels.items(): + if name in v2_metrics_with_labels: + common_metrics[name] = labels + elif not name.startswith("jaeger_agent"): + v1_only_metrics[name] = labels + + for name, labels in v2_metrics_with_labels.items(): + if name not in v1_metrics_with_labels: + v2_only_metrics[name] = labels + + differences = { + "common_metrics": common_metrics, + "v1_only_metrics": v1_only_metrics, + "v2_only_metrics": v2_only_metrics, + } + + #Write the differences to a new JSON file + differences_path = "./differences.json" + with open(differences_path, 'w') as file: + json.dump(differences, file, indent=4) + + print(f"Differences written to {differences_path}") + if args.is_storage == 'T': + all_in_one_path = "" #Add the path to the all_in_one.json file + with open(all_in_one_path, 'r') as file: + all_in_one_data = json.load(file) + with open(differences_path, 'r') as file: + other_json_data = json.load(file) + other_json_data = remove_overlapping_metrics(all_in_one_data, other_json_data) + with open(differences_path, 'w') as file: + json.dump(other_json_data, file, indent=4) + print(f"Overlapping storage metrics removed from {differences_path}") + # If the user requested markdown output, run metrics_md.py + if args.out == 'md': + try: + print("Running metrics_md.py to generate markdown output...") + subprocess.run(['python3', 'metrics-md.py'], check=True) + except subprocess.CalledProcessError as e: + print(f"Error running metrics_md.py: {e}") + + # If json output is requested or no output type is provided (default is json) + else: + print("Output in JSON format.") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/scripts/utils/metrics-md.py b/scripts/utils/metrics-md.py new file mode 100644 index 00000000000..2b158697257 --- /dev/null +++ b/scripts/utils/metrics-md.py @@ -0,0 +1,117 @@ +# Copyright (c) 2024 The Jaeger Authors. +# SPDX-License-Identifier: Apache-2.0 + +import json + + +def generate_spans_markdown_table(v1_spans, v2_spans): + """ + Generates a markdown table specifically for spans metrics with two main columns V1 and V2. + + Args: + v1_spans (dict): The dictionary of V1 spans metrics. + v2_spans (dict): The dictionary of V2 spans metrics. + + Returns: + str: The generated markdown table as a string. + """ + table = "### Equivalent Metrics\n\n" + table += "| V1 Metric | V1 Parameters | V2 Metric | V2 Parameters |\n" + table += "|-----------|---------------|-----------|---------------|\n" + + + # Iterate through the metrics using zip_longest to handle mismatched lengths + from itertools import zip_longest + + for (v1_metric, v1_params), (v2_metric, v2_params) in zip_longest(v1_spans.items(), v2_spans.items(), fillvalue=('', {})): + v1_inner_keys = ', '.join(v1_params.keys()) if v1_params else '' + v2_inner_keys = ', '.join(v2_params.keys()) if v2_params else '' + table += f"| {v1_metric} | {v1_inner_keys} | {v2_metric} | {v2_inner_keys} |\n" + + return table + + + +def generate_combined_markdown_table(common_metrics, v1_metrics, v2_metrics): + """ + Generates a markdown table for combined metrics from common, V1, and V2. + + Args: + common_metrics (dict): The dictionary of common metrics. + v1_metrics (dict): The dictionary of V1 only metrics. + v2_metrics (dict): The dictionary of V2 only metrics. + + Returns: + str: The generated markdown table as a string. + """ + table = "### Combined Metrics\n\n" + table += "| V1 Metric | V1 Parameters | V2 Metric | V2 Parameters |\n" + table += "|-----------|---------------|-----------|---------------|\n" + for metric_name, params in common_metrics.items(): + v1_params = ', '.join(common_metrics[metric_name].keys()) if params else 'N/A' + v2_params = ', '.join(common_metrics[metric_name].keys()) if params else 'N/A' + table += f"| {metric_name} | {v1_params} | {metric_name} | {v2_params} |\n" + + # Then, handle V1-only metrics (V2 shows as N/A) + for metric_name, v1_params in v1_metrics.items(): + v1_params_str = ', '.join(v1_params.keys()) if v1_params else 'N/A' + table += f"| {metric_name} | {v1_params_str} | N/A | N/A |\n" + + # Then, handle V2-only metrics (V1 shows as N/A) + for metric_name, v2_params in v2_metrics.items(): + v2_params_str = ', '.join(v2_params.keys()) if v2_params else 'N/A' + table += f"| N/A | N/A | {metric_name} | {v2_params_str} |\n" + + return table + +class ConvertJson: + + def __init__(self, json_fp, h1): + self.fp = json_fp + self.h1 = h1 + self.jdata = self.get_json() + self.mddata = self.format_json_to_md() + + def get_json(self): + with open(self.fp) as f: + res = json.load(f) + return res + + def format_json_to_md(self): + text = f'# {self.h1}\n' + dct = self.jdata + + # Extracting individual metric dictionaries + common_metrics = dct.get("common_metrics", {}) + v1_only_metrics = dct.get("v1_only_metrics", {}) + v2_only_metrics = dct.get("v2_only_metrics", {}) + + # Generate combined table + combined_metrics_table = generate_combined_markdown_table( + common_metrics, v1_only_metrics, v2_only_metrics + ) + + filtered_v1_metrics = { + "jaeger_collector_spans_rejected_total": {"debug": "false", "format": "","svc": "","transport":""}, + "jaeger_build_info": {"build_date": "","revision": ""," version": ""} # Add more metrics as needed + } + + # Hardcoding filtered v2 metrics + filtered_v2_metrics = { + "receiver_refused_spans": {"receiver": "","service_instance_id": "","service_name": "","service_version": "","transport": ""}, + "target_info": {"service_instance_id": "","service_name": "","service_version": ""} # Add more metrics as needed + } + spans_metrics_table = generate_spans_markdown_table(filtered_v1_metrics, filtered_v2_metrics) + text += combined_metrics_table+spans_metrics_table + return text + + def convert_dict_to_md(self, output_fn): + with open(output_fn, 'w') as writer: + writer.writelines(self.mddata) + print('Dict successfully converted to md') + +# Usage +fn = '' # Enter the path of the JSON file generated by compare_metrics.py +title = "TITLE" +converter = ConvertJson(fn, title) +converter.convert_dict_to_md(output_fn='metrics.md') \ No newline at end of file