Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions source/common/tracing/http_tracer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -154,8 +155,10 @@ LightStepSink::LightStepSink(const Json::Object& config, Upstream::ClusterManage
ThreadLocal::Instance& tls, Runtime::Loader& runtime,
std::unique_ptr<lightstep::TracerOptions> 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_));
Expand Down
8 changes: 8 additions & 0 deletions source/common/tracing/http_tracer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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_;
Expand Down
3 changes: 3 additions & 0 deletions test/common/tracing/http_tracer_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.spans_sent").value());
}

TEST_F(LightStepSinkTest, FlushOneSpanGrpcFailure) {
Expand Down Expand Up @@ -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.spans_sent").value());
}

} // Tracing