From 88af82e8d13fc3f88a3c76d6ec96e646b47fb264 Mon Sep 17 00:00:00 2001 From: Saransh Shankar <103821431+Wise-Wizard@users.noreply.github.com> Date: Sat, 6 Apr 2024 09:38:12 +0530 Subject: [PATCH 1/2] Intialized ES factory (#5313) **Which problem is this PR solving?** This PR addresses a new found issue which is a part of the issue [#5203 ](https://github.com/jaegertracing/jaeger/issues/5203). It initializes ES Factory in the Integration Test Suite. Description: This PR introduces changes to the integration tests by initializing an ElasticSearch factory (es.Factory) and utilizing it for the creation of span readers and writers. Previously, the code instantiated a new span reader/writer from the SpanStore directly, which has been replaced with the more appropriate approach of leveraging the ElasticSearch factory. **How was this change tested?** The changes were tested by running the following command: ```bash make test ``` **Checklist** - [x] I have read [CONTRIBUTING_GUIDELINES.md](https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md) - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - `for jaeger: make lint test` - `for jaeger-ui: yarn lint` and `yarn test` --------- Signed-off-by: Wise-Wizard Signed-off-by: Yuri Shkuro Co-authored-by: Yuri Shkuro --- .../storage/integration/elasticsearch_test.go | 137 ++++++------------ plugin/storage/integration/integration.go | 20 ++- 2 files changed, 56 insertions(+), 101 deletions(-) diff --git a/plugin/storage/integration/elasticsearch_test.go b/plugin/storage/integration/elasticsearch_test.go index e386f802be9..aa97184485f 100644 --- a/plugin/storage/integration/elasticsearch_test.go +++ b/plugin/storage/integration/elasticsearch_test.go @@ -18,6 +18,7 @@ package integration import ( "context" "errors" + "fmt" "net/http" "strconv" "strings" @@ -28,19 +29,18 @@ import ( "github.com/olivere/elastic" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - sdktrace "go.opentelemetry.io/otel/sdk/trace" - "go.opentelemetry.io/otel/sdk/trace/tracetest" - "go.opentelemetry.io/otel/trace" "go.uber.org/zap" + "go.uber.org/zap/zaptest" + "github.com/jaegertracing/jaeger/pkg/config" estemplate "github.com/jaegertracing/jaeger/pkg/es" eswrapper "github.com/jaegertracing/jaeger/pkg/es/wrapper" "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/pkg/testutils" - "github.com/jaegertracing/jaeger/plugin/storage/es/dependencystore" + "github.com/jaegertracing/jaeger/plugin/storage/es" "github.com/jaegertracing/jaeger/plugin/storage/es/mappings" "github.com/jaegertracing/jaeger/plugin/storage/es/samplingstore" - "github.com/jaegertracing/jaeger/plugin/storage/es/spanstore" + "github.com/jaegertracing/jaeger/storage/dependencystore" ) const ( @@ -56,6 +56,8 @@ const ( spanTemplateName = "jaeger-span" serviceTemplateName = "jaeger-service" dependenciesTemplateName = "jaeger-dependencies" + primaryNamespace = "es" + archiveNamespace = "es-archive" ) type ESStorageIntegration struct { @@ -67,20 +69,6 @@ type ESStorageIntegration struct { logger *zap.Logger } -func (s *ESStorageIntegration) tracerProvider() (trace.TracerProvider, *tracetest.InMemoryExporter, func()) { - exporter := tracetest.NewInMemoryExporter() - tp := sdktrace.NewTracerProvider( - sdktrace.WithSampler(sdktrace.AlwaysSample()), - sdktrace.WithSyncer(exporter), - ) - closer := func() { - if err := tp.Shutdown(context.Background()); err != nil { - s.logger.Error("failed to close tracer", zap.Error(err)) - } - } - return tp, exporter, closer -} - func (s *ESStorageIntegration) getVersion() (uint, error) { pingResult, _, err := s.client.Ping(queryURL).Do(context.Background()) if err != nil { @@ -99,7 +87,7 @@ func (s *ESStorageIntegration) getVersion() (uint, error) { return uint(esVersion), nil } -func (s *ESStorageIntegration) initializeES(t *testing.T, allTagsAsFields bool) error { +func (s *ESStorageIntegration) initializeES(t *testing.T, allTagsAsFields bool) { rawClient, err := elastic.NewClient( elastic.SetURL(queryURL), elastic.SetSniff(false)) @@ -124,7 +112,6 @@ func (s *ESStorageIntegration) initializeES(t *testing.T, allTagsAsFields bool) // TODO: remove this flag after ES support returning spanKind when get operations s.GetOperationsMissingSpanKind = true s.SkipArchiveTest = false - return nil } func (s *ESStorageIntegration) esCleanUp(t *testing.T, allTagsAsFields bool) { @@ -168,86 +155,44 @@ func (s *ESStorageIntegration) getEsClient(t *testing.T) eswrapper.ClientWrapper return eswrapper.WrapESClient(s.client, bp, esVersion, s.v8Client) } -func (s *ESStorageIntegration) initSpanstore(t *testing.T, allTagsAsFields bool) error { - client := s.getEsClient(t) - mappingBuilder := mappings.MappingBuilder{ - TemplateBuilder: estemplate.TextTemplateBuilder{}, - Shards: 5, - Replicas: 1, - EsVersion: client.GetVersion(), - IndexPrefix: indexPrefix, - UseILM: false, +func (s *ESStorageIntegration) initializeESFactory(t *testing.T, allTagsAsFields bool) *es.Factory { + s.logger = zaptest.NewLogger(t) + f := es.NewFactory() + v, command := config.Viperize(f.AddFlags) + args := []string{ + fmt.Sprintf("--es.tags-as-fields.all=%v", allTagsAsFields), + fmt.Sprintf("--es.index-prefix=%v", indexPrefix), + "--es-archive.enabled=true", + fmt.Sprintf("--es-archive.tags-as-fields.all=%v", allTagsAsFields), + fmt.Sprintf("--es-archive.index-prefix=%v", indexPrefix), } - spanMapping, serviceMapping, err := mappingBuilder.GetSpanServiceMappings() - require.NoError(t, err) - clientFn := func() estemplate.Client { return client } + require.NoError(t, command.ParseFlags(args)) + f.InitFromViper(v, s.logger) + require.NoError(t, f.Initialize(metrics.NullFactory, s.logger)) - // Initializing Span Reader and Writer - w := spanstore.NewSpanWriter( - spanstore.SpanWriterParams{ - Client: clientFn, - Logger: s.logger, - MetricsFactory: metrics.NullFactory, - IndexPrefix: indexPrefix, - AllTagsAsFields: allTagsAsFields, - TagDotReplacement: tagKeyDeDotChar, - Archive: false, - }) - err = w.CreateTemplates(spanMapping, serviceMapping, indexPrefix) - require.NoError(t, err) - tracer, _, closer := s.tracerProvider() - defer closer() - s.SpanWriter = w - s.SpanReader = spanstore.NewSpanReader(spanstore.SpanReaderParams{ - Client: clientFn, - Logger: s.logger, - MetricsFactory: metrics.NullFactory, - IndexPrefix: indexPrefix, - MaxSpanAge: maxSpanAge, - TagDotReplacement: tagKeyDeDotChar, - MaxDocCount: defaultMaxDocCount, - Tracer: tracer.Tracer("test"), - Archive: false, - }) - - // Initializing Archive Span Reader and Writer - s.ArchiveSpanWriter = spanstore.NewSpanWriter( - spanstore.SpanWriterParams{ - Client: clientFn, - Logger: s.logger, - MetricsFactory: metrics.NullFactory, - IndexPrefix: indexPrefix, - AllTagsAsFields: allTagsAsFields, - TagDotReplacement: tagKeyDeDotChar, - Archive: true, - }) - s.ArchiveSpanReader = spanstore.NewSpanReader(spanstore.SpanReaderParams{ - Client: clientFn, - Logger: s.logger, - MetricsFactory: metrics.NullFactory, - IndexPrefix: indexPrefix, - MaxSpanAge: maxSpanAge, - TagDotReplacement: tagKeyDeDotChar, - MaxDocCount: defaultMaxDocCount, - Tracer: tracer.Tracer("test"), - Archive: true, - }) - - dependencyStore := dependencystore.NewDependencyStore(dependencystore.DependencyStoreParams{ - Client: clientFn, - Logger: s.logger, - IndexPrefix: indexPrefix, - IndexDateLayout: indexDateLayout, - MaxDocCount: defaultMaxDocCount, - }) + // TODO ideally we need to close the factory once the test is finished + // but because esCleanup calls initialize() we get a panic later + // t.Cleanup(func() { + // require.NoError(t, f.Close()) + // }) + return f +} - depMapping, err := mappingBuilder.GetDependenciesMappings() +func (s *ESStorageIntegration) initSpanstore(t *testing.T, allTagsAsFields bool) { + f := s.initializeESFactory(t, allTagsAsFields) + var err error + s.SpanWriter, err = f.CreateSpanWriter() require.NoError(t, err) - err = dependencyStore.CreateTemplates(depMapping) + s.SpanReader, err = f.CreateSpanReader() require.NoError(t, err) - s.DependencyReader = dependencyStore - s.DependencyWriter = dependencyStore - return nil + s.ArchiveSpanReader, err = f.CreateArchiveSpanReader() + require.NoError(t, err) + s.ArchiveSpanWriter, err = f.CreateArchiveSpanWriter() + require.NoError(t, err) + + s.DependencyReader, err = f.CreateDependencyReader() + require.NoError(t, err) + s.DependencyWriter = s.DependencyReader.(dependencystore.Writer) } func (s *ESStorageIntegration) esRefresh(t *testing.T) { diff --git a/plugin/storage/integration/integration.go b/plugin/storage/integration/integration.go index 506900e8ee3..d6edc3a8abf 100644 --- a/plugin/storage/integration/integration.go +++ b/plugin/storage/integration/integration.go @@ -460,12 +460,22 @@ func (s *StorageIntegration) testGetDependencies(t *testing.T) { require.NoError(t, s.DependencyWriter.WriteDependencies(time.Now(), expected)) s.refresh(t) - actual, err := s.DependencyReader.GetDependencies(context.Background(), time.Now(), 5*time.Minute) - require.NoError(t, err) - sort.Slice(actual, func(i, j int) bool { - return actual[i].Parent < actual[j].Parent + + var actual []model.DependencyLink + found := s.waitForCondition(t, func(t *testing.T) bool { + var err error + actual, err = s.DependencyReader.GetDependencies(context.Background(), time.Now(), 5*time.Minute) + require.NoError(t, err) + sort.Slice(actual, func(i, j int) bool { + return actual[i].Parent < actual[j].Parent + }) + return assert.ObjectsAreEqualValues(expected, actual) }) - assert.EqualValues(t, expected, actual) + + if !assert.True(t, found) { + t.Log("\t Expected:", expected) + t.Log("\t Actual :", actual) + } } // === Sampling Store Integration Tests === From 8a4748c8b5a8a4e38e54c4b0c6922ef459e12430 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 6 Apr 2024 00:08:43 -0400 Subject: [PATCH 2/2] build(deps): bump github.com/prometheus/client_model from 0.6.0 to 0.6.1 (#5324) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [github.com/prometheus/client_model](https://github.com/prometheus/client_model) from 0.6.0 to 0.6.1.
Release notes

Sourced from github.com/prometheus/client_model's releases.

v0.6.1

What's Changed

Full Changelog: https://github.com/prometheus/client_model/compare/v0.6.0...v0.6.1

Commits
  • 571429e Merge pull request #86 from prometheus/repo_sync
  • cc727ab Update common Prometheus files
  • 6fe5007 Merge pull request #85 from prometheus/repo_sync
  • bce87c1 Update common Prometheus files
  • 64c33c9 Merge pull request #84 from prometheus/dependabot/go_modules/google.golang.or...
  • d954a8a Bump google.golang.org/protobuf from 1.32.0 to 1.33.0
  • 5c25993 Merge pull request #82 from prometheus/repo_sync
  • bb45f95 Update common Prometheus files
  • 01ca24c Merge pull request #81 from prometheus/repo_sync
  • ccd6823 Update common Prometheus files
  • See full diff in compare view

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/prometheus/client_model&package-manager=go_modules&previous-version=0.6.0&new-version=0.6.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a8435de45db..8f10820bd88 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.97.0 github.com/open-telemetry/opentelemetry-collector-contrib/testbed v0.97.0 github.com/prometheus/client_golang v1.19.0 - github.com/prometheus/client_model v0.6.0 + github.com/prometheus/client_model v0.6.1 github.com/prometheus/common v0.52.2 github.com/soheilhy/cmux v0.1.5 github.com/spf13/cobra v1.8.0 diff --git a/go.sum b/go.sum index 8362b3740c2..76bd1decb9b 100644 --- a/go.sum +++ b/go.sum @@ -390,8 +390,8 @@ github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= -github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.52.2 h1:LW8Vk7BccEdONfrJBDffQGRtpSzi5CQaRZGtboOO2ck= github.com/prometheus/common v0.52.2/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=