Skip to content
Open
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 .github/workflows/all-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
delay: '3'
retries: '45'
polling_interval: '1'
checks_exclude: 'devflow/merge'
checks_exclude: 'devflow/merge,dd-gitlab/default-pipeline'
25 changes: 0 additions & 25 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,3 @@ trigger_internal_build:
project: DataDog/apm-reliability/libddprof-build
strategy: depend
branch: $DOWNSTREAM_BRANCH

# Following jobs are required otherwise gitsync will not report downstream pipeline failure to github

# This job is used to determine if downstream pipeline has succeeded
report_failure:
tags: ["arch:amd64"]
when: on_failure
needs: [trigger_internal_build, benchmarks]
# allow_failure: true prevents the job from showing up in github statuses (because it's filtered by gitsync)
allow_failure: true
script:
- echo "STATUS=1" >> .env
- exit 1 # if this job completes it should always be considered a failure
artifacts:
reports:
dotenv: .env

# Final job that will show in github statuses
report_gitlab_CI_status:
tags: ["arch:amd64"]
when: always
stage: .post
script:
- "echo TIP: If you see this failing, something else in the GitLab pipeline failed. Follow the link to the pipeline and check for other things that failed prior to this step."
- exit ${STATUS}
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 13 additions & 15 deletions datadog-profiling-replayer/src/replayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ pub struct Replayer<'pprof> {
pub start_time: SystemTime,
pub duration: Duration,
pub end_time: SystemTime, // start_time + duration
pub sample_types: Vec<api::ValueType<'pprof>>,
pub period: Option<api::Period<'pprof>>,
pub sample_types: Vec<api::SampleType>,
pub period: Option<api::Period>,
pub endpoints: Vec<(u64, &'pprof str)>,
pub samples: Vec<(Option<Timestamp>, api::Sample<'pprof>)>,
}
Expand Down Expand Up @@ -57,29 +57,27 @@ impl<'pprof> Replayer<'pprof> {

fn sample_types<'a>(
profile_index: &'a ProfileIndex<'pprof>,
) -> anyhow::Result<Vec<api::ValueType<'pprof>>> {
) -> anyhow::Result<Vec<api::SampleType>> {
let mut sample_types = Vec::with_capacity(profile_index.pprof.sample_types.len());
for sample_type in profile_index.pprof.sample_types.iter() {
sample_types.push(api::ValueType::new(
profile_index.get_string(sample_type.r#type)?,
profile_index.get_string(sample_type.unit)?,
))
let type_str = profile_index.get_string(sample_type.r#type)?;
let unit = profile_index.get_string(sample_type.unit)?;
let vt = api::ValueType::new(type_str, unit);
sample_types.push(vt.try_into()?);
}
Ok(sample_types)
}

fn period<'a>(
profile_index: &'a ProfileIndex<'pprof>,
) -> anyhow::Result<Option<api::Period<'pprof>>> {
fn period<'a>(profile_index: &'a ProfileIndex<'pprof>) -> anyhow::Result<Option<api::Period>> {
let value = profile_index.pprof.period;

match profile_index.pprof.period_type {
Some(period_type) => {
let r#type = api::ValueType::new(
profile_index.get_string(period_type.r#type)?,
profile_index.get_string(period_type.unit)?,
);
Ok(Some(api::Period { r#type, value }))
let type_str = profile_index.get_string(period_type.r#type)?;
let unit = profile_index.get_string(period_type.unit)?;
let vt = api::ValueType::new(type_str, unit);
let sample_type = vt.try_into()?;
Ok(Some(api::Period { sample_type, value }))
}
None => Ok(None),
}
Expand Down
15 changes: 6 additions & 9 deletions examples/cxx/profiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ int main() {
std::cout << "=== Datadog Profiling CXX Bindings Example ===" << std::endl;
std::cout << "\nCreating Profile..." << std::endl;

ValueType wall_time{
.type_ = "wall-time",
.unit = "nanoseconds"
};

Period period{
.value_type = wall_time,
.value_type = SampleType::WallTime,
.value = 60
};

auto profile = Profile::create({wall_time}, period);
// Create profile with predefined sample types
// Note: ExperimentalCount, ExperimentalNanoseconds, and ExperimentalBytes
// are available for custom profiling metrics
auto profile = Profile::create({SampleType::WallTime}, period);
std::cout << "✅ Profile created" << std::endl;

std::cout << "Adding upscaling rules..." << std::endl;
Expand Down Expand Up @@ -253,8 +251,7 @@ int main() {
// Files to compress and attach
{AttachmentFile{
.name = "app_metadata.json",
.data = {metadata_bytes.data(), metadata_bytes.size()},
.mime = MimeType::ApplicationJson
.data = {metadata_bytes.data(), metadata_bytes.size()}
}},
// Additional per-profile tags
{
Expand Down
12 changes: 6 additions & 6 deletions examples/ffi/exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ int main(int argc, char *argv[]) {

const auto service = argv[1];

const ddog_prof_ValueType wall_time = {
.type_ = DDOG_CHARSLICE_C_BARE("wall-time"),
.unit = DDOG_CHARSLICE_C_BARE("nanoseconds"),
// Use the SampleType enum instead of ValueType struct
const ddog_prof_SampleType wall_time = DDOG_PROF_SAMPLE_TYPE_WALL_TIME;
const ddog_prof_Slice_SampleType sample_types = {&wall_time, 1};
const ddog_prof_Period period = {
.sample_type = wall_time,
.value = 60,
};

const ddog_prof_Slice_ValueType sample_types = {&wall_time, 1};
const ddog_prof_Period period = {wall_time, 60};
ddog_prof_Profile_NewResult profile_new_result = ddog_prof_Profile_new(sample_types, &period);
if (profile_new_result.tag != DDOG_PROF_PROFILE_NEW_RESULT_OK) {
print_error("Failed to make new profile: ", profile_new_result.err);
Expand Down
40 changes: 22 additions & 18 deletions examples/ffi/exporter_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ void print_error(const char *s, const ddog_Error *err) {

// Helper function to create a simple profile with one sample
ddog_prof_Profile *create_profile_with_sample(void) {
const ddog_prof_ValueType wall_time = {
.type_ = DDOG_CHARSLICE_C_BARE("wall-time"),
.unit = DDOG_CHARSLICE_C_BARE("nanoseconds"),
// Use the SampleType enum instead of ValueType struct
const ddog_prof_SampleType wall_time = DDOG_PROF_SAMPLE_TYPE_WALL_TIME;
const ddog_prof_Slice_SampleType sample_types = {&wall_time, 1};
const ddog_prof_Period period = {
.sample_type = wall_time,
.value = 60,
};

const ddog_prof_Slice_ValueType sample_types = {&wall_time, 1};
const ddog_prof_Period period = {wall_time, 60};

ddog_prof_Profile_NewResult profile_result = ddog_prof_Profile_new(sample_types, &period);
if (profile_result.tag != DDOG_PROF_PROFILE_NEW_RESULT_OK) {
print_error("Failed to create profile", &profile_result.err);
Expand Down Expand Up @@ -121,16 +121,16 @@ int main(int argc, char *argv[]) {
}

// We need to heap-allocate the exporter to pass it to ExporterManager_new
ddog_prof_ProfileExporter *exporter = malloc(sizeof(ddog_prof_ProfileExporter));
*exporter = exporter_result.ok;
// The function takes ownership via a mutable pointer
ddog_prof_ProfileExporter exporter = exporter_result.ok;
ddog_prof_ProfileExporter *exporter_ptr = &exporter;

// Create the ExporterManager
printf("Creating ExporterManager...\n");
ddog_prof_Result_HandleExporterManager manager_result = ddog_prof_ExporterManager_new(exporter);
ddog_prof_Result_HandleExporterManager manager_result = ddog_prof_ExporterManager_new(exporter_ptr);
if (manager_result.tag != DDOG_PROF_RESULT_HANDLE_EXPORTER_MANAGER_OK_HANDLE_EXPORTER_MANAGER) {
print_error("Failed to create ExporterManager", &manager_result.err);
ddog_Error_drop(&manager_result.err);
free(exporter);
return 1;
}

Expand All @@ -156,15 +156,17 @@ int main(int argc, char *argv[]) {
return 1;
}

ddog_prof_EncodedProfile *encoded_profile = &serialize_result.ok;
// The queue function takes ownership of the encoded profile, so we need a mutable pointer
ddog_prof_EncodedProfile encoded_profile = serialize_result.ok;
ddog_prof_EncodedProfile *encoded_profile_ptr = &encoded_profile;

// Queue the profile (no additional files or tags for this simple example)
ddog_prof_Exporter_Slice_File empty_files = ddog_prof_Exporter_Slice_File_empty();
ddog_Vec_Tag empty_tags = ddog_Vec_Tag_new();

ddog_VoidResult queue_result = ddog_prof_ExporterManager_queue(
&manager,
encoded_profile,
encoded_profile_ptr,
empty_files,
&empty_tags,
NULL, // optional_process_tags
Expand All @@ -177,7 +179,7 @@ int main(int argc, char *argv[]) {
if (queue_result.tag != DDOG_VOID_RESULT_OK) {
print_error("Failed to queue profile", &queue_result.err);
ddog_Error_drop(&queue_result.err);
ddog_prof_EncodedProfile_drop(encoded_profile);
// encoded_profile was consumed by queue, so we don't drop it here
ddog_prof_Profile_drop(profile);
free(profile);
ddog_prof_ExporterManager_drop(&manager);
Expand All @@ -187,7 +189,7 @@ int main(int argc, char *argv[]) {
printf("Profile queued successfully!\n");

// Clean up profile after queueing
ddog_prof_EncodedProfile_drop(encoded_profile);
// Note: encoded_profile was consumed by queue, so we don't drop it
ddog_prof_Profile_drop(profile);
free(profile);

Expand Down Expand Up @@ -215,13 +217,15 @@ int main(int argc, char *argv[]) {
return 1;
}

encoded_profile = &serialize_result.ok;
// The queue function takes ownership of the encoded profile, so we need a mutable pointer
ddog_prof_EncodedProfile encoded_profile2 = serialize_result.ok;
ddog_prof_EncodedProfile *encoded_profile_ptr2 = &encoded_profile2;

// Queue another profile
empty_tags = ddog_Vec_Tag_new();
queue_result = ddog_prof_ExporterManager_queue(
&manager,
encoded_profile,
encoded_profile_ptr2,
empty_files,
&empty_tags,
NULL, // optional_process_tags
Expand All @@ -233,14 +237,14 @@ int main(int argc, char *argv[]) {
if (queue_result.tag != DDOG_VOID_RESULT_OK) {
print_error("Failed to queue profile for fork example", &queue_result.err);
ddog_Error_drop(&queue_result.err);
ddog_prof_EncodedProfile_drop(encoded_profile);
// encoded_profile was consumed by queue, so we don't drop it here
ddog_prof_Profile_drop(profile);
free(profile);
ddog_prof_ExporterManager_drop(&manager);
return 1;
}

ddog_prof_EncodedProfile_drop(encoded_profile);
// Note: encoded_profile was consumed by queue, so we don't drop it
ddog_prof_Profile_drop(profile);
free(profile);

Expand Down
11 changes: 6 additions & 5 deletions examples/ffi/profile_intern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ void wait_for_user(std::string s) {
}

int main(void) {
const ddog_prof_ValueType wall_time = {
.type_ = to_slice_c_char("wall-time"),
.unit = to_slice_c_char("nanoseconds"),
// Use the SampleType enum instead of ValueType struct
const ddog_prof_SampleType wall_time = DDOG_PROF_SAMPLE_TYPE_WALL_TIME;
const ddog_prof_Slice_SampleType sample_types = {&wall_time, 1};
const ddog_prof_Period period = {
.sample_type = wall_time,
.value = 60,
};
const ddog_prof_Slice_ValueType sample_types = {&wall_time, 1};
const ddog_prof_Period period = {wall_time, 60};

ddog_prof_Profile_NewResult new_result = ddog_prof_Profile_new(sample_types, &period);
if (new_result.tag != DDOG_PROF_PROFILE_NEW_RESULT_OK) {
Expand Down
11 changes: 6 additions & 5 deletions examples/ffi/profiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
#define NUM_SAMPLES 5000000

int main(void) {
const ddog_prof_ValueType wall_time = {
.type_ = DDOG_CHARSLICE_C("wall-time"),
.unit = DDOG_CHARSLICE_C("nanoseconds"),
// Use the SampleType enum instead of ValueType struct
const ddog_prof_SampleType wall_time = DDOG_PROF_SAMPLE_TYPE_WALL_TIME;
const ddog_prof_Slice_SampleType sample_types = {&wall_time, 1};
const ddog_prof_Period period = {
.sample_type = wall_time,
.value = 60,
};
const ddog_prof_Slice_ValueType sample_types = {&wall_time, 1};
const ddog_prof_Period period = {wall_time, 60};

// Create a ProfilesDictionary for the new API
ddog_prof_ProfilesDictionaryHandle dict = {0};
Expand Down
1 change: 0 additions & 1 deletion libdd-profiling-ffi/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ renaming_overrides_prefixing = true
"VoidResult" = "ddog_VoidResult"

"CbindgenIsDumbStringId" = "ddog_prof_StringId"
"MimeType" = "ddog_prof_MimeType"

"Slice_GenerationalIdLabelId" = "ddog_prof_Slice_LabelId"
"Slice_GenerationalIdLocationId" = "ddog_prof_Slice_LocationId"
Expand Down
6 changes: 2 additions & 4 deletions libdd-profiling-ffi/src/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use libdd_common_ffi::{
wrap_with_ffi_result, wrap_with_void_ffi_result, Handle, Result, ToInner, VoidResult,
};
use libdd_profiling::exporter;
use libdd_profiling::exporter::{ExporterManager, MimeType, ProfileExporter};
use libdd_profiling::exporter::{ExporterManager, ProfileExporter};
use libdd_profiling::internal::EncodedProfile;
use std::borrow::Cow;
use std::str::FromStr;
Expand All @@ -31,7 +31,6 @@ pub enum ProfilingEndpoint<'a> {
pub struct File<'a> {
name: CharSlice<'a>,
file: ByteSlice<'a>,
mime: MimeType,
}

#[must_use]
Expand Down Expand Up @@ -187,8 +186,7 @@ unsafe fn into_vec_files<'a>(slice: Slice<'a, File>) -> Vec<exporter::File<'a>>
.map(|file| {
let name = file.name.try_to_utf8().unwrap_or("{invalid utf-8}");
let bytes = file.file.as_slice();
let mime = file.mime;
exporter::File { name, bytes, mime }
exporter::File { name, bytes }
})
.collect()
}
Expand Down
Loading
Loading