Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(profiling) add uptime information to profiles #2610

Merged
merged 2 commits into from
Apr 25, 2024
Merged
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
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.

1 change: 1 addition & 0 deletions profiling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ anyhow = { version = "1.0" }
bumpalo = { version = "3.12", features = ["collections"] }
cfg-if = { version = "1.0" }
cpu-time = { version = "1.0" }
chrono = { version = "0.4" }
crossbeam-channel = { version = "0.5", default-features = false, features = ["std"] }
datadog-profiling = { git = "https://github.com/DataDog/libdatadog", tag = "v7.0.0" }
ddcommon = { git = "https://github.com/DataDog/libdatadog", tag = "v7.0.0" }
Expand Down
2 changes: 2 additions & 0 deletions profiling/src/profiling/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::bindings::ddog_php_prof_get_active_fiber_test as ddog_php_prof_get_ac
use crate::bindings::{datadog_php_profiling_get_profiling_context, zend_execute_data};
use crate::config::SystemSettings;
use crate::{CLOCKS, TAGS};
use chrono::Utc;
use core::{ptr, str};
use crossbeam_channel::{Receiver, Sender, TrySendError};
use datadog_profiling::api::{
Expand Down Expand Up @@ -527,6 +528,7 @@ impl Profiler {
upload_receiver,
system_settings.output_pprof.clone(),
system_settings.uri.clone(),
Utc::now(),
);

let ddprof_time = "ddprof_time";
Expand Down
15 changes: 14 additions & 1 deletion profiling/src/profiling/uploader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::config::AgentEndpoint;
use crate::exception::EXCEPTION_PROFILING_EXCEPTION_COUNT;
use crate::profiling::{UploadMessage, UploadRequest};
use crate::{PROFILER_NAME_STR, PROFILER_VERSION_STR};
use chrono::{DateTime, Utc};
use crossbeam_channel::{select, Receiver};
use datadog_profiling::exporter::File;
use ddcommon::Endpoint;
Expand All @@ -19,6 +20,7 @@ pub struct Uploader {
receiver: Receiver<UploadMessage>,
output_pprof: Option<Cow<'static, str>>,
endpoint: AgentEndpoint,
start_time: String,
}

impl Uploader {
Expand All @@ -27,12 +29,14 @@ impl Uploader {
receiver: Receiver<UploadMessage>,
output_pprof: Option<Cow<'static, str>>,
endpoint: AgentEndpoint,
start_time: DateTime<Utc>,
) -> Self {
Self {
fork_barrier,
receiver,
output_pprof,
endpoint,
start_time: start_time.to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
realFlowControl marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand All @@ -47,6 +51,15 @@ impl Uploader {
Some(metadata)
}

fn create_profiler_info(&self) -> Option<serde_json::Value> {
let metadata = json!({
"application": {
"start_time": self.start_time,
}
});
Some(metadata)
}

fn upload(&self, message: Box<UploadRequest>) -> anyhow::Result<u16> {
let index = message.index;
let profile = message.profile;
Expand Down Expand Up @@ -84,7 +97,7 @@ impl Uploader {
None,
endpoint_counts,
Self::create_internal_metadata(),
None,
self.create_profiler_info(),
timeout,
)?;
debug!("Sending profile to: {agent_endpoint}");
Expand Down
Loading