|
13 | 13 |
|
14 | 14 | #include <algorithm> |
15 | 15 | #include <cassert> |
| 16 | +#include <filesystem> |
16 | 17 |
|
17 | 18 | #include "config_manager.h" |
18 | 19 | #include "datadog_agent.h" |
|
30 | 31 | #include "trace_sampler.h" |
31 | 32 | #include "w3c_propagation.h" |
32 | 33 |
|
| 34 | +namespace fs = std::filesystem; |
| 35 | + |
33 | 36 | namespace datadog { |
34 | 37 | namespace tracing { |
35 | 38 |
|
@@ -99,7 +102,17 @@ Tracer::Tracer(const FinalizedTracerConfig& config, |
99 | 102 | }); |
100 | 103 | } |
101 | 104 |
|
102 | | - store_config(); |
| 105 | + std::unordered_map<std::string, std::string> process_tags( |
| 106 | + config.process_tags); |
| 107 | + process_tags.emplace("entrypoint.name", get_process_name()); |
| 108 | + process_tags.emplace("entrypoint.type", "executable"); |
| 109 | + process_tags.emplace("entrypoint.workdir", fs::current_path().filename()); |
| 110 | + if (auto maybe_process_path = get_process_path(); |
| 111 | + maybe_process_path.has_value()) { |
| 112 | + process_tags.emplace("entrypoint.basedir", |
| 113 | + maybe_process_path->parent_path().filename()); |
| 114 | + } |
| 115 | + store_config(process_tags); |
103 | 116 | } |
104 | 117 |
|
105 | 118 | std::string Tracer::config() const { |
@@ -129,7 +142,8 @@ std::string Tracer::config() const { |
129 | 142 | return config.dump(); |
130 | 143 | } |
131 | 144 |
|
132 | | -void Tracer::store_config() { |
| 145 | +void Tracer::store_config( |
| 146 | + const std::unordered_map<std::string, std::string>& process_tags) { |
133 | 147 | auto maybe_file = |
134 | 148 | InMemoryFile::make(std::string("datadog-tracer-info-") + short_uuid()); |
135 | 149 | if (auto error = maybe_file.if_error()) { |
@@ -162,7 +176,7 @@ void Tracer::store_config() { |
162 | 176 | "service_name", [&](auto& buffer) { return msgpack::pack_string(buffer, defaults->service); }, |
163 | 177 | "service_env", [&](auto& buffer) { return msgpack::pack_string(buffer, defaults->environment); }, |
164 | 178 | "service_version", [&](auto& buffer) { return msgpack::pack_string(buffer, defaults->version); }, |
165 | | - "process_tags", [&](auto& buffer) { return msgpack::pack_string(buffer, ""); }, |
| 179 | + "process_tags", [&](auto& buffer) { return msgpack::pack_string(buffer, join_tags(process_tags)); }, |
166 | 180 | "container_id", [&](auto& buffer) { return msgpack::pack_string(buffer, container_id); } |
167 | 181 | ); |
168 | 182 | // clang-format on |
|
0 commit comments