Skip to content

Commit 5d7fb15

Browse files
vandonrgleocadie
andauthored
bump libdatadog version to v30 (#8282)
## Summary of changes just bumping the lib version, there seem to be no breaking change on our side. ## Reason for change I need DataDog/libdatadog#1459 and DataDog/libdatadog#1576 for process tags, both released in v28.0.0, I'm taking the latest minor ## Implementation details ## Test coverage ## Other details <!-- Fixes #{issue} --> <!-- ⚠️ Note: Where possible, please obtain 2 approvals prior to merging. Unless CODEOWNERS specifies otherwise, for external teams it is typically best to have one review from a team member, and one review from apm-dotnet. Trivial changes do not require 2 reviews. MergeQueue is NOT enabled in this repository. If you have write access to the repo, the PR has 1-2 approvals (see above), and all of the required checks have passed, you can use the Squash and Merge button to merge the PR. If you don't have write access, or you need help, reach out in the #apm-dotnet channel in Slack. --> --------- Co-authored-by: Gregory LEOCADIE <gregory.leocadie@datadoghq.com>
1 parent f5d4398 commit 5d7fb15

File tree

12 files changed

+224
-184
lines changed

12 files changed

+224
-184
lines changed

build/cmake/FindLibdatadog.cmake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ endif()
44

55
include(FetchContent)
66

7-
set(LIBDATADOG_VERSION "v25.0.0" CACHE STRING "libdatadog version")
7+
set(LIBDATADOG_VERSION "v30.0.0" CACHE STRING "libdatadog version")
88

99
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
1010
# For Darwin, we'll download both architectures and combine them
11-
set(SHA256_LIBDATADOG_ARM64 "2292639fa885a5f126e7bdf0bbdfd9b08ef54835bfa5c1c6291db15d4ed1b807" CACHE STRING "libdatadog arm64 sha256")
12-
set(SHA256_LIBDATADOG_X86_64 "e8fa9cd5ad8ec81defa2b7eeb62fea8eaca3df37c945be36434e9a080e14c7c5" CACHE STRING "libdatadog x86_64 sha256")
11+
set(SHA256_LIBDATADOG_ARM64 "4b54a4b0b4f7acc22b9a42786ce4bc1888024848ba345b011cab19ba73693bfa" CACHE STRING "libdatadog arm64 sha256")
12+
set(SHA256_LIBDATADOG_X86_64 "f7cb62321c0bfe2da5f22df7fd0bf52a150ce6650aac9885e19f89f4405961b5" CACHE STRING "libdatadog x86_64 sha256")
1313
set(FILE_TO_DOWNLOAD_ARM64 libdatadog-aarch64-apple-darwin.tar.gz)
1414
set(FILE_TO_DOWNLOAD_X86_64 libdatadog-x86_64-apple-darwin.tar.gz)
1515

@@ -62,18 +62,18 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
6262
else()
6363
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
6464
if(DEFINED ENV{IsAlpine} AND "$ENV{IsAlpine}" MATCHES "true")
65-
set(SHA256_LIBDATADOG "b5badd5d781086919596692fdeb46545bb3a7bfbc0786058ee3d38b847921a36" CACHE STRING "libdatadog sha256")
65+
set(SHA256_LIBDATADOG "43b0af54fe43512f17e71a1534c9d524c13a5cff01124ca0f89c1e7ccb0205f3" CACHE STRING "libdatadog sha256")
6666
set(FILE_TO_DOWNLOAD libdatadog-aarch64-alpine-linux-musl.tar.gz)
6767
else()
68-
set(SHA256_LIBDATADOG "6a408fab094966e6c5cd95ad00aab40885e816ed5268025365684be72cb71e5c" CACHE STRING "libdatadog sha256")
68+
set(SHA256_LIBDATADOG "cd39a8599d1335594644debd13bb2b60c9995c9643da41753c847f52e13c619c" CACHE STRING "libdatadog sha256")
6969
set(FILE_TO_DOWNLOAD libdatadog-aarch64-unknown-linux-gnu.tar.gz)
7070
endif()
7171
else()
7272
if(DEFINED ENV{IsAlpine} AND "$ENV{IsAlpine}" MATCHES "true")
73-
set(SHA256_LIBDATADOG "d595e65f68e5e48f8d3158ac0d5494881848d03bcded2e6c4eb68cd05fd3c0a0" CACHE STRING "libdatadog sha256")
73+
set(SHA256_LIBDATADOG "0d1b09d6653b121464b433f4d3b6947c76491d444fe1f68f22d14fe38e400649" CACHE STRING "libdatadog sha256")
7474
set(FILE_TO_DOWNLOAD libdatadog-${CMAKE_SYSTEM_PROCESSOR}-alpine-linux-musl.tar.gz)
7575
else()
76-
set(SHA256_LIBDATADOG "1571e52919e9c014f53a7accba003f930d1e49e51146064846b79c12110a2df2" CACHE STRING "libdatadog sha256")
76+
set(SHA256_LIBDATADOG "bba2c16867d81575510abc046f7e3de125c1ca7b975d7b1cd51ce6f0507859a9" CACHE STRING "libdatadog sha256")
7777
set(FILE_TO_DOWNLOAD libdatadog-${CMAKE_SYSTEM_PROCESSOR}-unknown-linux-gnu.tar.gz)
7878
endif()
7979
endif()

build/vcpkg_local_ports/libdatadog/portfile.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ set(LIBDATADOG_VERSION ${VERSION})
33
if(TARGET_TRIPLET STREQUAL "x64-windows" OR
44
TARGET_TRIPLET STREQUAL "x64-windows-static")
55
set(PLATFORM "x64")
6-
set(LIBDATADOG_HASH "abcdc9a07494ef5043bcc9654cd9fea833762441b80cf2d7959779c83f7c25cc0c3a8b2ec341389942d950720c4532b2feb1703f18d55386348ed691352dda88")
6+
set(LIBDATADOG_HASH "6ce5906245733f1fc80a2912e259e771e94285e8945fde6cfe3e5090330428288502966bd7e7fa785a57973a8f93c40f29e75105e95e6ebed3e9f9c85a269cb7")
77
elseif(TARGET_TRIPLET STREQUAL "x86-windows" OR
88
TARGET_TRIPLET STREQUAL "x86-windows-static")
99
set(PLATFORM "x86")
10-
set(LIBDATADOG_HASH "b93fee3a03453fe64c1e4e5267063cdff78c1fd7a12651556f53947b40c7ca716fdb4c03d6a496c0a961d1aba06088f9611eb40cb3bfbf625220a8f0f475267d")
10+
set(LIBDATADOG_HASH "3ab7d4d7acc6f6b328a86daf9ba17856f01eb37b9e7f06c0f1c4c4c318f04223026eb59457a31ca6549c910ada38dbaf59714d77b4f13d9a95ead499ac29e3e4")
1111
else()
1212
message(FATAL_ERROR "Unsupported triplet: ${TARGET_TRIPLET}")
1313
endif()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "libdatadog",
3-
"version-string": "25.0.0",
3+
"version-string": "30.0.0",
44
"description": "Package providing libdatadog prebuilt binaries for Windows only.",
55
"dependencies": []
66
}

