Metadata: add vpid_datetime field to metadta env
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 24 Apr 2019 15:22:23 +0000 (11:22 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 1 May 2019 21:22:27 +0000 (17:22 -0400)
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 <jonathan.rajotte-julien@efficios.com>
src/bin/lttng-sessiond/ust-app.c
src/bin/lttng-sessiond/ust-app.h
src/bin/lttng-sessiond/ust-metadata.c

index faa51c75937ebc1f5ddabd820f0feca05dbebf6a..8b3028c57201f98ffdefe19ded346b9956399b4c 100644 (file)
@@ -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();
 
        /*
index b90ff4bcef8833459268ba02f62dfc2e40bfc7e8..d9279f0e47720c42e0b9ab37918eb4c8510b570a 100644 (file)
@@ -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
index 324169559f354907ead3afe66f9ec2b2ad1f9d93..48db2cc5605535818f75a000e2ad1d9945fab57d 100644 (file)
@@ -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"
This page took 0.030397 seconds and 5 git commands to generate.