File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 13
13
#include <time.h>
14
14
15
15
#include "util_health.h"
16
+ #include "nr_uuid.h"
16
17
#include "util_memory.h"
17
18
#include "util_strings.h"
18
19
#include "util_syscalls.h"
@@ -48,15 +49,33 @@ static nrhealth_t last_error_code = NRH_HEALTHY;
48
49
static char health_uuid [] = "bc21b5891f5e44fc9272caef924611a8" ;
49
50
50
51
nr_status_t nrh_set_uuid (char * uuid ) {
52
+ char * rand_uuid = NULL ;
53
+ if (NULL == uuid ) {
54
+ // no uuid supplied, auto-generate instead
55
+ rand_uuid = nr_uuid_create (-1 );
56
+ uuid = rand_uuid ;
57
+ }
58
+
51
59
if (UUID_LEN != nr_strlen (uuid )) {
52
60
return NR_FAILURE ;
53
61
}
54
62
55
63
nr_strlcpy (& health_uuid [0 ], uuid , UUID_LEN + 1 );
56
64
65
+ nr_free (rand_uuid );
57
66
return NR_SUCCESS ;
58
67
}
59
68
69
+ char * nrh_get_uuid (void ) {
70
+ if (UUID_LEN != nr_strlen (health_uuid )) {
71
+ // handle edge case that uuid is not currently set
72
+ // or is set improperly
73
+ return NULL ;
74
+ }
75
+
76
+ return nr_strdup (health_uuid );
77
+ }
78
+
60
79
char * nrh_strip_scheme_prefix (char * uri ) {
61
80
char * filedir = NULL ;
62
81
int prefix_len = nr_strlen ("file://" );
Original file line number Diff line number Diff line change @@ -32,7 +32,6 @@ typedef enum _nrhealth_t {
32
32
/* utility */
33
33
extern char * nrh_strip_scheme_prefix (char * uri );
34
34
extern nr_status_t nrh_write_health (char * uri );
35
- extern char * nrh_generate_uuid (void );
36
35
37
36
/* getters */
38
37
extern char * nrh_get_health_location (char * uri );
@@ -41,6 +40,7 @@ extern char* nrh_get_health_filename(void);
41
40
extern long long nrh_get_start_time_ns (void );
42
41
extern long long nrh_get_current_time_ns (void );
43
42
extern nrhealth_t nrh_get_last_error (void );
43
+ extern char * nrh_get_uuid (void );
44
44
45
45
/* setters */
46
46
extern nr_status_t nrh_set_start_time (void );
You can’t perform that action at this time.
0 commit comments