profiler/src/ProfilerEngine/Datadog.Profiler.Native/AgentProxy.hpp

Lines changed: 24 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -38,83 +38,6 @@ class AgentProxy
3838

3939
Success Send(ddog_prof_EncodedProfile* profile, Tags tags, std::vector<std::pair<std::string, std::string>> files, std::string metadata, std::string info, std::string processTags)
4040
{
41-
auto [request, ec] = CreateRequest(profile, std::move(tags), std::move(files), std::move(metadata), std::move(info), std::move(processTags));
42-
if (!ec)
43-
{
44-
return std::move(ec); // ?? really ?? otherwise it calls the copy constructor :sad:
45-
}
46-
47-
assert(request != nullptr);
48-
49-
auto result = ddog_prof_Exporter_send(&_exporter, request, nullptr);
50-
51-
if (result.tag == DDOG_PROF_RESULT_HTTP_STATUS_ERR_HTTP_STATUS)
52-
{
53-
return make_error(result.err);
54-
}
55-
56-
if (IsValidHttpCode(result.ok.code))
57-
{
58-
return make_error(std::to_string(result.ok.code));
59-
}
60-
61-
return make_success();
62-
}
63-
64-
bool IsValidHttpCode(int16_t code)
65-
{
66-
// Although we expect only 200, this range represents successful sends
67-
return code < 200 || code >= 300;
68-
}
69-
70-
private:
71-
struct Request
72-
{
73-
Request(ddog_prof_Request p) :
74-
_inner(p)
75-
{
76-
}
77-
78-
Request(std::nullptr_t) :
79-
_inner{}
80-
{
81-
}
82-
83-
~Request()
84-
{
85-
ddog_prof_Exporter_Request_drop(&_inner);
86-
}
87-
88-
Request(Request const&) = delete;
89-
Request& operator=(Request const&) = delete;
90-
91-
Request(Request&& o) noexcept : _inner{}
92-
{
93-
*this = std::move(o);
94-
}
95-
96-
Request& operator=(Request&& o) noexcept
97-
{
98-
if (this != &o)
99-
{
100-
std::swap(_inner, o._inner);
101-
}
102-
return *this;
103-
}
104-
105-
operator ddog_prof_Request*()
106-
{
107-
return &_inner;
108-
}
109-
110-
private:
111-
ddog_prof_Request _inner;
112-
};
113-
114-
std::pair<Request, Success> CreateRequest(ddog_prof_EncodedProfile* encodedProfile, Tags&& tags, std::vector<std::pair<std::string, std::string>> files, std::string metadata, std::string info, std::string processTags)
115-
{
116-
std::string const profile_filename = "auto.pprof";
117-
11841
std::vector<ddog_prof_Exporter_File> to_compress_files;
11942
to_compress_files.reserve(files.size());
12043

@@ -124,7 +47,6 @@ class AgentProxy
12447
to_compress_files.push_back({to_char_slice(filename), fileSlice});
12548
}
12649

