Skip to content

Commit

Permalink
add info.json with start time (#2610)
Browse files Browse the repository at this point in the history
  • Loading branch information
realFlowControl authored Apr 25, 2024
1 parent 872565b commit fb712b5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
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),
}
}

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

0 comments on commit fb712b5

Please sign in to comment.