aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/debug/trace.c45
-rw-r--r--src/core/debug/trace.h1
-rw-r--r--src/core/surface/init.c1
3 files changed, 29 insertions, 18 deletions
diff --git a/src/core/debug/trace.c b/src/core/debug/trace.c
index 32c35e7fb3..b53dfe804b 100644
--- a/src/core/debug/trace.c
+++ b/src/core/debug/trace.c
@@ -35,6 +35,7 @@
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/support/env.h"
@@ -80,27 +81,10 @@ static void parse(const char *s) {
char **strings = NULL;
size_t nstrings = 0;
size_t i;
- tracer *t;
split(s, &strings, &nstrings);
for (i = 0; i < nstrings; i++) {
- const char *s = strings[i];
- if (0 == strcmp(s, "all")) {
- for (t = tracers; t; t = t->next) {
- *t->flag = 1;
- }
- } else {
- int found = 0;
- for (t = tracers; t; t = t->next) {
- if (0 == strcmp(s, t->name)) {
- *t->flag = 1;
- found = 1;
- }
- }
- if (!found) {
- gpr_log(GPR_ERROR, "Unknown trace var: '%s'", s);
- }
- }
+ grpc_tracer_set_enabled(strings[i], 1);
}
for (i = 0; i < nstrings; i++) {
@@ -115,9 +99,34 @@ void grpc_tracer_init(const char *env_var) {
parse(e);
gpr_free(e);
}
+}
+
+void grpc_tracer_shutdown(void) {
while (tracers) {
tracer *t = tracers;
tracers = t->next;
gpr_free(t);
}
}
+
+int grpc_tracer_set_enabled(const char *name, int enabled) {
+ tracer *t;
+ if (0 == strcmp(name, "all")) {
+ for (t = tracers; t; t = t->next) {
+ *t->flag = 1;
+ }
+ } else {
+ int found = 0;
+ for (t = tracers; t; t = t->next) {
+ if (0 == strcmp(name, t->name)) {
+ *t->flag = enabled;
+ found = 1;
+ }
+ }
+ if (!found) {
+ gpr_log(GPR_ERROR, "Unknown trace var: '%s'", name);
+ return 0; /* early return */
+ }
+ }
+ return 1;
+}
diff --git a/src/core/debug/trace.h b/src/core/debug/trace.h
index c02f14b7f2..fc8615bc69 100644
--- a/src/core/debug/trace.h
+++ b/src/core/debug/trace.h
@@ -38,5 +38,6 @@
void grpc_register_tracer(const char *name, int *flag);
void grpc_tracer_init(const char *env_var_name);
+void grpc_tracer_shutdown(void);
#endif /* GRPC_INTERNAL_CORE_DEBUG_TRACE_H */
diff --git a/src/core/surface/init.c b/src/core/surface/init.c
index ac6871c6f2..ca61a38a35 100644
--- a/src/core/surface/init.c
+++ b/src/core/surface/init.c
@@ -78,6 +78,7 @@ void grpc_shutdown(void) {
grpc_iomgr_shutdown();
census_shutdown();
grpc_timers_global_destroy();
+ grpc_tracer_shutdown();
}
gpr_mu_unlock(&g_init_mu);
}