From ff6df24c90b0a86c031acd9f219efdb9dd44da02 Mon Sep 17 00:00:00 2001 From: Roman Dzhabarov Date: Tue, 4 Oct 2016 13:38:02 -0700 Subject: [PATCH 1/2] Stats on number of spans sent to lightstep. --- source/common/tracing/http_tracer_impl.cc | 7 +++++-- source/common/tracing/http_tracer_impl.h | 8 ++++++++ test/common/tracing/http_tracer_impl_test.cc | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/source/common/tracing/http_tracer_impl.cc b/source/common/tracing/http_tracer_impl.cc index c95cd670bfc40..2626753cb4348 100644 --- a/source/common/tracing/http_tracer_impl.cc +++ b/source/common/tracing/http_tracer_impl.cc @@ -123,6 +123,7 @@ void LightStepRecorder::RecordSpan(lightstep::collector::Span&& span) { uint64_t min_flush_spans = sink_.runtime().snapshot().getInteger("tracing.lightstep.min_flush_spans", 5U); if (builder_.pendingSpans() == min_flush_spans) { + sink_.tracerStats().spans_sent_.add(min_flush_spans); lightstep::collector::ReportRequest request; std::swap(request, builder_.pending()); @@ -154,8 +155,10 @@ LightStepSink::LightStepSink(const Json::Object& config, Upstream::ClusterManage ThreadLocal::Instance& tls, Runtime::Loader& runtime, std::unique_ptr options) : collector_cluster_(config.getString("collector_cluster")), cm_(cluster_manager), - stats_store_(stats), service_node_(service_node), tls_(tls), runtime_(runtime), - options_(std::move(options)), tls_slot_(tls.allocateSlot()) { + stats_store_(stats), + tracer_stats_{LIGHTSTEP_TRACER_STATS(POOL_COUNTER_PREFIX(stats, "tracing.lightstep."))}, + service_node_(service_node), tls_(tls), runtime_(runtime), options_(std::move(options)), + tls_slot_(tls.allocateSlot()) { if (!cm_.get(collector_cluster_)) { throw EnvoyException(fmt::format("{} collector cluster is not defined on cluster manager level", collector_cluster_)); diff --git a/source/common/tracing/http_tracer_impl.h b/source/common/tracing/http_tracer_impl.h index 3de1402e01174..b34a0e0cb5bd2 100644 --- a/source/common/tracing/http_tracer_impl.h +++ b/source/common/tracing/http_tracer_impl.h @@ -28,6 +28,12 @@ struct HttpTracerStats { HTTP_TRACER_STATS(GENERATE_COUNTER_STRUCT) }; +#define LIGHTSTEP_TRACER_STATS(COUNTER) COUNTER(spans_sent) + +struct LightstepTracerStats { + LIGHTSTEP_TRACER_STATS(GENERATE_COUNTER_STRUCT) +}; + class HttpNullTracer : public HttpTracer { public: // Tracing::HttpTracer @@ -103,6 +109,7 @@ class LightStepSink : public HttpSink { const std::string& collectorCluster() { return collector_cluster_; } Runtime::Loader& runtime() { return runtime_; } Stats::Store& statsStore() { return stats_store_; } + LightstepTracerStats& tracerStats() { return tracer_stats_; } static const std::string LIGHTSTEP_SERVICE; static const std::string LIGHTSTEP_METHOD; @@ -125,6 +132,7 @@ class LightStepSink : public HttpSink { const std::string collector_cluster_; Upstream::ClusterManager& cm_; Stats::Store& stats_store_; + LightstepTracerStats tracer_stats_; const std::string service_node_; ThreadLocal::Instance& tls_; Runtime::Loader& runtime_; diff --git a/test/common/tracing/http_tracer_impl_test.cc b/test/common/tracing/http_tracer_impl_test.cc index 6652684c55a37..654af1b22202d 100644 --- a/test/common/tracing/http_tracer_impl_test.cc +++ b/test/common/tracing/http_tracer_impl_test.cc @@ -430,6 +430,8 @@ TEST_F(LightStepSinkTest, FlushSeveralSpans) { stats_.counter( "cluster.lightstep_saas.grpc.lightstep.collector.CollectorService.Report.total") .value()); + + EXPECT_EQ(2U, stats_.counter("tracing.lightstep.min_flush_spans").value()); } TEST_F(LightStepSinkTest, FlushOneSpanGrpcFailure) { @@ -486,6 +488,7 @@ TEST_F(LightStepSinkTest, FlushOneSpanGrpcFailure) { stats_.counter( "cluster.lightstep_saas.grpc.lightstep.collector.CollectorService.Report.total") .value()); + EXPECT_EQ(1U, stats_.counter("tracing.lightstep.min_flush_spans").value()); } } // Tracing From bb6fe2c72d88ab1914987650fe287898ae20ec80 Mon Sep 17 00:00:00 2001 From: Roman Dzhabarov Date: Tue, 4 Oct 2016 13:55:37 -0700 Subject: [PATCH 2/2] spans sent. --- test/common/tracing/http_tracer_impl_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/common/tracing/http_tracer_impl_test.cc b/test/common/tracing/http_tracer_impl_test.cc index 654af1b22202d..c7fa378d50ce4 100644 --- a/test/common/tracing/http_tracer_impl_test.cc +++ b/test/common/tracing/http_tracer_impl_test.cc @@ -431,7 +431,7 @@ TEST_F(LightStepSinkTest, FlushSeveralSpans) { "cluster.lightstep_saas.grpc.lightstep.collector.CollectorService.Report.total") .value()); - EXPECT_EQ(2U, stats_.counter("tracing.lightstep.min_flush_spans").value()); + EXPECT_EQ(2U, stats_.counter("tracing.lightstep.spans_sent").value()); } TEST_F(LightStepSinkTest, FlushOneSpanGrpcFailure) { @@ -488,7 +488,7 @@ TEST_F(LightStepSinkTest, FlushOneSpanGrpcFailure) { stats_.counter( "cluster.lightstep_saas.grpc.lightstep.collector.CollectorService.Report.total") .value()); - EXPECT_EQ(1U, stats_.counter("tracing.lightstep.min_flush_spans").value()); + EXPECT_EQ(1U, stats_.counter("tracing.lightstep.spans_sent").value()); } } // Tracing