-
Notifications
You must be signed in to change notification settings - Fork 16
Implement stable session identifier headers for telemetry #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e40dd5d
3fab2f5
d805351
1f8a254
468dd13
f124ca3
c106643
25fb7ea
d323be4
3d9252b
b3c0f73
b673a7e
0b7fd49
64223a6
2453d16
d3c3b39
a571544
d47c926
b8a48ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,14 @@ HTTPClient::URL make_telemetry_endpoint(HTTPClient::URL url) { | |
| return url; | ||
| } | ||
|
|
||
| void set_session_headers(DictWriter& headers, | ||
| const tracing::TracerSignature& sig) { | ||
| headers.set("DD-Session-ID", sig.runtime_id.string()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit, opt: store |
||
| if (sig.root_session_id != sig.runtime_id.string()) { | ||
| headers.set("DD-Root-Session-ID", sig.root_session_id); | ||
| } | ||
| } | ||
|
|
||
| void cancel_tasks(std::vector<tracing::EventScheduler::Cancel>& tasks) { | ||
| for (auto& cancel_task : tasks) { | ||
| cancel_task(); | ||
|
|
@@ -309,13 +317,15 @@ void Telemetry::app_started() { | |
| auto payload = app_started_payload(); | ||
|
|
||
| auto on_headers = [payload_size = payload.size(), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code lines 312-356 is very similar to the one lines 368-409. |
||
| debug_enabled = config_.debug](DictWriter& headers) { | ||
| debug_enabled = config_.debug, | ||
| &sig = tracer_signature_](DictWriter& headers) { | ||
| headers.set("Content-Type", "application/json"); | ||
| headers.set("Content-Length", std::to_string(payload_size)); | ||
| headers.set("DD-Telemetry-API-Version", "v2"); | ||
| headers.set("DD-Client-Library-Language", "cpp"); | ||
| headers.set("DD-Client-Library-Version", tracer_version); | ||
| headers.set("DD-Telemetry-Request-Type", "app-started"); | ||
| set_session_headers(headers, sig); | ||
| if (debug_enabled) { | ||
| headers.set("DD-Telemetry-Debug-Enabled", "true"); | ||
| } | ||
|
|
@@ -363,14 +373,15 @@ void Telemetry::app_closing() { | |
|
|
||
| void Telemetry::send_payload(StringView request_type, std::string payload) { | ||
| auto set_telemetry_headers = [request_type, payload_size = payload.size(), | ||
| debug_enabled = | ||
| config_.debug](DictWriter& headers) { | ||
| debug_enabled = config_.debug, | ||
| &sig = tracer_signature_](DictWriter& headers) { | ||
| headers.set("Content-Type", "application/json"); | ||
| headers.set("Content-Length", std::to_string(payload_size)); | ||
| headers.set("DD-Telemetry-API-Version", "v2"); | ||
| headers.set("DD-Client-Library-Language", "cpp"); | ||
| headers.set("DD-Client-Library-Version", tracer_version); | ||
| headers.set("DD-Telemetry-Request-Type", request_type); | ||
| set_session_headers(headers, sig); | ||
| if (debug_enabled) { | ||
| headers.set("DD-Telemetry-Debug-Enabled", "true"); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.