Skip to content

Commit 08909b1

Browse files
Remove logging (again) and reduce the diff
1 parent 587405f commit 08909b1

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

src/datadog/datadog_agent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ DatadogAgent::DatadogAgent(
171171
// Origin Detection headers are not necessary when Unix Domain Socket (UDS)
172172
// is used to communicate with the Datadog Agent.
173173
if (!contains(config.url.scheme, "unix")) {
174-
if (auto container_id = container::get_id(logger_)) {
174+
if (auto container_id = container::get_id()) {
175175
if (container_id->type == container::ContainerID::Type::container_id) {
176176
headers_.emplace("Datadog-Container-ID", container_id->value);
177177
headers_.emplace("Datadog-Entity-Id", "ci-" + container_id->value);

src/datadog/platform_util.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#include <cassert>
44
#include <cstdint>
55
#include <fstream>
6-
#include <iostream>
7-
#include <memory>
86
#include <regex>
97

108
// clang-format off
@@ -46,8 +44,6 @@
4644
#endif
4745
// clang-format on
4846

49-
#include <datadog/logger.h>
50-
5147
namespace datadog {
5248
namespace tracing {
5349
namespace {
@@ -330,17 +326,13 @@ bool is_running_in_host_namespace() {
330326
return false;
331327
}
332328

333-
Optional<Cgroup> get_cgroup_version(const std::shared_ptr<tracing::Logger>& logger) {
329+
Optional<Cgroup> get_cgroup_version() {
334330
struct statfs buf;
335331

336332
if (statfs("/sys/fs/cgroup", &buf) != 0) {
337-
logger->log_error("Failed to statfs /sys/fs/cgroup");
338333
return nullopt;
339334
}
340335

341-
logger->log_error([&](auto& stream) {
342-
stream << "statfs /sys/fs/cgroup: f_type = " << buf.f_type;
343-
});
344336
if (buf.f_type == CGROUP_SUPER_MAGIC || buf.f_type == TMPFS_MAGIC)
345337
return Cgroup::v1;
346338
else if (buf.f_type == CGROUP2_SUPER_MAGIC)
@@ -351,9 +343,7 @@ Optional<Cgroup> get_cgroup_version(const std::shared_ptr<tracing::Logger>& logg
351343

352344
Optional<std::string> find_container_id_from_cgroup() {
353345
auto cgroup_fd = std::ifstream("/proc/self/cgroup", std::ios::in);
354-
if (!cgroup_fd.is_open()) {
355-
return nullopt;
356-
}
346+
if (!cgroup_fd.is_open()) return nullopt;
357347

358348
return find_container_id(cgroup_fd);
359349
}
@@ -386,12 +376,11 @@ Optional<std::string> find_container_id(std::istream& source) {
386376
return nullopt;
387377
}
388378

389-
Optional<ContainerID> get_id(const std::shared_ptr<tracing::Logger>& logger) {
379+
Optional<ContainerID> get_id() {
390380
#if defined(__linux__) || defined(__unix__)
391-
auto maybe_cgroup = get_cgroup_version(logger);
381+
auto maybe_cgroup = get_cgroup_version();
392382
if (!maybe_cgroup) return nullopt;
393383

394-
// Determine the container ID or inode
395384
ContainerID id;
396385
switch (*maybe_cgroup) {
397386
case Cgroup::v1: {

src/datadog/platform_util.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
// This component provides platform-dependent miscellanea.
44

55
#include <datadog/expected.h>
6-
#include <datadog/logger.h>
76
#include <datadog/string_view.h>
87

9-
#include <memory>
108
#include <string>
119

1210
namespace datadog {
@@ -98,7 +96,7 @@ Optional<std::string> find_container_id(std::istream& source);
9896
///
9997
/// @return A `ContainerID` object containing id of the container in
10098
/// which the current process is running.
101-
Optional<ContainerID> get_id(const std::shared_ptr<tracing::Logger>& logger);
99+
Optional<ContainerID> get_id();
102100

103101
} // namespace container
104102

0 commit comments

Comments
 (0)