-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathrequest_handler.h
More file actions
55 lines (46 loc) · 2.22 KB
/
Copy pathrequest_handler.h
File metadata and controls
55 lines (46 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#include <datadog/optional.h>
#include <datadog/span_config.h>
#include <datadog/tracer.h>
#include <datadog/tracer_config.h>
#include <datadog/json.hpp>
#include "developer_noise.h"
#include "httplib.h"
#include "manual_scheduler.h"
class RequestHandler final {
public:
RequestHandler(datadog::tracing::FinalizedTracerConfig& tracerConfig,
std::shared_ptr<ManualScheduler> scheduler,
std::shared_ptr<DeveloperNoiseLogger> logger);
void set_error(const char* const file, int line, const std::string& reason,
httplib::Response& res);
void on_trace_config(const httplib::Request& req, httplib::Response& res);
void on_span_start(const httplib::Request& req, httplib::Response& res);
void on_span_end(const httplib::Request& req, httplib::Response& res);
void on_set_meta(const httplib::Request& req, httplib::Response& res);
void on_set_metric(const httplib::Request& /* req */, httplib::Response& res);
void on_inject_headers(const httplib::Request& req, httplib::Response& res);
void on_extract_headers(const httplib::Request& req, httplib::Response& res);
void on_span_flush(const httplib::Request& /* req */, httplib::Response& res);
void on_stats_flush(const httplib::Request& /* req */,
httplib::Response& res);
void on_span_error(const httplib::Request& req, httplib::Response& res);
private:
datadog::tracing::Tracer tracer_;
std::shared_ptr<ManualScheduler> scheduler_;
std::shared_ptr<DeveloperNoiseLogger> logger_;
std::unordered_map<uint64_t, datadog::tracing::Span> active_spans_;
std::unordered_map<uint64_t, nlohmann::json::array_t> tracing_context_;
// Previously, `/trace/span/start` was used to create new spans or create
// child spans from the extracted tracing context.
//
// The logic has been split into two distinct endpoint, with the addition of
// `extract_headers`. However, the public API does not expose a method to just
// extract tracing context.
//
// For now, the workaround is to extract and create a span from tracing
// context and keep the span alive until the process terminate, thus
// explaining the name :)
std::vector<datadog::tracing::Span> blackhole_;
#undef VALIDATION_ERROR
};