1#ifndef NANOMMO_SERVER_TRACING_H_
2#define NANOMMO_SERVER_TRACING_H_
11#include "absl/status/status.h"
12#include "absl/status/statusor.h"
13#include "absl/time/clock.h"
14#include "absl/time/time.h"
15#include "prometheus/registry.h"
63 explicit Span(std::unique_ptr<Data> data);
75 void SetAttribute(std::string_view key, std::string_view value);
78 void SetError(std::string_view message);
88 std::unique_ptr<Data> data_;
93using SendSpans = std::function<absl::Status(
const std::string& json)>;
109 prometheus::Registry* registry =
nullptr);
123 absl::Time start = absl::Now());
Span()
A span that records nothing.
void SetAttribute(std::string_view key, std::string_view value)
Span(const Span &)=delete
void SetError(std::string_view message)
Marks it as failed, and why.
void AddLink(const SpanContext &other)
SpanContext context() const
No trace and no span when it isn't recording.
Span & operator=(const Span &)=delete
Span(Span &&other) noexcept
The span it was, which the other doesn't record any more.
std::string Traceparent(const SpanContext &context)
Span StartSpan(std::string_view name, SpanKind kind)
std::function< absl::Status(const std::string &json)> SendSpans
Sends a batch of spans, written as OTLP's JSON, and says whether it went.
SendSpans PostTo(const std::string &endpoint)
void StartTracing(std::string service, SendSpans send, prometheus::Registry *registry)
absl::StatusOr< SpanContext > ParseTraceparent(std::string_view traceparent)
Span StartChildSpan(std::string_view name, SpanKind kind)
constexpr std::size_t kMostWaitingSpans
bool operator==(const SpanContext &) const =default
std::string trace_id() const
The trace's id, as 32 hex digits, as Tempo shows it.