Merge branch 'pratik/otel-phase6-statsd' into pratik/otel-phase7-native-metrics

This commit is contained in:
Pratik Mankawde
2026-09-09 12:02:22 +01:00
4 changed files with 14 additions and 4 deletions

View File

@@ -36,7 +36,6 @@
#endif
#include <memory>
#include <string>
#include <utility>
namespace xrpl::telemetry {

View File

@@ -185,7 +185,7 @@ requireReadableFile(std::string const& path, char const* configKey)
{
reason = "not a regular file";
}
else if (std::ifstream stream{path, std::ios::in}; !stream)
else if (std::ifstream const stream{path, std::ios::in}; !stream)
{
reason = std::error_code{errno, std::generic_category()}.message();
}

View File

@@ -1,7 +1,5 @@
#include <xrpl/beast/insight/StatsDCollector.h>
#include <xrpl/beast/insight/Counter.h>
#include <xrpl/beast/insight/Gauge.h>
#include <xrpl/beast/net/IPEndpoint.h>
#include <xrpl/beast/utility/Journal.h>
@@ -39,6 +37,7 @@ namespace beast::insight {
* "test",
* Journal(Journal::getNullSink()));
* auto const gauge = collector->makeGauge("g");
* collector->onCollectionReady(); // Nothing is polled before this.
* EXPECT_EQ(server.receive(std::chrono::seconds(10)), "test.g:0|g\n");
*
* // Edge case: nothing was sent, so the wait runs out and returns empty.
@@ -128,6 +127,10 @@ TEST(StatsDCollector, UntouchedGaugePublishesInitialZero)
// Created and then left alone: no set(), no increment().
auto const gauge = collector->makeGauge("untouched");
// A collector polls its metrics only after this. Without the call no tick
// ever flushes and every assertion below would hold for the wrong reason.
collector->onCollectionReady();
EXPECT_EQ(server.receive(std::chrono::seconds(10)), std::string("test.untouched:0|g\n"));
}
@@ -146,6 +149,10 @@ TEST(StatsDCollector, UntouchedCounterPublishesNothing)
auto collector = StatsDCollector::make(address, "test", Journal(Journal::getNullSink()));
auto const counter = collector->makeCounter("untouched");
// Same reason as above: polling must be on, or the empty result proves only
// that nothing was polled.
collector->onCollectionReady();
// Three seconds spans several one-second flush ticks.
EXPECT_EQ(server.receive(std::chrono::seconds(3)), std::string());
}

View File

@@ -807,9 +807,13 @@ TxQ::apply(
{
span.setAttribute(txq_span::attr::terCode, transToken(directApplied->ter).c_str());
if (directApplied->applied)
{
span.setAttribute(txq_span::attr::txqStatus, txq_span::val::appliedDirect);
}
else
{
span.setAttribute(txq_span::attr::txqStatus, txq_span::val::failed);
}
}
return *directApplied;
}