diff --git a/cmd/agent/app/reporter/client_metrics_test.go b/cmd/agent/app/reporter/client_metrics_test.go index 8d1651b0207..345cc386773 100644 --- a/cmd/agent/app/reporter/client_metrics_test.go +++ b/cmd/agent/app/reporter/client_metrics_test.go @@ -256,15 +256,16 @@ func TestClientMetricsReporter_Expire(t *testing.T) { t.Run(fmt.Sprintf("iter%d:gauge=%d,log=%s", i, test.expGauge, test.expLog), func(t *testing.T) { // Expire loop runs every 100us, and removes the client after 5ms. // We check for condition in each test for up to 5ms (10*500us). + var gaugeValue int64 = -1 for i := 0; i < 10; i++ { _, gauges := tr.mb.Snapshot() - if gauges["client_stats.connected_clients"] == int64(test.expGauge) { + gaugeValue = gauges["client_stats.connected_clients"] + if gaugeValue == int64(test.expGauge) { break } time.Sleep(500 * time.Microsecond) } - tr.mb.AssertGaugeMetrics(t, - metricstest.ExpectedMetric{Name: "client_stats.connected_clients", Value: test.expGauge}) + assert.EqualValues(t, test.expGauge, gaugeValue) tr.assertLog(t, test.expLog, clientUUID) // sleep between tests long enough to exceed the 5ms TTL. diff --git a/plugin/storage/cassandra/schema/docker.sh b/plugin/storage/cassandra/schema/docker.sh index 4a55902c330..d0265e8f93d 100755 --- a/plugin/storage/cassandra/schema/docker.sh +++ b/plugin/storage/cassandra/schema/docker.sh @@ -3,7 +3,7 @@ # This script is used in the Docker image jaegertracing/jaeger-cassandra-schema # that allows installing Jaeger keyspace and schema without installing cqlsh. -CQLSH=${CQLSH:-"/usr/bin/cqlsh"} +CQLSH=${CQLSH:-"/opt/cassandra/bin/cqlsh"} CQLSH_HOST=${CQLSH_HOST:-"cassandra"} CQLSH_SSL=${CQLSH_SSL:-""} CASSANDRA_WAIT_TIMEOUT=${CASSANDRA_WAIT_TIMEOUT:-"60"} diff --git a/plugin/storage/cassandra/spanstore/writer.go b/plugin/storage/cassandra/spanstore/writer.go index ecb16388a0c..2ffc278c6f5 100644 --- a/plugin/storage/cassandra/spanstore/writer.go +++ b/plugin/storage/cassandra/spanstore/writer.go @@ -141,7 +141,7 @@ func (s *SpanWriter) WriteSpan(span *model.Span) error { return err } } - if s.storageMode&indexFlag == indexFlag && !span.Flags.IsFirehoseEnabled() { + if s.storageMode&indexFlag == indexFlag { if err := s.writeIndexes(span, ds); err != nil { return err } @@ -182,6 +182,10 @@ func (s *SpanWriter) writeIndexes(span *model.Span, ds *dbmodel.Span) error { return s.logError(ds, err, "Failed to insert service name and operation name", s.logger) } + if span.Flags.IsFirehoseEnabled() { + return nil // skipping expensive indexing + } + if err := s.indexByTags(span, ds); err != nil { return s.logError(ds, err, "Failed to index tags", s.logger) } diff --git a/plugin/storage/cassandra/spanstore/writer_test.go b/plugin/storage/cassandra/spanstore/writer_test.go index 5966b7d9427..36e9d6b288e 100644 --- a/plugin/storage/cassandra/spanstore/writer_test.go +++ b/plugin/storage/cassandra/spanstore/writer_test.go @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/uber/jaeger-lib/metrics/metricstest" + "go.uber.org/atomic" "go.uber.org/zap" "github.com/jaegertracing/jaeger/model" @@ -352,13 +353,21 @@ func TestStorageMode_IndexOnly_WithFilter(t *testing.T) { func TestStorageMode_IndexOnly_FirehoseSpan(t *testing.T) { withSpanWriter(0, func(w *spanWriterTest) { - - w.writer.serviceNamesWriter = func(serviceName string) error { return nil } - w.writer.operationNamesWriter = func(operation dbmodel.Operation) error { return nil } + serviceWritten := atomic.NewString("") + operationWritten := &atomic.Value{} + w.writer.serviceNamesWriter = func(serviceName string) error { + serviceWritten.Store(serviceName) + return nil + } + w.writer.operationNamesWriter = func(operation dbmodel.Operation) error { + operationWritten.Store(operation) + return nil + } span := &model.Span{ - TraceID: model.NewTraceID(0, 1), + TraceID: model.NewTraceID(0, 1), + OperationName: "package-delivery", Process: &model.Process{ - ServiceName: "service-a", + ServiceName: "planet-express", }, Flags: model.Flags(8), } @@ -366,9 +375,14 @@ func TestStorageMode_IndexOnly_FirehoseSpan(t *testing.T) { err := w.writer.WriteSpan(span) assert.NoError(t, err) w.session.AssertExpectations(t) - w.session.AssertNotCalled(t, "Query", stringMatcher(serviceOperationIndex)) w.session.AssertNotCalled(t, "Query", stringMatcher(serviceNameIndex)) w.session.AssertNotCalled(t, "Query", stringMatcher(durationIndex)) + assert.Equal(t, "planet-express", serviceWritten.Load()) + assert.Equal(t, dbmodel.Operation{ + ServiceName: "planet-express", + SpanKind: "", + OperationName: "package-delivery", + }, operationWritten.Load()) }, StoreIndexesOnly()) } diff --git a/scripts/travis/cassandra-integration-test.sh b/scripts/travis/cassandra-integration-test.sh index 2cfbe55e69e..4f516bf8cfc 100755 --- a/scripts/travis/cassandra-integration-test.sh +++ b/scripts/travis/cassandra-integration-test.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -ex # Clean up before starting. docker rm -f cassandra || true