Add the GMT offset in the rotated chunk path
authorJulien Desfossez <jdesfossez@efficios.com>
Thu, 11 Jan 2018 18:44:56 +0000 (13:44 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 3 Apr 2018 16:12:29 +0000 (12:12 -0400)
The path of a rotated chunk is composed of the start and end timestamp
of the trace inside that chunk. In order to support distributed
environments, we now specify the GMT offset in this path as well. The
date is now formatted in ISO 8601. Here is an example:
~/lttng-traces/<session-name>/20180118T144610-0500-20180118T144611-0500-1

Chunk start: 2018-01-18 14:46:10
Chunk end: 2018-01-18 14:46:11
GMT offset: GMT-5 on both timestamps
Chunk ID: 1 (number of rotations that occured in this session so far)

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/rotate.c
tests/regression/tools/rotation/rotate_utils.sh

index 924ac92316bf0c9add8a79e15b7087aa421a6c44..375324aec870bea400ce620b95fe8603ed1357cd 100644 (file)
@@ -4377,7 +4377,7 @@ int cmd_rotate_session(struct ltt_session *session,
        int ret;
        size_t strf_ret;
        struct tm *timeinfo;
-       char datetime[16];
+       char datetime[21];
        time_t now;
        bool ust_active = false;
 
@@ -4479,7 +4479,7 @@ int cmd_rotate_session(struct ltt_session *session,
                ret = -LTTNG_ERR_UNK;
                goto end;
        }
-       strf_ret = strftime(datetime, sizeof(datetime), "%Y%m%d-%H%M%S",
+       strf_ret = strftime(datetime, sizeof(datetime), "%Y%m%dT%H%M%S%z",
                        timeinfo);
        if (!strf_ret) {
                ERR("Failed to format local time timestamp in rotate session command");
index 237723d3da8c7bc3e4f8963fcf73e829310bdd72..4264cd4bd91fadeca704f9895b4c0733610a1b9c 100644 (file)
@@ -209,8 +209,8 @@ error:
 int rename_complete_chunk(struct ltt_session *session, time_t ts)
 {
        struct tm *timeinfo;
-       char datetime[16], start_datetime[16];
        char new_path[LTTNG_PATH_MAX];
+       char datetime[21], start_datetime[21];
        int ret;
        size_t strf_ret;
 
@@ -221,7 +221,8 @@ int rename_complete_chunk(struct ltt_session *session, time_t ts)
                ret = -1;
                goto end;
        }
-       strf_ret = strftime(datetime, sizeof(datetime), "%Y%m%d-%H%M%S",
+
+       strf_ret = strftime(datetime, sizeof(datetime), "%Y%m%dT%H%M%S%z",
                        timeinfo);
        if (strf_ret == 0) {
                ERR("Failed to format timestamp while renaming completed session chunk");
@@ -230,7 +231,7 @@ int rename_complete_chunk(struct ltt_session *session, time_t ts)
        }
 
        if (session->rotate_count == 1) {
-               char start_time[16];
+               char start_time[21];
 
                timeinfo = localtime(&session->last_chunk_start_ts);
                if (!timeinfo) {
@@ -240,7 +241,7 @@ int rename_complete_chunk(struct ltt_session *session, time_t ts)
                }
 
                strf_ret = strftime(start_time, sizeof(start_time),
-                               "%Y%m%d-%H%M%S", timeinfo);
+                               "%Y%m%dT%H%M%S%z", timeinfo);
                if (strf_ret == 0) {
                        ERR("Failed to format timestamp while renaming completed session chunk");
                        ret = -1;
@@ -302,7 +303,8 @@ int rename_complete_chunk(struct ltt_session *session, time_t ts)
                        ret = -1;
                        goto end;
                }
-               strf_ret = strftime(start_datetime, sizeof(start_datetime), "%Y%m%d-%H%M%S", timeinfo);
+               strf_ret = strftime(start_datetime, sizeof(start_datetime),
+                               "%Y%m%dT%H%M%S%z", timeinfo);
                if (!strf_ret) {
                        ERR("Failed to format timestamp while renaming completed session chunk");
                        ret = -1;
index 1a78c174bdb8ef9d24111484c4d4ecf0fdf2481e..37ada94864338cccf4556b1c49eb644ddef65ef0 100644 (file)
@@ -2,8 +2,8 @@ function set_chunk_pattern ()
 {
        # Need to call this function after $today has been set.
 
-       # YYYYMMDD-HHMMSS-YYYYMMDD-HHMMSS
-       export chunk_pattern="${today}-[0-9][0-9][0-9][0-9][0-9][0-9]-${today}-[0-9][0-9][0-9][0-9][0-9][0-9]"
+       # YYYYMMDDTHHMMSS[+-]HHMM-YYYYMMDDTHHMMSS[+-]HHMM
+       export chunk_pattern="${today}T[0-9][0-9][0-9][0-9][0-9][0-9][+-][0-9][0-9][0-9][0-9]-${today}T[0-9][0-9][0-9][0-9][0-9][0-9][+-][0-9][0-9][0-9][0-9]"
 }
 
 function validate_test_chunks ()
This page took 0.03182 seconds and 4 git commands to generate.