aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/census/grpc_context.c2
-rw-r--r--src/core/census/initialize.c19
-rw-r--r--src/core/surface/init.c7
3 files changed, 18 insertions, 10 deletions
diff --git a/src/core/census/grpc_context.c b/src/core/census/grpc_context.c
index 0ed63469b6..d4243cb246 100644
--- a/src/core/census/grpc_context.c
+++ b/src/core/census/grpc_context.c
@@ -39,7 +39,7 @@ static void grpc_census_context_destroy(void *context) {
}
void grpc_census_call_set_context(grpc_call *call, census_context *context) {
- if (!census_available()) {
+ if (census_enabled() == CENSUS_FEATURE_NONE) {
return;
}
if (context == NULL) {
diff --git a/src/core/census/initialize.c b/src/core/census/initialize.c
index 8016520641..8d60f790eb 100644
--- a/src/core/census/initialize.c
+++ b/src/core/census/initialize.c
@@ -33,20 +33,25 @@
#include <grpc/census.h>
-static int census_fns_enabled = CENSUS_NONE;
+static int features_enabled = CENSUS_FEATURE_NONE;
-int census_initialize(int functions) {
- if (census_fns_enabled != CENSUS_NONE) {
+int census_initialize(int features) {
+ if (features_enabled != CENSUS_FEATURE_NONE) {
return 1;
}
- if (functions != CENSUS_NONE) {
+ if (features != CENSUS_FEATURE_NONE) {
return 1;
} else {
- census_fns_enabled = functions;
+ features_enabled = features;
return 0;
}
}
-void census_shutdown() { census_fns_enabled = CENSUS_NONE; }
+void census_shutdown(void) { features_enabled = CENSUS_FEATURE_NONE; }
-int census_available() { return (census_fns_enabled != CENSUS_NONE); }
+int census_supported(void) {
+ /* TODO(aveitch): improve this as we implement features... */
+ return CENSUS_FEATURE_NONE;
+}
+
+int census_enabled(void) { return features_enabled; }
diff --git a/src/core/surface/init.c b/src/core/surface/init.c
index a015262612..442bc72f21 100644
--- a/src/core/surface/init.c
+++ b/src/core/surface/init.c
@@ -80,8 +80,11 @@ void grpc_init(void) {
grpc_security_pre_init();
grpc_iomgr_init();
grpc_tracer_init("GRPC_TRACE");
- if (census_initialize(CENSUS_NONE)) {
- gpr_log(GPR_ERROR, "Could not initialize census.");
+ /* Only initialize census if noone else has. */
+ if (census_enabled() == CENSUS_FEATURE_NONE) {
+ if (census_initialize(census_supported())) { /* enable all features. */
+ gpr_log(GPR_ERROR, "Could not initialize census.");
+ }
}
grpc_timers_global_init();
}