feat(Observability): add zero-dep hooks, HookLease, ContextSnapshot, bounded metrics/tracing, and snapshot exporter (S-OBSERVABILITY-01..04)
This commit is contained in:
1 parent
809b6f548d
commit
fe99051ded
16 files changed
+3545
No files matched your search
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidObservabilityOnlyConsumer LANGUAGES CXX)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS Observability)
|
||||
|
||||
add_executable(void_observability_only_consumer main.cpp)
|
||||
target_link_libraries(void_observability_only_consumer PRIVATE Void::Observability)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME VoidObservabilityOnlyConsumer COMMAND void_observability_only_consumer)
|
||||
@@ -0,0 +1,29 @@
|
||||
#include <Void/Observability/Observability.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
int main()
|
||||
{
|
||||
auto reg = Void::Observability::MetricRegistry::create();
|
||||
if (!reg) {
|
||||
return 1;
|
||||
}
|
||||
auto ctr = reg->register_instrument(Void::Observability::InstrumentSpec{
|
||||
.name = "consumer_ops",
|
||||
.unit = "1",
|
||||
.kind = Void::Observability::MetricKind::counter});
|
||||
if (!ctr || !reg->add_counter(*ctr, 1)) {
|
||||
return 2;
|
||||
}
|
||||
auto exp = std::make_shared<Void::Observability::TextSnapshotExporter>();
|
||||
auto tr = Void::Observability::Tracer::create({}, exp);
|
||||
if (!tr) {
|
||||
return 3;
|
||||
}
|
||||
auto sp = tr->start_span(
|
||||
Void::Observability::ContextSnapshot{},
|
||||
Void::Observability::SpanSpec{.name = "root"});
|
||||
sp.end();
|
||||
const auto rep = tr->close();
|
||||
return rep.failed_spans == 0 ? 0 : 4;
|
||||
}
|
||||
Reference in new issue
Block a user