Line data Source code
1 : #pragma once 2 : 3 : #include <memory> 4 : 5 : #include "envoy/extensions/filters/network/wasm/v3/wasm.pb.validate.h" 6 : #include "envoy/stats/sink.h" 7 : 8 : #include "source/extensions/common/wasm/wasm.h" 9 : 10 : namespace Envoy { 11 : namespace Extensions { 12 : namespace StatSinks { 13 : namespace Wasm { 14 : 15 : using Envoy::Extensions::Common::Wasm::PluginHandleSharedPtr; 16 : using Envoy::Extensions::Common::Wasm::PluginSharedPtr; 17 : 18 : class WasmStatSink : public Stats::Sink { 19 : public: 20 : WasmStatSink(const PluginSharedPtr& plugin, PluginHandleSharedPtr singleton) 21 0 : : plugin_(plugin), singleton_(singleton) {} 22 : 23 0 : void flush(Stats::MetricSnapshot& snapshot) override { 24 0 : singleton_->wasmHandle()->wasm()->onStatsUpdate(plugin_, snapshot); 25 0 : } 26 : 27 0 : void setSingleton(PluginHandleSharedPtr singleton) { 28 0 : ASSERT(singleton != nullptr); 29 0 : singleton_ = singleton; 30 0 : } 31 : 32 0 : void onHistogramComplete(const Stats::Histogram& histogram, uint64_t value) override { 33 0 : (void)histogram; 34 0 : (void)value; 35 0 : } 36 : 37 : private: 38 : PluginSharedPtr plugin_; 39 : PluginHandleSharedPtr singleton_; 40 : }; 41 : 42 : } // namespace Wasm 43 : } // namespace StatSinks 44 : } // namespace Extensions 45 : } // namespace Envoy