127-
auto uncompressed_files_view = ddog_prof_Exporter_Slice_File_empty();
12850
ddog_prof_Exporter_Slice_File to_compress_files_view = {to_compress_files.data(), to_compress_files.size()};
12951

13052
ddog_CharSlice* pMetadata = nullptr;
@@ -135,9 +57,6 @@ class AgentProxy
13557
pMetadata = &ffi_metadata;
13658
}
13759

138-
// json defined in internal RFC - Pprof System Info Support
139-
// that is used for SSI telemetry metrics.
140-
// Mostly already passed through tags today
14160
ddog_CharSlice* pInfo = nullptr;
14261
ddog_CharSlice ffi_info{};
14362
if (!info.empty())
@@ -154,18 +73,34 @@ class AgentProxy
15473
pProcessTags = &ffi_processTags;
15574
}
15675

157-
auto requestResult =
158-
ddog_prof_Exporter_Request_build(
159-
&_exporter, encodedProfile,
160-
to_compress_files_view, uncompressed_files_view,
76+
auto result =
77+
ddog_prof_Exporter_send_blocking(
78+
&_exporter,
79+
profile,
80+
to_compress_files_view,
16181
static_cast<ddog_Vec_Tag const*>(*tags._impl),
162-
pProcessTags, pMetadata, pInfo);
82+
pProcessTags,
83+
pMetadata,
84+
pInfo,
85+
nullptr);
86+
87+
if (result.tag == DDOG_PROF_RESULT_HTTP_STATUS_ERR_HTTP_STATUS)
88+
{
89+
return make_error(result.err);
90+
}
16391

164-
if (requestResult.tag == DDOG_PROF_REQUEST_RESULT_ERR_HANDLE_REQUEST)
92+
if (IsErrorHttpCode(result.ok.code))
16593
{
166-
return std::make_pair(Request{nullptr}, make_error(requestResult.err));
94+
return make_error(std::to_string(result.ok.code));
16795
}
168-
return std::make_pair(Request{requestResult.ok}, make_success());
96+
97+
return make_success();
98+
}
99+
100+
bool IsErrorHttpCode(int16_t code)
101+
{
102+
// Although we expect only 200, we'll accept the whole range of valid codes
103+
return code < 200 || code >= 300;
169104
}
170105

171106
private:

profiler/src/ProfilerEngine/Datadog.Profiler.Native/ExporterBuilder.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ extern "C"
2121
}
2222

