Skip to content

Commit de750a8

Browse files
authored
Update libdatadog to 20.0.0 (#7358)
## Summary of changes - Bump version from 19.1.0 to 20.0.0. - Update GetResponseBody signature. ## Reason for change API Changes: - `ddog_trace_exporter_response_get_body` now returns the length which prevents managed code to compute the payload's length manually. Improvements: - Avoid formatting the agent response into a null terminated string before returning it to the managed code. This will boost the performance by avoiding an additional copy of the response ([#1170](DataDog/libdatadog#1170)). - Lower the severity of the info fetcher logs [#1168](DataDog/libdatadog#1168). ## Other details Libdd release [page](https://github.com/DataDog/libdatadog/releases/tag/v20.0.0)
1 parent d2f2aba commit de750a8

File tree

5 files changed

+23
-33
lines changed

5 files changed

+23
-33
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 "v19.1.0" CACHE STRING "libdatadog version")
7+
set(LIBDATADOG_VERSION "v20.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 "b992a11b90ec5927646a0c96b74fe9fcd63e7e471307e74a670ddf42fc10eaf9" CACHE STRING "libdatadog arm64 sha256")
12-
set(SHA256_LIBDATADOG_X86_64 "6a12ef60fd7b00544343c2b6761ef801ad2e1237075711bd16dfb7247464bc43" CACHE STRING "libdatadog x86_64 sha256")
11+
set(SHA256_LIBDATADOG_ARM64 "916a207ea1343744062ff44f421f198bc9d79ae2be7624f4ba355542ff03b7ec" CACHE STRING "libdatadog arm64 sha256")
12+
set(SHA256_LIBDATADOG_X86_64 "879d213a5cbf982500833323828c862a5efc824afdb03628daa8f363e70cbfe9" 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 "7c69a37cb335260610b61ae956192a6dbd104d05a8278c8ff894dbfebc2efd53" CACHE STRING "libdatadog sha256")
65+
set(SHA256_LIBDATADOG "12791239d3d0bfeab8fc659d10dd64e8ccf9ad87aa3f293c3f509a57bf2b3ade" CACHE STRING "libdatadog sha256")
6666
set(FILE_TO_DOWNLOAD libdatadog-aarch64-alpine-linux-musl.tar.gz)
6767
else()
68-
set(SHA256_LIBDATADOG "606b23f4de7defacd5d4a381816f8d7bfe26112c97fcdf21ec2eb998a6c5fbbd" CACHE STRING "libdatadog sha256")
68+
set(SHA256_LIBDATADOG "368903a0a73b700ba2a6a8aee91b2be49af9ef6077b684b9f1aace408f8917b1" 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 "2008886021ddee573c0d539626d1d58d41e2a7dbc8deca22b3662da52de6f4d9" CACHE STRING "libdatadog sha256")
73+
set(SHA256_LIBDATADOG "bcf85135fea719aa192d176b08bb62056beff5d96ddbd114dfc28e50fcfea08c" CACHE STRING "libdatadog sha256")
7474
set(FILE_TO_DOWNLOAD libdatadog-${CMAKE_SYSTEM_PROCESSOR}-alpine-linux-musl.tar.gz)
7575
else()
76-
set(SHA256_LIBDATADOG "4e5b05515ab180aec0819608aa5d277ff710055819654147a9d69caea27a0dbc" CACHE STRING "libdatadog sha256")
76+
set(SHA256_LIBDATADOG "84b779bdaa3da7668795e264a5ac4b015185044d147a142727349026eb49d428" 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 "9b33697d3a9949c81a5eadf6fd6334adba4b262acb8887651021443c5f5b35b06dc7e2bdde5cee1b7a1f4862f0896436130b7f4940050e4dbccf8e7e0b2f129e")
6+
set(LIBDATADOG_HASH "f43b4e0a41a4f1d20995e13bc43b7d3502120c2809aefa177f3eea73db1f430e9de350f6f54bdadae09820ad7a492b7f054ec0180d94c33e44fb9a462ab3153a")
77
elseif(TARGET_TRIPLET STREQUAL "x86-windows" OR
88
TARGET_TRIPLET STREQUAL "x86-windows-static")
99
set(PLATFORM "x86")
10-
set(LIBDATADOG_HASH "ace14ad5b0525c11f86d166b5696b8dcfd48cb5bb1c4435e71eba982c3da21c4f42ac6b6ec5fdf53f09a353a3339e2a31cc57003637578bc73815def808768b1")
10+
set(LIBDATADOG_HASH "9cdc780f52edcccf272098f46ee2200e2fa3d56b29be21b5bfc1bcf7943f9a0efd7b7d9e84ca6340e618ec92c4b19d7625d6907592027d4ca67241b08b9063a6")
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": "19.1.0",
3+
"version-string": "20.0.0",
44
"description": "Package providing libdatadog prebuilt binaries for Windows only.",
55
"dependencies": []
66
}

tracer/src/Datadog.Trace/LibDatadog/NativeInterop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ internal static class Exporter
4444
internal static extern TraceExporterErrorHandle Send(SafeHandle handle, ByteSlice trace, UIntPtr traceCount, ref IntPtr response);
4545

4646
[DllImport(DllName, EntryPoint = "ddog_trace_exporter_response_get_body")]
47-
internal static extern IntPtr GetResponseBody(IntPtr outHandle);
47+
internal static extern IntPtr GetResponseBody(IntPtr outHandle, ref UIntPtr len);
4848

4949
[DllImport(DllName, EntryPoint = "ddog_trace_exporter_response_free")]
5050
internal static extern void FreeResponse(IntPtr handle);

tracer/src/Datadog.Trace/LibDatadog/TraceExporter.cs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,6 @@ protected override bool ReleaseHandle()
9797
return true;
9898
}
9999

100-
private unsafe int GetBodyLen(IntPtr body)
101-
{
102-
if (body == IntPtr.Zero)
103-
{
104-
return 0;
105-
}
106-
107-
byte* p = (byte*)body;
108-
int len = 0;
109-
while (p[len] != 0)
110-
{
111-
len++;
112-
}
113-
114-
return len;
115-
}
116-
117100
private unsafe void Send(ArraySegment<byte> traces, int numberOfTraces, ref IntPtr responsePtr)
118101
{
119102
fixed (byte* ptr = traces.Array)
@@ -147,15 +130,22 @@ private unsafe void ProcessResponse(IntPtr response)
147130
return;
148131
}
149132

150-
// TODO: replace GetBodyLen with a native function in order to avoid iterating over the response to get its length.
151-
var body = NativeInterop.Exporter.GetResponseBody(response);
152-
var len = GetBodyLen(body);
153-
if (len <= 0)
133+
var len = UIntPtr.Zero;
134+
var body = NativeInterop.Exporter.GetResponseBody(response, ref len);
135+
var bodyLen = (ulong)len;
136+
if (body == IntPtr.Zero || bodyLen == 0)
137+
{
138+
_log.Warning("Agent response is null or empty");
139+
return;
140+
}
141+
142+
if (bodyLen > int.MaxValue)
154143
{
144+
_log.Warning("Agent response is too large");
155145
return;
156146
}
157147

158-
var json = System.Text.Encoding.UTF8.GetString((byte*)body, len);
148+
var json = System.Text.Encoding.UTF8.GetString((byte*)body, (int)bodyLen);
159149
if (json != _cachedResponse)
160150
{
161151
var apiResponse = JsonConvert.DeserializeObject<ApiResponse>(json);

0 commit comments

Comments
 (0)