From fcf1c6efa2936be0065867fbfb86f4c8c182c35f Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Wed, 24 Apr 2019 11:22:23 -0400 Subject: [PATCH] Metadata: add vpid_datetime field to metadta env This information can be used by viewer and previously contain in the path hierarchy of a trace. Add the registration_time field to ust_app to access it when printing metadata. Reuse this field to generate the trace path. Signed-off-by: Jonathan Rajotte --- src/bin/lttng-sessiond/ust-app.c | 7 ++-- src/bin/lttng-sessiond/ust-app.h | 5 +++ src/bin/lttng-sessiond/ust-metadata.c | 49 ++++++++++++++++++++------- 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index faa51c759..8b3028c57 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -1831,15 +1831,12 @@ static void shadow_copy_channel(struct ust_app_channel *ua_chan, static void shadow_copy_session(struct ust_app_session *ua_sess, struct ltt_ust_session *usess, struct ust_app *app) { - time_t rawtime; struct tm *timeinfo; char datetime[16]; int ret; char tmp_shm_path[PATH_MAX]; - /* Get date and time for unique app path */ - time(&rawtime); - timeinfo = localtime(&rawtime); + timeinfo = localtime(&app->registration_time); strftime(datetime, sizeof(datetime), "%Y%m%d-%H%M%S", timeinfo); DBG2("Shadow copy of session handle %d", ua_sess->handle); @@ -3377,6 +3374,8 @@ void ust_app_add(struct ust_app *app) assert(app); assert(app->notify_sock >= 0); + app->registration_time = time(NULL); + rcu_read_lock(); /* diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index b90ff4bce..d9279f0e4 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -298,6 +298,11 @@ struct ust_app { * to a negative value indicating that the agent application is gone. */ int agent_app_sock; + /* + * Time at which the app is registred. + * Used for path creation + */ + time_t registration_time; }; #ifdef HAVE_LIBLTTNG_UST_CTL diff --git a/src/bin/lttng-sessiond/ust-metadata.c b/src/bin/lttng-sessiond/ust-metadata.c index 324169559..48db2cc56 100644 --- a/src/bin/lttng-sessiond/ust-metadata.c +++ b/src/bin/lttng-sessiond/ust-metadata.c @@ -969,6 +969,39 @@ error: return ret; } +static +int print_metadata_app_information(struct ust_registry_session *registry, + struct ust_app *app) +{ + int ret; + char datetime[ISO8601_LEN]; + + if (!app) { + ret = 0; + goto end; + } + + ret = time_t_to_ISO8601(datetime, sizeof(datetime), + app->registration_time); + if (ret) { + goto end; + } + + ret = lttng_metadata_printf(registry, + " tracer_patchlevel = %u;\n" + " vpid = %d;\n" + " procname = \"%s\";\n" + " vpid_datetime = \"%s\";\n" , + app->version.patchlevel, + (int) app->pid, + app->name, + datetime + ); + +end: + return ret; +} + /* * Should be called with session registry mutex held. */ @@ -1055,18 +1088,10 @@ int ust_metadata_session_statedump(struct ust_registry_session *session, * If per-application registry, we can output extra information * about the application. */ - if (app) { - ret = lttng_metadata_printf(session, - " tracer_patchlevel = %u;\n" - " vpid = %d;\n" - " procname = \"%s\";\n", - app->version.patchlevel, - (int) app->pid, - app->name - ); - if (ret) - goto end; - } + ret = print_metadata_app_information(session, app); + if (ret) + goto end; + ret = lttng_metadata_printf(session, "};\n\n" -- 2.34.1