Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not skip service/operation indexing for firehose spans + a couple fixes #2090

Merged
merged 6 commits into from Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions cmd/agent/app/reporter/client_metrics_test.go
Expand Up @@ -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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change to fix a flaky test. There was a race condition with gauge value being 1 inside the loop and then dropping back to 0 by the time the AssertGaugeMetrics was called.

tr.assertLog(t, test.expLog, clientUUID)

// sleep between tests long enough to exceed the 5ms TTL.
Expand Down
2 changes: 1 addition & 1 deletion plugin/storage/cassandra/schema/docker.sh
Expand Up @@ -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"}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change to fix regression in Cassandra tests that were breaking CI.

CQLSH_HOST=${CQLSH_HOST:-"cassandra"}
CQLSH_SSL=${CQLSH_SSL:-""}
CASSANDRA_WAIT_TIMEOUT=${CASSANDRA_WAIT_TIMEOUT:-"60"}
Expand Down
6 changes: 5 additions & 1 deletion plugin/storage/cassandra/spanstore/writer.go
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}
Expand Down
26 changes: 20 additions & 6 deletions plugin/storage/cassandra/spanstore/writer_test.go
Expand Up @@ -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"
Expand Down Expand Up @@ -352,23 +353,36 @@ 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),
}

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())
Comment on lines +380 to +385
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these not tested elsewhere? For e.g., if plugin/storage/cassandra/spanstore/writer.go L183 were removed - wouldn't other tests fail?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not testing whether index writing works, but whether it's invoked for firehose span. This is the only test that makes distinction between two types of indices.

}, StoreIndexesOnly())
}

Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down