|
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 |
|
@@ -100,7 +103,18 @@ Tracer::Tracer(const FinalizedTracerConfig& config, |
100 | 103 | }); |
101 | 104 | } |
102 | 105 |
|
103 | | - store_config(); |
| 106 | + std::unordered_map<std::string, std::string> process_tags( |
| 107 | + config.process_tags); |
| 108 | + process_tags.emplace("entrypoint.name", get_process_name()); |
| 109 | + process_tags.emplace("entrypoint.type", "executable"); |
| 110 | + process_tags.emplace("entrypoint.workdir", |
| 111 | + fs::current_path().filename().string()); |
| 112 | + if (auto maybe_process_path = get_process_path(); |
| 113 | + maybe_process_path.has_value()) { |
| 114 | + process_tags.emplace("entrypoint.basedir", |
| 115 | + maybe_process_path->parent_path().filename().string()); |
| 116 | + } |
| 117 | + store_config(process_tags); |
104 | 118 | } |
105 | 119 |
|
106 | 120 | std::string Tracer::config() const { |
@@ -130,7 +144,8 @@ std::string Tracer::config() const { |
130 | 144 | return config.dump(); |
131 | 145 | } |
132 | 146 |
|
133 | | -void Tracer::store_config() { |
| 147 | +void Tracer::store_config( |
| 148 | + const std::unordered_map<std::string, std::string>& process_tags) { |
134 | 149 | auto maybe_file = |
135 | 150 | InMemoryFile::make(std::string("datadog-tracer-info-") + short_uuid()); |
136 | 151 | if (auto error = maybe_file.if_error()) { |
@@ -163,7 +178,7 @@ void Tracer::store_config() { |
163 | 178 | "service_name", [&](auto& buffer) { return msgpack::pack_string(buffer, defaults->service); }, |
164 | 179 | "service_env", [&](auto& buffer) { return msgpack::pack_string(buffer, defaults->environment); }, |
165 | 180 | "service_version", [&](auto& buffer) { return msgpack::pack_string(buffer, defaults->version); }, |
166 | | - "process_tags", [&](auto& buffer) { return msgpack::pack_string(buffer, ""); }, |
| 181 | + "process_tags", [&](auto& buffer) { return msgpack::pack_string(buffer, join_tags(process_tags)); }, |
167 | 182 | "container_id", [&](auto& buffer) { return msgpack::pack_string(buffer, container_id); } |
168 | 183 | ); |
169 | 184 | // clang-format on |
|
0 commit comments