aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Alistair Veitch <aveitch@google.com>2015-07-26 16:51:23 -0700
committerGravatar Alistair Veitch <aveitch@google.com>2015-07-26 16:51:23 -0700
commit925e4a634978ec0e8cd43fe2352a2c6240953f82 (patch)
treecdfc61deea867fb89d167a1206b76d57ab6607a2 /src/core
parent5c575dd6e4b01cd68cca5d1917b58023dcf4ca0f (diff)
Enrich census initialization and feature code
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 5cba479317..99fbde50c4 100644
--- a/src/core/surface/init.c
+++ b/src/core/surface/init.c
@@ -78,8 +78,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();
}