From fe7352d4b7d170fc811b20d3acb274dff062aebf Mon Sep 17 00:00:00 2001 From: Prithvi Raj Date: Tue, 1 Jan 2019 14:22:34 -0500 Subject: [PATCH] Log cql query on error (#1250) Signed-off-by: Prithvi Raj --- plugin/storage/cassandra/spanstore/reader.go | 3 ++- plugin/storage/cassandra/spanstore/reader_test.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/storage/cassandra/spanstore/reader.go b/plugin/storage/cassandra/spanstore/reader.go index 6a6ad7ede72..f232edb7e1b 100644 --- a/plugin/storage/cassandra/spanstore/reader.go +++ b/plugin/storage/cassandra/spanstore/reader.go @@ -410,7 +410,8 @@ func (s *SpanReader) executeQuery(span opentracing.Span, query cassandra.Query, tableMetrics.Emit(err, time.Since(start)) if err != nil { logErrorToSpan(span, err) - s.logger.Error("Failed to exec query", zap.Error(err)) + span.LogFields(otlog.String("query", query.String())) + s.logger.Error("Failed to exec query", zap.Error(err), zap.String("query", query.String())) return nil, err } return retMe, nil diff --git a/plugin/storage/cassandra/spanstore/reader_test.go b/plugin/storage/cassandra/spanstore/reader_test.go index 8499aa6800a..b59ad520b85 100644 --- a/plugin/storage/cassandra/spanstore/reader_test.go +++ b/plugin/storage/cassandra/spanstore/reader_test.go @@ -305,6 +305,7 @@ func TestSpanReaderFindTraces(t *testing.T) { query.On("Consistency", cassandra.One).Return(query) query.On("PageSize", 0).Return(query) query.On("Iter").Return(iter) + query.On("String").Return("queryString") return query }