2323
namespace libdatadog {
24+
constexpr uint64_t EndpointTimeoutMs = 0; // 0 means "use the default timeout"
25+
constexpr bool UseSystemResolver = true;
2426

2527
ExporterBuilder::ExporterBuilder() = default;
2628
ExporterBuilder::~ExporterBuilder() = default;
@@ -103,10 +105,10 @@ ExporterBuilder::AgentEndpoint ExporterBuilder::CreateEndpoint()
103105
{
104106
assert(!_site.empty());
105107
assert(!_apiKey.empty());
106-
return {ddog_prof_Endpoint_agentless(to_char_slice(_site), to_char_slice(_apiKey))};
108+
return {ddog_prof_Endpoint_agentless(to_char_slice(_site), to_char_slice(_apiKey), EndpointTimeoutMs, UseSystemResolver)};
107109
}
108110

109-
return {ddog_prof_Endpoint_agent(to_char_slice(_url))};
111+
return {ddog_prof_Endpoint_agent(to_char_slice(_url), EndpointTimeoutMs, UseSystemResolver)};
110112
}
111113

112114
std::unique_ptr<Exporter> ExporterBuilder::Build()

profiler/src/ProfilerEngine/Datadog.Profiler.Native/FfiHelper.cpp

Lines changed: 95 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,102 @@ ddog_CharSlice to_char_slice(std::string_view str)
3434
return {str.data(), str.size()};
3535
}
3636

37-
ddog_prof_ValueType CreateValueType(std::string const& type, std::string const& unit)
37+
bool IsCountUnit(std::string_view unit)
3838
{
39-
auto valueType = ddog_prof_ValueType{};
40-
valueType.type_ = to_char_slice(type);
41-
valueType.unit = to_char_slice(unit);
42-
return valueType;
39+
return unit == "count" || unit == "counts";
40+
}
41+
42+
bool IsBytesUnit(std::string_view unit)
43+
{
44+
return unit == "byte" || unit == "bytes";
45+
}
46+
47+
bool IsNanosecondsUnit(std::string_view unit)
48+
{
49+
return unit == "nanosecond" || unit == "nanoseconds" || unit == "Nanosecond" || unit == "Nanoseconds";
50+
}
51+
52+
bool TryCreateSampleType(std::string_view type, std::string_view unit, ddog_prof_SampleType& sampleType)
53+
{
54+
if (type == "alloc-samples" && IsCountUnit(unit))
55+
{
56+
sampleType = DDOG_PROF_SAMPLE_TYPE_ALLOC_SAMPLES;
57+
return true;
58+
}
59+
60+
if (type == "alloc-size" && IsBytesUnit(unit))
61+
{
62+
sampleType = DDOG_PROF_SAMPLE_TYPE_ALLOC_SIZE;
63+
return true;
64+
}
65+
66+
if (type == "cpu" && IsNanosecondsUnit(unit))
67+
{
68+
sampleType = DDOG_PROF_SAMPLE_TYPE_CPU_LEGACY;
69+
return true;
70+
}
71+
72+
if (type == "cpu-samples" && IsCountUnit(unit))
73+
{
74+
sampleType = DDOG_PROF_SAMPLE_TYPE_CPU_SAMPLES;
75+
return true;
76+
}
77+
78+
if (type == "exception" && IsCountUnit(unit))
79+
{
80+
sampleType = DDOG_PROF_SAMPLE_TYPE_EXCEPTION_LEGACY;
81+
return true;
82+
}
83+
84+
if (type == "inuse-objects" && IsCountUnit(unit))
85+
{
86+
sampleType = DDOG_PROF_SAMPLE_TYPE_INUSE_OBJECTS;
87+
return true;
88+
}
89+
90+
if (type == "inuse-space" && IsBytesUnit(unit))
91+
{
92+
sampleType = DDOG_PROF_SAMPLE_TYPE_INUSE_SPACE;
93+
return true;
94+
}
95+
96+
if (type == "lock-count" && IsCountUnit(unit))
97+
{
98+
sampleType = DDOG_PROF_SAMPLE_TYPE_LOCK_COUNT;
99+
return true;
100+
}
101+
102+
if (type == "lock-time" && IsNanosecondsUnit(unit))
103+
{
104+
sampleType = DDOG_PROF_SAMPLE_TYPE_LOCK_TIME;
105+
return true;
106+
}
107+
108+
if (type == "request-time" && IsNanosecondsUnit(unit))
109+
{
110+
sampleType = DDOG_PROF_SAMPLE_TYPE_REQUEST_TIME;
111+
return true;
112+
}
113+
114+
if (type == "timeline" && IsNanosecondsUnit(unit))
115+
{
116+
sampleType = DDOG_PROF_SAMPLE_TYPE_TIMELINE;
117+
return true;
118+
}
119+
120+
if (type == "wall" && IsNanosecondsUnit(unit))
121+
{
122+
sampleType = DDOG_PROF_SAMPLE_TYPE_WALL_LEGACY;
123+
return true;
124+
}
125+
126+
if ((type == "wall-time" || type == "RealTime") && IsNanosecondsUnit(unit))
127+
{
128+
sampleType = DDOG_PROF_SAMPLE_TYPE_WALL_TIME;
129+
return true;
130+
}
131+
132+
return false;
43133
}
44134

