Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/Findlibdatadog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# libdatadog : common profiler imported libraries https://github.com/DataDog/libdatadog/releases
set(TAG_LIBDATADOG
"v26.0.0"
"v28.0.0"
CACHE STRING "libdatadog github tag")

set(Datadog_ROOT ${VENDOR_PATH}/libdatadog-${TAG_LIBDATADOG})
Expand Down
5 changes: 3 additions & 2 deletions src/exporter/ddprof_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,11 @@ DDRes ddprof_exporter_new(const UserTags *user_tags, DDProfExporter *exporter) {
ddog_CharSlice const base_url = to_CharSlice(exporter->_url);
ddog_prof_Endpoint endpoint;
if (exporter->_agent) {
endpoint = ddog_prof_Endpoint_agent(base_url, k_timeout_ms);
endpoint = ddog_prof_Endpoint_agent(base_url, k_timeout_ms, false);
} else {
ddog_CharSlice const api_key = to_CharSlice(exporter->_input.api_key);
endpoint = ddog_prof_Endpoint_agentless(base_url, api_key, k_timeout_ms);
endpoint =
ddog_prof_Endpoint_agentless(base_url, api_key, k_timeout_ms, false);
}

ddog_prof_ProfileExporter_Result res_exporter = ddog_prof_Exporter_new(
Expand Down
65 changes: 44 additions & 21 deletions src/pprof/ddprof_pprof.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,42 @@ DDRes get_active_ids(std::span<PerfWatcher> watchers, ActiveIdsResult &result) {
return {};
}

class ProfValueTypes {
ddog_prof_SampleType to_ddog_sample_type(int sample_type_id,
EventAggregationModePos pos) {
if (pos == kSumPos) {
switch (sample_type_id) {
case DDPROF_PWT_CPU_NANOS:
return DDOG_PROF_SAMPLE_TYPE_CPU_TIME;
case DDPROF_PWT_CPU_SAMPLE:
return DDOG_PROF_SAMPLE_TYPE_CPU_SAMPLES;
case DDPROF_PWT_ALLOC_SAMPLE:
return DDOG_PROF_SAMPLE_TYPE_ALLOC_SAMPLES;
case DDPROF_PWT_ALLOC_SPACE:
return DDOG_PROF_SAMPLE_TYPE_ALLOC_SPACE;
default:
return DDOG_PROF_SAMPLE_TYPE_SAMPLE;
}
}
// Live aggregation
switch (sample_type_id) {
case DDPROF_PWT_ALLOC_SAMPLE:
return DDOG_PROF_SAMPLE_TYPE_INUSE_OBJECTS;
case DDPROF_PWT_ALLOC_SPACE:
return DDOG_PROF_SAMPLE_TYPE_INUSE_SPACE;
default:
return DDOG_PROF_SAMPLE_TYPE_SAMPLE;
}
}

class ProfSampleTypes {
private:
int watcher_type_to_pprof_indices[DDPROF_PWT_LENGTH]
[kNbEventAggregationModes];
ddog_prof_ValueType perf_value_type[k_max_value_types] = {};
ddog_prof_SampleType sample_types[k_max_value_types] = {};
int num_sample_type_ids = 0;

public:
ProfValueTypes() {
ProfSampleTypes() {
for (auto &indices : watcher_type_to_pprof_indices) {
for (auto &index : indices) {
index = -1;
Expand All @@ -187,10 +214,8 @@ class ProfValueTypes {
watcher_type_to_pprof_indices[watcher_type][pos] = value;
}

void add_value_type(const char *name, const char *unit, int watcher_type,
EventAggregationModePos pos) {
perf_value_type[num_sample_type_ids].type_ = to_CharSlice(name);
perf_value_type[num_sample_type_ids].unit = to_CharSlice(unit);
void add_sample_type(int watcher_type, EventAggregationModePos pos) {
sample_types[num_sample_type_ids] = to_ddog_sample_type(watcher_type, pos);
set_index(watcher_type, pos, num_sample_type_ids);
++num_sample_type_ids;
}
Expand All @@ -204,14 +229,14 @@ class ProfValueTypes {
return num_sample_type_ids;
}

[[nodiscard]] ddog_prof_Slice_ValueType get_sample_types_slice() const {
return {.ptr = perf_value_type,
[[nodiscard]] ddog_prof_Slice_SampleType get_sample_types_slice() const {
return {.ptr = sample_types,
.len = static_cast<uintptr_t>(num_sample_type_ids)};
}
};

ProfValueTypes compute_pprof_values(const ActiveIdsResult &active_ids) {
ProfValueTypes result{};
ProfSampleTypes compute_pprof_values(const ActiveIdsResult &active_ids) {
ProfSampleTypes result{};
for (int i = 0; i < DDPROF_PWT_LENGTH; ++i) {
if (active_ids.output_mode[i] == EventAggregationMode::kDisabled) {
continue;
Expand All @@ -222,13 +247,12 @@ ProfValueTypes compute_pprof_values(const ActiveIdsResult &active_ids) {
static_cast<EventAggregationMode>(1 << value_pos))) {
const char *value_name = sample_type_name_from_idx(
i, static_cast<EventAggregationModePos>(value_pos));
const char *value_unit = sample_type_unit_from_idx(i);
if (!value_name || !value_unit) {
if (!value_name) {
LG_WRN("Malformed sample type (%d), ignoring", i);
continue;
}
result.add_value_type(value_name, value_unit, i,
static_cast<EventAggregationModePos>(value_pos));
result.add_sample_type(i,
static_cast<EventAggregationModePos>(value_pos));
}
}
}
Expand Down Expand Up @@ -400,9 +424,9 @@ DDRes pprof_create_profile(DDProfPProf *pprof, DDProfContext &ctx) {
static_cast<int>(active_ids.output_mode[i]));
}
#endif
// Based on active IDs, prepare the list pf pprof values
// Based on active IDs, prepare the list of pprof values
// pprof_values should stay alive while we create the pprof
const ProfValueTypes pprof_values = compute_pprof_values(active_ids);
const ProfSampleTypes pprof_values = compute_pprof_values(active_ids);

// Update each watcher with matching types
for (unsigned i = 0; i < num_watchers; ++i) {
Expand All @@ -427,9 +451,9 @@ DDRes pprof_create_profile(DDProfPProf *pprof, DDProfContext &ctx) {
}

pprof->_nb_values = pprof_values.get_num_sample_type_ids();
const ddog_prof_Slice_ValueType sample_types =
const ddog_prof_Slice_SampleType sample_types =
pprof_values.get_sample_types_slice();
ddog_prof_Period period;
ddog_prof_Period period{};
if (pprof->_nb_values > 0) {
if (!active_ids.default_watcher) {
DDRES_RETURN_ERROR_LOG(DD_WHAT_PPROF, "Unable to find default watcher");
Expand Down Expand Up @@ -457,9 +481,8 @@ DDRes pprof_create_profile(DDProfPProf *pprof, DDProfContext &ctx) {
DDRES_RETURN_ERROR_LOG(DD_WHAT_PPROF,
"Unable to find default watcher's value");
}
// period is the default watcher's type.
period = {
.type_ = sample_types.ptr[default_index],
.sample_type = sample_types.ptr[default_index],
.value = default_period,
};
}
Expand Down
12 changes: 6 additions & 6 deletions tools/libdatadog_checksums.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
38b83da2781f20f004d278c077b071441f40671de2e0adf72f7e14e37b10db15 libdatadog-x86_64-apple-darwin.tar.gz
1420ba4970ff9158aec4bd8a80d139abe8c19cfd71ae31c6c518f8a2ad1416b8 libdatadog-aarch64-apple-darwin.tar.gz
1778bed8bb4ec5a63af792ed6d7b0acd2564e5c7633d9b65d7c715e7f8635743 libdatadog-x86_64-unknown-linux-gnu.tar.gz
c90bd4959026f7fddb9012036fdc5b1e49bdf57d716cb429cdde291af6108740 libdatadog-aarch64-alpine-linux-musl.tar.gz
c67ada4359cd6a806adafcb44043bc8fb0dffd463e3aa328856496e2883142ac libdatadog-aarch64-unknown-linux-gnu.tar.gz
394b13591400b36d90755bc9851be047e6d31813347ed9d0e2638355cc9617d4 libdatadog-x86_64-alpine-linux-musl.tar.gz
23ab09884eba1b651eb841c3eb99c858a9760d1dc27ea928624c9fbe65b163a0 libdatadog-x86_64-apple-darwin.tar.gz
f9d3042918a9962415e3a5e403a2dca5a1c17fe535e7be9a932ae8ba9a6f44da libdatadog-x86_64-alpine-linux-musl.tar.gz
9e2302d99d028316dd9f0f2e2deb39b49af9387f6c849035ce7b3ec68f8021cc libdatadog-aarch64-apple-darwin.tar.gz
26936f3b8c3371aa09ae0b0cd31649401671f845e9ab08980e37fe912dd9ad7c libdatadog-aarch64-unknown-linux-gnu.tar.gz
d53951629b0173d6cf7df0ed036e706041d73541c18bc738550f5fe33d1a825f libdatadog-x86_64-unknown-linux-gnu.tar.gz
766cbe5fb9633ec57e5f4199beb3bbb182763edb7ce9e8dce554976d488b3364 libdatadog-aarch64-alpine-linux-musl.tar.gz