45135
std::string GetErrorMessage(ddog_Error& error)

profiler/src/ProfilerEngine/Datadog.Profiler.Native/FfiHelper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
extern "C"
1111
{
1212
#include "datadog/common.h"
13+
#include "datadog/profiling.h"
1314
}
1415

1516
namespace libdatadog {
@@ -19,7 +20,7 @@ constexpr ddog_CharSlice to_char_slice(const char* str)
1920
{
2021
return {str, std::char_traits<char>::length(str)};
2122
}
22-
ddog_prof_ValueType CreateValueType(std::string const& type, std::string const& unit);
23+
bool TryCreateSampleType(std::string_view type, std::string_view unit, ddog_prof_SampleType& sampleType);
2324

2425
std::string GetErrorMessage(ddog_Error& error);
2526
std::string GetErrorMessage(ddog_MaybeError& error);

profiler/src/ProfilerEngine/Datadog.Profiler.Native/Profile.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,25 +188,32 @@ libdatadog::Success Profile::AddUpscalingRulePoisson(std::vector<std::uintptr_t>
188188

189189
libdatadog::profile_unique_ptr CreateProfile(std::vector<SampleValueType> const& valueTypes, std::string const& periodType, std::string const& periodUnit)
190190
{
191-
std::vector<ddog_prof_ValueType> samplesTypes;
191+
std::vector<ddog_prof_SampleType> samplesTypes;
192192
samplesTypes.reserve(valueTypes.size());
193193

194-
// TODO: create a vector<int32> containing the indexes of the valueTypes
195-
std::vector<int32_t> indexes;
196-
indexes.reserve(valueTypes.size());
197-
198194
for (auto const& type : valueTypes)
199195
{
200-
samplesTypes.push_back(CreateValueType(type.Name, type.Unit));
201-
indexes.push_back(type.Index);
196+
ddog_prof_SampleType sampleType;
197+
if (!TryCreateSampleType(type.Name, type.Unit, sampleType))
198+
{
199+
Log::Error("Unsupported libdatadog sample type: ", type.Name, "/", type.Unit);
200+
return nullptr;
201+
}
202+
203+
samplesTypes.push_back(sampleType);
202204
}
203205

204-
struct ddog_prof_Slice_ValueType sample_types = {samplesTypes.data(), samplesTypes.size()};
206+
ddog_prof_Slice_SampleType sample_types = {samplesTypes.data(), samplesTypes.size()};
205207

206-
auto period_value_type = CreateValueType(periodType, periodUnit);
208+
ddog_prof_SampleType periodSampleType;
209+
if (!TryCreateSampleType(periodType, periodUnit, periodSampleType))
210+
{
211+
Log::Error("Unsupported libdatadog period type: ", periodType, "/", periodUnit);
212+
return nullptr;
213+
}
207214

208215
auto period = ddog_prof_Period{};
209-
period.type_ = period_value_type;
216+
period.sample_type = periodSampleType;
210217
period.value = 1;
211218

212219
auto res = ddog_prof_Profile_new(sample_types, &period);

0 commit comments

Comments
 (0)