Merge remote-tracking branch 'upstream/master' into filter_api

pull/6915/head
Mark D. Roth 8 years ago
commit 85c1168d17
  1. 3
      .gitignore
  2. 12
      BUILD
  3. 4
      CMakeLists.txt
  4. 40
      Makefile
  5. 2
      binding.gyp
  6. 14
      build.yaml
  7. 2
      config.m4
  8. 6
      gRPC-Core.podspec
  9. 11
      grpc.def
  10. 4
      grpc.gemspec
  11. 5
      include/grpc++/impl/codegen/core_codegen.h
  12. 136
      include/grpc/census.h
  13. 4
      package.xml
  14. 71
      src/core/ext/census/base_resources.c
  15. 39
      src/core/ext/census/base_resources.h
  16. 55
      src/core/ext/census/gen/census.pb.c
  17. 135
      src/core/ext/census/gen/census.pb.h
  18. 20
      src/core/ext/census/initialize.c
  19. 45
      src/core/ext/census/placeholders.c
  20. 312
      src/core/ext/census/resource.c
  21. 63
      src/core/ext/census/resource.h
  22. 4
      src/core/lib/security/transport/secure_endpoint.c
  23. 6
      src/core/lib/surface/call.c
  24. 22
      src/core/lib/transport/static_metadata.c
  25. 56
      src/core/lib/transport/static_metadata.h
  26. 107
      src/proto/census/census.proto
  27. 2
      src/python/grpcio/grpc_core_dependencies.py
  28. 22
      src/ruby/ext/grpc/rb_grpc_imports.generated.c
  29. 33
      src/ruby/ext/grpc/rb_grpc_imports.generated.h
  30. 7
      test/core/census/README
  31. 1
      test/core/census/data/resource_empty_name.pb
  32. 5
      test/core/census/data/resource_empty_name.txt
  33. 2
      test/core/census/data/resource_full.pb
  34. 9
      test/core/census/data/resource_full.txt
  35. 2
      test/core/census/data/resource_minimal_good.pb
  36. 5
      test/core/census/data/resource_minimal_good.txt
  37. 1
      test/core/census/data/resource_no_name.pb
  38. 4
      test/core/census/data/resource_no_name.txt
  39. 2
      test/core/census/data/resource_no_numerator.pb
  40. 6
      test/core/census/data/resource_no_numerator.txt
  41. 2
      test/core/census/data/resource_no_unit.pb
  42. 2
      test/core/census/data/resource_no_unit.txt
  43. 157
      test/core/census/resource_test.c
  44. 4
      test/core/end2end/fuzzers/hpack.dictionary
  45. 4
      test/cpp/qps/limit_cores.cc
  46. 4
      tools/codegen/core/gen_static_metadata.py
  47. 2
      tools/distrib/check_include_guards.py
  48. 4
      tools/doxygen/Doxyfile.core.internal
  49. 22
      tools/run_tests/sources_and_headers.json
  50. 21
      tools/run_tests/tests.json
  51. 27
      vsprojects/buildtests_c.sln
  52. 6
      vsprojects/vcxproj/grpc/grpc.vcxproj
  53. 12
      vsprojects/vcxproj/grpc/grpc.vcxproj.filters
  54. 6
      vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
  55. 12
      vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
  56. 199
      vsprojects/vcxproj/test/census_resource_test/census_resource_test.vcxproj
  57. 21
      vsprojects/vcxproj/test/census_resource_test/census_resource_test.vcxproj.filters

3
.gitignore vendored

@ -99,3 +99,6 @@ artifacts/
# Git generated files for conflicting # Git generated files for conflicting
*.orig *.orig
# IDE specific folder for JetBrains IDEs
.idea/

12
BUILD

@ -306,11 +306,13 @@ cc_library(
"src/core/ext/load_reporting/load_reporting.h", "src/core/ext/load_reporting/load_reporting.h",
"src/core/ext/load_reporting/load_reporting_filter.h", "src/core/ext/load_reporting/load_reporting_filter.h",
"src/core/ext/census/aggregation.h", "src/core/ext/census/aggregation.h",
"src/core/ext/census/base_resources.h",
"src/core/ext/census/census_interface.h", "src/core/ext/census/census_interface.h",
"src/core/ext/census/census_rpc_stats.h", "src/core/ext/census/census_rpc_stats.h",
"src/core/ext/census/gen/census.pb.h", "src/core/ext/census/gen/census.pb.h",
"src/core/ext/census/grpc_filter.h", "src/core/ext/census/grpc_filter.h",
"src/core/ext/census/mlog.h", "src/core/ext/census/mlog.h",
"src/core/ext/census/resource.h",
"src/core/ext/census/rpc_metric_id.h", "src/core/ext/census/rpc_metric_id.h",
"src/core/lib/surface/init.c", "src/core/lib/surface/init.c",
"src/core/lib/channel/channel_args.c", "src/core/lib/channel/channel_args.c",
@ -486,6 +488,7 @@ cc_library(
"src/core/ext/resolver/sockaddr/sockaddr_resolver.c", "src/core/ext/resolver/sockaddr/sockaddr_resolver.c",
"src/core/ext/load_reporting/load_reporting.c", "src/core/ext/load_reporting/load_reporting.c",
"src/core/ext/load_reporting/load_reporting_filter.c", "src/core/ext/load_reporting/load_reporting_filter.c",
"src/core/ext/census/base_resources.c",
"src/core/ext/census/context.c", "src/core/ext/census/context.c",
"src/core/ext/census/gen/census.pb.c", "src/core/ext/census/gen/census.pb.c",
"src/core/ext/census/grpc_context.c", "src/core/ext/census/grpc_context.c",
@ -495,6 +498,7 @@ cc_library(
"src/core/ext/census/mlog.c", "src/core/ext/census/mlog.c",
"src/core/ext/census/operation.c", "src/core/ext/census/operation.c",
"src/core/ext/census/placeholders.c", "src/core/ext/census/placeholders.c",
"src/core/ext/census/resource.c",
"src/core/ext/census/tracing.c", "src/core/ext/census/tracing.c",
"src/core/plugin_registry/grpc_plugin_registry.c", "src/core/plugin_registry/grpc_plugin_registry.c",
], ],
@ -1027,11 +1031,13 @@ cc_library(
"src/core/ext/lb_policy/grpclb/load_balancer_api.h", "src/core/ext/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h", "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h",
"src/core/ext/census/aggregation.h", "src/core/ext/census/aggregation.h",
"src/core/ext/census/base_resources.h",
"src/core/ext/census/census_interface.h", "src/core/ext/census/census_interface.h",
"src/core/ext/census/census_rpc_stats.h", "src/core/ext/census/census_rpc_stats.h",
"src/core/ext/census/gen/census.pb.h", "src/core/ext/census/gen/census.pb.h",
"src/core/ext/census/grpc_filter.h", "src/core/ext/census/grpc_filter.h",
"src/core/ext/census/mlog.h", "src/core/ext/census/mlog.h",
"src/core/ext/census/resource.h",
"src/core/ext/census/rpc_metric_id.h", "src/core/ext/census/rpc_metric_id.h",
"src/core/lib/surface/init.c", "src/core/lib/surface/init.c",
"src/core/lib/surface/init_unsecure.c", "src/core/lib/surface/init_unsecure.c",
@ -1178,6 +1184,7 @@ cc_library(
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c", "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
"src/core/ext/lb_policy/pick_first/pick_first.c", "src/core/ext/lb_policy/pick_first/pick_first.c",
"src/core/ext/lb_policy/round_robin/round_robin.c", "src/core/ext/lb_policy/round_robin/round_robin.c",
"src/core/ext/census/base_resources.c",
"src/core/ext/census/context.c", "src/core/ext/census/context.c",
"src/core/ext/census/gen/census.pb.c", "src/core/ext/census/gen/census.pb.c",
"src/core/ext/census/grpc_context.c", "src/core/ext/census/grpc_context.c",
@ -1187,6 +1194,7 @@ cc_library(
"src/core/ext/census/mlog.c", "src/core/ext/census/mlog.c",
"src/core/ext/census/operation.c", "src/core/ext/census/operation.c",
"src/core/ext/census/placeholders.c", "src/core/ext/census/placeholders.c",
"src/core/ext/census/resource.c",
"src/core/ext/census/tracing.c", "src/core/ext/census/tracing.c",
"src/core/plugin_registry/grpc_unsecure_plugin_registry.c", "src/core/plugin_registry/grpc_unsecure_plugin_registry.c",
], ],
@ -1973,6 +1981,7 @@ objc_library(
"src/core/ext/resolver/sockaddr/sockaddr_resolver.c", "src/core/ext/resolver/sockaddr/sockaddr_resolver.c",
"src/core/ext/load_reporting/load_reporting.c", "src/core/ext/load_reporting/load_reporting.c",
"src/core/ext/load_reporting/load_reporting_filter.c", "src/core/ext/load_reporting/load_reporting_filter.c",
"src/core/ext/census/base_resources.c",
"src/core/ext/census/context.c", "src/core/ext/census/context.c",
"src/core/ext/census/gen/census.pb.c", "src/core/ext/census/gen/census.pb.c",
"src/core/ext/census/grpc_context.c", "src/core/ext/census/grpc_context.c",
@ -1982,6 +1991,7 @@ objc_library(
"src/core/ext/census/mlog.c", "src/core/ext/census/mlog.c",
"src/core/ext/census/operation.c", "src/core/ext/census/operation.c",
"src/core/ext/census/placeholders.c", "src/core/ext/census/placeholders.c",
"src/core/ext/census/resource.c",
"src/core/ext/census/tracing.c", "src/core/ext/census/tracing.c",
"src/core/plugin_registry/grpc_plugin_registry.c", "src/core/plugin_registry/grpc_plugin_registry.c",
], ],
@ -2163,11 +2173,13 @@ objc_library(
"src/core/ext/load_reporting/load_reporting.h", "src/core/ext/load_reporting/load_reporting.h",
"src/core/ext/load_reporting/load_reporting_filter.h", "src/core/ext/load_reporting/load_reporting_filter.h",
"src/core/ext/census/aggregation.h", "src/core/ext/census/aggregation.h",
"src/core/ext/census/base_resources.h",
"src/core/ext/census/census_interface.h", "src/core/ext/census/census_interface.h",
"src/core/ext/census/census_rpc_stats.h", "src/core/ext/census/census_rpc_stats.h",
"src/core/ext/census/gen/census.pb.h", "src/core/ext/census/gen/census.pb.h",
"src/core/ext/census/grpc_filter.h", "src/core/ext/census/grpc_filter.h",
"src/core/ext/census/mlog.h", "src/core/ext/census/mlog.h",
"src/core/ext/census/resource.h",
"src/core/ext/census/rpc_metric_id.h", "src/core/ext/census/rpc_metric_id.h",
], ],
includes = [ includes = [

@ -454,6 +454,7 @@ add_library(grpc
src/core/ext/resolver/sockaddr/sockaddr_resolver.c src/core/ext/resolver/sockaddr/sockaddr_resolver.c
src/core/ext/load_reporting/load_reporting.c src/core/ext/load_reporting/load_reporting.c
src/core/ext/load_reporting/load_reporting_filter.c src/core/ext/load_reporting/load_reporting_filter.c
src/core/ext/census/base_resources.c
src/core/ext/census/context.c src/core/ext/census/context.c
src/core/ext/census/gen/census.pb.c src/core/ext/census/gen/census.pb.c
src/core/ext/census/grpc_context.c src/core/ext/census/grpc_context.c
@ -463,6 +464,7 @@ add_library(grpc
src/core/ext/census/mlog.c src/core/ext/census/mlog.c
src/core/ext/census/operation.c src/core/ext/census/operation.c
src/core/ext/census/placeholders.c src/core/ext/census/placeholders.c
src/core/ext/census/resource.c
src/core/ext/census/tracing.c src/core/ext/census/tracing.c
src/core/plugin_registry/grpc_plugin_registry.c src/core/plugin_registry/grpc_plugin_registry.c
) )
@ -908,6 +910,7 @@ add_library(grpc_unsecure
third_party/nanopb/pb_encode.c third_party/nanopb/pb_encode.c
src/core/ext/lb_policy/pick_first/pick_first.c src/core/ext/lb_policy/pick_first/pick_first.c
src/core/ext/lb_policy/round_robin/round_robin.c src/core/ext/lb_policy/round_robin/round_robin.c
src/core/ext/census/base_resources.c
src/core/ext/census/context.c src/core/ext/census/context.c
src/core/ext/census/gen/census.pb.c src/core/ext/census/gen/census.pb.c
src/core/ext/census/grpc_context.c src/core/ext/census/grpc_context.c
@ -917,6 +920,7 @@ add_library(grpc_unsecure
src/core/ext/census/mlog.c src/core/ext/census/mlog.c
src/core/ext/census/operation.c src/core/ext/census/operation.c
src/core/ext/census/placeholders.c src/core/ext/census/placeholders.c
src/core/ext/census/resource.c
src/core/ext/census/tracing.c src/core/ext/census/tracing.c
src/core/plugin_registry/grpc_unsecure_plugin_registry.c src/core/plugin_registry/grpc_unsecure_plugin_registry.c
) )

@ -915,6 +915,7 @@ bad_server_response_test: $(BINDIR)/$(CONFIG)/bad_server_response_test
bin_decoder_test: $(BINDIR)/$(CONFIG)/bin_decoder_test bin_decoder_test: $(BINDIR)/$(CONFIG)/bin_decoder_test
bin_encoder_test: $(BINDIR)/$(CONFIG)/bin_encoder_test bin_encoder_test: $(BINDIR)/$(CONFIG)/bin_encoder_test
census_context_test: $(BINDIR)/$(CONFIG)/census_context_test census_context_test: $(BINDIR)/$(CONFIG)/census_context_test
census_resource_test: $(BINDIR)/$(CONFIG)/census_resource_test
channel_create_test: $(BINDIR)/$(CONFIG)/channel_create_test channel_create_test: $(BINDIR)/$(CONFIG)/channel_create_test
chttp2_hpack_encoder_test: $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test chttp2_hpack_encoder_test: $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test
chttp2_status_conversion_test: $(BINDIR)/$(CONFIG)/chttp2_status_conversion_test chttp2_status_conversion_test: $(BINDIR)/$(CONFIG)/chttp2_status_conversion_test
@ -1235,6 +1236,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/bin_decoder_test \ $(BINDIR)/$(CONFIG)/bin_decoder_test \
$(BINDIR)/$(CONFIG)/bin_encoder_test \ $(BINDIR)/$(CONFIG)/bin_encoder_test \
$(BINDIR)/$(CONFIG)/census_context_test \ $(BINDIR)/$(CONFIG)/census_context_test \
$(BINDIR)/$(CONFIG)/census_resource_test \
$(BINDIR)/$(CONFIG)/channel_create_test \ $(BINDIR)/$(CONFIG)/channel_create_test \
$(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test \ $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test \
$(BINDIR)/$(CONFIG)/chttp2_status_conversion_test \ $(BINDIR)/$(CONFIG)/chttp2_status_conversion_test \
@ -1542,6 +1544,8 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/bin_encoder_test || ( echo test bin_encoder_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/bin_encoder_test || ( echo test bin_encoder_test failed ; exit 1 )
$(E) "[RUN] Testing census_context_test" $(E) "[RUN] Testing census_context_test"
$(Q) $(BINDIR)/$(CONFIG)/census_context_test || ( echo test census_context_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/census_context_test || ( echo test census_context_test failed ; exit 1 )
$(E) "[RUN] Testing census_resource_test"
$(Q) $(BINDIR)/$(CONFIG)/census_resource_test || ( echo test census_resource_test failed ; exit 1 )
$(E) "[RUN] Testing channel_create_test" $(E) "[RUN] Testing channel_create_test"
$(Q) $(BINDIR)/$(CONFIG)/channel_create_test || ( echo test channel_create_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/channel_create_test || ( echo test channel_create_test failed ; exit 1 )
$(E) "[RUN] Testing chttp2_hpack_encoder_test" $(E) "[RUN] Testing chttp2_hpack_encoder_test"
@ -2703,6 +2707,7 @@ LIBGRPC_SRC = \
src/core/ext/resolver/sockaddr/sockaddr_resolver.c \ src/core/ext/resolver/sockaddr/sockaddr_resolver.c \
src/core/ext/load_reporting/load_reporting.c \ src/core/ext/load_reporting/load_reporting.c \
src/core/ext/load_reporting/load_reporting_filter.c \ src/core/ext/load_reporting/load_reporting_filter.c \
src/core/ext/census/base_resources.c \
src/core/ext/census/context.c \ src/core/ext/census/context.c \
src/core/ext/census/gen/census.pb.c \ src/core/ext/census/gen/census.pb.c \
src/core/ext/census/grpc_context.c \ src/core/ext/census/grpc_context.c \
@ -2712,6 +2717,7 @@ LIBGRPC_SRC = \
src/core/ext/census/mlog.c \ src/core/ext/census/mlog.c \
src/core/ext/census/operation.c \ src/core/ext/census/operation.c \
src/core/ext/census/placeholders.c \ src/core/ext/census/placeholders.c \
src/core/ext/census/resource.c \
src/core/ext/census/tracing.c \ src/core/ext/census/tracing.c \
src/core/plugin_registry/grpc_plugin_registry.c \ src/core/plugin_registry/grpc_plugin_registry.c \
@ -3404,6 +3410,7 @@ LIBGRPC_UNSECURE_SRC = \
third_party/nanopb/pb_encode.c \ third_party/nanopb/pb_encode.c \
src/core/ext/lb_policy/pick_first/pick_first.c \ src/core/ext/lb_policy/pick_first/pick_first.c \
src/core/ext/lb_policy/round_robin/round_robin.c \ src/core/ext/lb_policy/round_robin/round_robin.c \
src/core/ext/census/base_resources.c \
src/core/ext/census/context.c \ src/core/ext/census/context.c \
src/core/ext/census/gen/census.pb.c \ src/core/ext/census/gen/census.pb.c \
src/core/ext/census/grpc_context.c \ src/core/ext/census/grpc_context.c \
@ -3413,6 +3420,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/ext/census/mlog.c \ src/core/ext/census/mlog.c \
src/core/ext/census/operation.c \ src/core/ext/census/operation.c \
src/core/ext/census/placeholders.c \ src/core/ext/census/placeholders.c \
src/core/ext/census/resource.c \
src/core/ext/census/tracing.c \ src/core/ext/census/tracing.c \
src/core/plugin_registry/grpc_unsecure_plugin_registry.c \ src/core/plugin_registry/grpc_unsecure_plugin_registry.c \
@ -6948,6 +6956,38 @@ endif
endif endif
CENSUS_RESOURCE_TEST_SRC = \
test/core/census/resource_test.c \
CENSUS_RESOURCE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CENSUS_RESOURCE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/census_resource_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/census_resource_test: $(CENSUS_RESOURCE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(CENSUS_RESOURCE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/census_resource_test
endif
$(OBJDIR)/$(CONFIG)/test/core/census/resource_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_census_resource_test: $(CENSUS_RESOURCE_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(CENSUS_RESOURCE_TEST_OBJS:.o=.dep)
endif
endif
CHANNEL_CREATE_TEST_SRC = \ CHANNEL_CREATE_TEST_SRC = \
test/core/surface/channel_create_test.c \ test/core/surface/channel_create_test.c \

@ -739,6 +739,7 @@
'src/core/ext/resolver/sockaddr/sockaddr_resolver.c', 'src/core/ext/resolver/sockaddr/sockaddr_resolver.c',
'src/core/ext/load_reporting/load_reporting.c', 'src/core/ext/load_reporting/load_reporting.c',
'src/core/ext/load_reporting/load_reporting_filter.c', 'src/core/ext/load_reporting/load_reporting_filter.c',
'src/core/ext/census/base_resources.c',
'src/core/ext/census/context.c', 'src/core/ext/census/context.c',
'src/core/ext/census/gen/census.pb.c', 'src/core/ext/census/gen/census.pb.c',
'src/core/ext/census/grpc_context.c', 'src/core/ext/census/grpc_context.c',
@ -748,6 +749,7 @@
'src/core/ext/census/mlog.c', 'src/core/ext/census/mlog.c',
'src/core/ext/census/operation.c', 'src/core/ext/census/operation.c',
'src/core/ext/census/placeholders.c', 'src/core/ext/census/placeholders.c',
'src/core/ext/census/resource.c',
'src/core/ext/census/tracing.c', 'src/core/ext/census/tracing.c',
'src/core/plugin_registry/grpc_plugin_registry.c', 'src/core/plugin_registry/grpc_plugin_registry.c',
], ],

@ -14,13 +14,16 @@ filegroups:
- include/grpc/census.h - include/grpc/census.h
headers: headers:
- src/core/ext/census/aggregation.h - src/core/ext/census/aggregation.h
- src/core/ext/census/base_resources.h
- src/core/ext/census/census_interface.h - src/core/ext/census/census_interface.h
- src/core/ext/census/census_rpc_stats.h - src/core/ext/census/census_rpc_stats.h
- src/core/ext/census/gen/census.pb.h - src/core/ext/census/gen/census.pb.h
- src/core/ext/census/grpc_filter.h - src/core/ext/census/grpc_filter.h
- src/core/ext/census/mlog.h - src/core/ext/census/mlog.h
- src/core/ext/census/resource.h
- src/core/ext/census/rpc_metric_id.h - src/core/ext/census/rpc_metric_id.h
src: src:
- src/core/ext/census/base_resources.c
- src/core/ext/census/context.c - src/core/ext/census/context.c
- src/core/ext/census/gen/census.pb.c - src/core/ext/census/gen/census.pb.c
- src/core/ext/census/grpc_context.c - src/core/ext/census/grpc_context.c
@ -30,6 +33,7 @@ filegroups:
- src/core/ext/census/mlog.c - src/core/ext/census/mlog.c
- src/core/ext/census/operation.c - src/core/ext/census/operation.c
- src/core/ext/census/placeholders.c - src/core/ext/census/placeholders.c
- src/core/ext/census/resource.c
- src/core/ext/census/tracing.c - src/core/ext/census/tracing.c
plugin: census_grpc_plugin plugin: census_grpc_plugin
uses: uses:
@ -1303,6 +1307,16 @@ targets:
- grpc - grpc
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: census_resource_test
build: test
language: c
src:
- test/core/census/resource_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: channel_create_test - name: channel_create_test
build: test build: test
language: c language: c

@ -258,6 +258,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/resolver/sockaddr/sockaddr_resolver.c \ src/core/ext/resolver/sockaddr/sockaddr_resolver.c \
src/core/ext/load_reporting/load_reporting.c \ src/core/ext/load_reporting/load_reporting.c \
src/core/ext/load_reporting/load_reporting_filter.c \ src/core/ext/load_reporting/load_reporting_filter.c \
src/core/ext/census/base_resources.c \
src/core/ext/census/context.c \ src/core/ext/census/context.c \
src/core/ext/census/gen/census.pb.c \ src/core/ext/census/gen/census.pb.c \
src/core/ext/census/grpc_context.c \ src/core/ext/census/grpc_context.c \
@ -267,6 +268,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/census/mlog.c \ src/core/ext/census/mlog.c \
src/core/ext/census/operation.c \ src/core/ext/census/operation.c \
src/core/ext/census/placeholders.c \ src/core/ext/census/placeholders.c \
src/core/ext/census/resource.c \
src/core/ext/census/tracing.c \ src/core/ext/census/tracing.c \
src/core/plugin_registry/grpc_plugin_registry.c \ src/core/plugin_registry/grpc_plugin_registry.c \
src/boringssl/err_data.c \ src/boringssl/err_data.c \

@ -403,11 +403,13 @@ Pod::Spec.new do |s|
'src/core/ext/load_reporting/load_reporting.h', 'src/core/ext/load_reporting/load_reporting.h',
'src/core/ext/load_reporting/load_reporting_filter.h', 'src/core/ext/load_reporting/load_reporting_filter.h',
'src/core/ext/census/aggregation.h', 'src/core/ext/census/aggregation.h',
'src/core/ext/census/base_resources.h',
'src/core/ext/census/census_interface.h', 'src/core/ext/census/census_interface.h',
'src/core/ext/census/census_rpc_stats.h', 'src/core/ext/census/census_rpc_stats.h',
'src/core/ext/census/gen/census.pb.h', 'src/core/ext/census/gen/census.pb.h',
'src/core/ext/census/grpc_filter.h', 'src/core/ext/census/grpc_filter.h',
'src/core/ext/census/mlog.h', 'src/core/ext/census/mlog.h',
'src/core/ext/census/resource.h',
'src/core/ext/census/rpc_metric_id.h', 'src/core/ext/census/rpc_metric_id.h',
'src/core/lib/surface/init.c', 'src/core/lib/surface/init.c',
'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_args.c',
@ -586,6 +588,7 @@ Pod::Spec.new do |s|
'src/core/ext/resolver/sockaddr/sockaddr_resolver.c', 'src/core/ext/resolver/sockaddr/sockaddr_resolver.c',
'src/core/ext/load_reporting/load_reporting.c', 'src/core/ext/load_reporting/load_reporting.c',
'src/core/ext/load_reporting/load_reporting_filter.c', 'src/core/ext/load_reporting/load_reporting_filter.c',
'src/core/ext/census/base_resources.c',
'src/core/ext/census/context.c', 'src/core/ext/census/context.c',
'src/core/ext/census/gen/census.pb.c', 'src/core/ext/census/gen/census.pb.c',
'src/core/ext/census/grpc_context.c', 'src/core/ext/census/grpc_context.c',
@ -595,6 +598,7 @@ Pod::Spec.new do |s|
'src/core/ext/census/mlog.c', 'src/core/ext/census/mlog.c',
'src/core/ext/census/operation.c', 'src/core/ext/census/operation.c',
'src/core/ext/census/placeholders.c', 'src/core/ext/census/placeholders.c',
'src/core/ext/census/resource.c',
'src/core/ext/census/tracing.c', 'src/core/ext/census/tracing.c',
'src/core/plugin_registry/grpc_plugin_registry.c' 'src/core/plugin_registry/grpc_plugin_registry.c'
@ -760,11 +764,13 @@ Pod::Spec.new do |s|
'src/core/ext/load_reporting/load_reporting.h', 'src/core/ext/load_reporting/load_reporting.h',
'src/core/ext/load_reporting/load_reporting_filter.h', 'src/core/ext/load_reporting/load_reporting_filter.h',
'src/core/ext/census/aggregation.h', 'src/core/ext/census/aggregation.h',
'src/core/ext/census/base_resources.h',
'src/core/ext/census/census_interface.h', 'src/core/ext/census/census_interface.h',
'src/core/ext/census/census_rpc_stats.h', 'src/core/ext/census/census_rpc_stats.h',
'src/core/ext/census/gen/census.pb.h', 'src/core/ext/census/gen/census.pb.h',
'src/core/ext/census/grpc_filter.h', 'src/core/ext/census/grpc_filter.h',
'src/core/ext/census/mlog.h', 'src/core/ext/census/mlog.h',
'src/core/ext/census/resource.h',
'src/core/ext/census/rpc_metric_id.h' 'src/core/ext/census/rpc_metric_id.h'
end end

@ -23,15 +23,10 @@ EXPORTS
census_trace_scan_start census_trace_scan_start
census_get_trace_record census_get_trace_record
census_trace_scan_end census_trace_scan_end
census_define_resource
census_delete_resource
census_resource_id
census_record_values census_record_values
census_view_create
census_view_delete
census_view_metric
census_view_naggregations
census_view_tags
census_view_aggregrations
census_view_get_data
census_view_reset
grpc_compression_algorithm_parse grpc_compression_algorithm_parse
grpc_compression_algorithm_name grpc_compression_algorithm_name
grpc_compression_algorithm_for_level grpc_compression_algorithm_for_level

@ -322,11 +322,13 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/load_reporting/load_reporting.h ) s.files += %w( src/core/ext/load_reporting/load_reporting.h )
s.files += %w( src/core/ext/load_reporting/load_reporting_filter.h ) s.files += %w( src/core/ext/load_reporting/load_reporting_filter.h )
s.files += %w( src/core/ext/census/aggregation.h ) s.files += %w( src/core/ext/census/aggregation.h )
s.files += %w( src/core/ext/census/base_resources.h )
s.files += %w( src/core/ext/census/census_interface.h ) s.files += %w( src/core/ext/census/census_interface.h )
s.files += %w( src/core/ext/census/census_rpc_stats.h ) s.files += %w( src/core/ext/census/census_rpc_stats.h )
s.files += %w( src/core/ext/census/gen/census.pb.h ) s.files += %w( src/core/ext/census/gen/census.pb.h )
s.files += %w( src/core/ext/census/grpc_filter.h ) s.files += %w( src/core/ext/census/grpc_filter.h )
s.files += %w( src/core/ext/census/mlog.h ) s.files += %w( src/core/ext/census/mlog.h )
s.files += %w( src/core/ext/census/resource.h )
s.files += %w( src/core/ext/census/rpc_metric_id.h ) s.files += %w( src/core/ext/census/rpc_metric_id.h )
s.files += %w( src/core/lib/surface/init.c ) s.files += %w( src/core/lib/surface/init.c )
s.files += %w( src/core/lib/channel/channel_args.c ) s.files += %w( src/core/lib/channel/channel_args.c )
@ -505,6 +507,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/resolver/sockaddr/sockaddr_resolver.c ) s.files += %w( src/core/ext/resolver/sockaddr/sockaddr_resolver.c )
s.files += %w( src/core/ext/load_reporting/load_reporting.c ) s.files += %w( src/core/ext/load_reporting/load_reporting.c )
s.files += %w( src/core/ext/load_reporting/load_reporting_filter.c ) s.files += %w( src/core/ext/load_reporting/load_reporting_filter.c )
s.files += %w( src/core/ext/census/base_resources.c )
s.files += %w( src/core/ext/census/context.c ) s.files += %w( src/core/ext/census/context.c )
s.files += %w( src/core/ext/census/gen/census.pb.c ) s.files += %w( src/core/ext/census/gen/census.pb.c )
s.files += %w( src/core/ext/census/grpc_context.c ) s.files += %w( src/core/ext/census/grpc_context.c )
@ -514,6 +517,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/census/mlog.c ) s.files += %w( src/core/ext/census/mlog.c )
s.files += %w( src/core/ext/census/operation.c ) s.files += %w( src/core/ext/census/operation.c )
s.files += %w( src/core/ext/census/placeholders.c ) s.files += %w( src/core/ext/census/placeholders.c )
s.files += %w( src/core/ext/census/resource.c )
s.files += %w( src/core/ext/census/tracing.c ) s.files += %w( src/core/ext/census/tracing.c )
s.files += %w( src/core/plugin_registry/grpc_plugin_registry.c ) s.files += %w( src/core/plugin_registry/grpc_plugin_registry.c )
s.files += %w( third_party/boringssl/crypto/aes/internal.h ) s.files += %w( third_party/boringssl/crypto/aes/internal.h )

@ -31,6 +31,9 @@
* *
*/ */
#ifndef GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H
#define GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H
// This file should be compiled as part of grpc++. // This file should be compiled as part of grpc++.
#include <grpc++/impl/codegen/core_codegen_interface.h> #include <grpc++/impl/codegen/core_codegen_interface.h>
@ -83,3 +86,5 @@ class CoreCodegen : public CoreCodegenInterface {
}; };
} // namespace grpc } // namespace grpc
#endif // GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -56,9 +56,11 @@ enum census_features {
/** Shutdown and startup census subsystem. The 'features' argument should be /** Shutdown and startup census subsystem. The 'features' argument should be
* the OR (|) of census_features values. If census fails to initialize, then * the OR (|) of census_features values. If census fails to initialize, then
* census_initialize() will return a non-zero value. It is an error to call * census_initialize() will return -1, otherwise the set of enabled features
* census_initialize() more than once (without an intervening * (which may be smaller than that provided in the `features` argument, see
* census_shutdown()). */ * census_supported()) is returned. It is an error to call census_initialize()
* more than once (without an intervening census_shutdown()). These functions
* are not thread-safe. */
CENSUSAPI int census_initialize(int features); CENSUSAPI int census_initialize(int features);
CENSUSAPI void census_shutdown(void); CENSUSAPI void census_shutdown(void);
@ -430,30 +432,44 @@ CENSUSAPI int census_get_trace_record(census_trace_record *trace_record);
CENSUSAPI void census_trace_scan_end(); CENSUSAPI void census_trace_scan_end();
/* Core stats collection API's. The following concepts are used: /* Core stats collection API's. The following concepts are used:
* Aggregation: A collection of values. Census supports the following * Resource: Users record measurements for a single resource. Examples
aggregation types: include RPC latency, CPU seconds consumed, and bytes transmitted.
Sum - a single summation type. Typically used for keeping (e.g.) * Aggregation: An aggregation of a set of measurements. Census supports the
counts of events. following aggregation types:
Distribution - statistical distribution information, used for * Distribution - statistical distribution information, used for
recording average, standard deviation etc. recording average, standard deviation etc. Can include a histogram.
Histogram - a histogram of measurements falling in defined bucket * Interval - a count of events that happen in a rolling time window.
boundaries. * View: A view is a combination of a Resource, a set of tag keys and an
Window - a count of events that happen in reolling time window. Aggregation. When a measurement for a Resource matches the View tags, it is
New aggregation types can be added by the user, if desired (see recorded (for each unique set of tag values) using the Aggregation type.
census_register_aggregation()). Each resource can have an arbitrary number of views by which it will be
* Metric: Each measurement is for a single metric. Examples include RPC broken down.
latency, CPU seconds consumed, and bytes transmitted.
* View: A view is a combination of a metric, a tag set (in which the tag Census uses protos to define each of the above, and output results. This
values are regular expressions) and a set of aggregations. When a ensures unification across the different language and runtime
measurement for a metric matches the view tags, it is recorded (for each implementations. The proto definitions can be found in src/proto/census.
unique set of tags) against each aggregation. Each metric can have an
arbitrary number of views by which it will be broken down.
*/ */
/* Define a new resource. `resource_pb` should contain an encoded Resource
protobuf, `resource_pb_size` being the size of the buffer. Returns a -ve
value on error, or a positive (>= 0) resource id (for use in
census_delete_resource() and census_record_values()). In order to be valid, a
resource must have a name, and at least one numerator in it's unit type. The
resource name must be unique, and an error will be returned if it is not. */
CENSUSAPI int32_t census_define_resource(const uint8_t *resource_pb,
size_t resource_pb_size);
/* Delete a resource created by census_define_resource(). */
CENSUSAPI void census_delete_resource(int32_t resource_id);
/* Determine the id of a resource, given it's name. returns -1 if the resource
does not exist. */
CENSUSAPI int32_t census_resource_id(const char *name);
/* A single value to be recorded comprises two parts: an ID for the particular /* A single value to be recorded comprises two parts: an ID for the particular
* metric and the value to be recorded against it. */ * resource and the value to be recorded against it. */
typedef struct { typedef struct {
uint32_t metric_id; int32_t resource_id;
double value; double value;
} census_value; } census_value;
@ -461,78 +477,6 @@ typedef struct {
CENSUSAPI void census_record_values(census_context *context, CENSUSAPI void census_record_values(census_context *context,
census_value *values, size_t nvalues); census_value *values, size_t nvalues);
/** Type representing a particular aggregation */
typedef struct census_aggregation_ops census_aggregation_ops;
/* Predefined aggregation types, for use with census_view_create(). */
extern census_aggregation_ops census_agg_sum;
extern census_aggregation_ops census_agg_distribution;
extern census_aggregation_ops census_agg_histogram;
extern census_aggregation_ops census_agg_window;
/** Information needed to instantiate a new aggregation. Used in view
construction via census_define_view(). */
typedef struct {
const census_aggregation_ops *ops;
const void *create_arg; /* Aaggregation initialization argument. */
} census_aggregation;
/** A census view type. Opaque. */
typedef struct census_view census_view;
/** Create a new view.
@param metric_id Metric with which this view is associated.
@param tags tags that define the view.
@param aggregations aggregations to associate with the view
@param naggregations number of aggregations
@return A new census view
*/
/* TODO(aveitch): consider if context is the right argument type to pass in
tags. */
CENSUSAPI census_view *census_view_create(
uint32_t metric_id, const census_context *tags,
const census_aggregation *aggregations, size_t naggregations);
/** Destroy a previously created view. */
CENSUSAPI void census_view_delete(census_view *view);
/** Metric ID associated with a view */
CENSUSAPI size_t census_view_metric(const census_view *view);
/** Number of aggregations associated with view. */
CENSUSAPI size_t census_view_naggregations(const census_view *view);
/** Get tags associated with view. */
CENSUSAPI const census_context *census_view_tags(const census_view *view);
/** Get aggregation descriptors associated with a view. */
CENSUSAPI const census_aggregation *census_view_aggregrations(
const census_view *view);
/** Holds all the aggregation data for a particular view instantiation. Forms
part of the data returned by census_view_data(). */
typedef struct {
const census_context *tags; /* Tags for this set of aggregations. */
const void **data; /* One data set for every aggregation in the view. */
} census_view_aggregation_data;
/** Census view data as returned by census_view_get_data(). */
typedef struct {
size_t n_tag_sets; /* Number of unique tag sets that matched view. */
const census_view_aggregation_data *data; /* n_tag_sets entries */
} census_view_data;
/** Get data from aggregations associated with a view.
@param view View from which to get data.
@return Full set of data for all aggregations for the view.
*/
CENSUSAPI const census_view_data *census_view_get_data(const census_view *view);
/** Reset all view data to zero for the specified view */
CENSUSAPI void census_view_reset(census_view *view);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

@ -330,11 +330,13 @@
<file baseinstalldir="/" name="src/core/ext/load_reporting/load_reporting.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/load_reporting/load_reporting.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/load_reporting/load_reporting_filter.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/load_reporting/load_reporting_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/aggregation.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/aggregation.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/base_resources.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/census_interface.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/census_interface.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/census_rpc_stats.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/census_rpc_stats.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/gen/census.pb.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/gen/census.pb.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/grpc_filter.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/grpc_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/mlog.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/mlog.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/resource.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/rpc_metric_id.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/rpc_metric_id.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/init.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/surface/init.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_args.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/channel/channel_args.c" role="src" />
@ -513,6 +515,7 @@
<file baseinstalldir="/" name="src/core/ext/resolver/sockaddr/sockaddr_resolver.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/resolver/sockaddr/sockaddr_resolver.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/load_reporting/load_reporting.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/load_reporting/load_reporting.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/load_reporting/load_reporting_filter.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/load_reporting/load_reporting_filter.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/base_resources.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/context.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/context.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/gen/census.pb.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/gen/census.pb.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/grpc_context.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/grpc_context.c" role="src" />
@ -522,6 +525,7 @@
<file baseinstalldir="/" name="src/core/ext/census/mlog.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/mlog.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/operation.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/operation.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/placeholders.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/placeholders.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/resource.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/census/tracing.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/census/tracing.c" role="src" />
<file baseinstalldir="/" name="src/core/plugin_registry/grpc_plugin_registry.c" role="src" /> <file baseinstalldir="/" name="src/core/plugin_registry/grpc_plugin_registry.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/aes/internal.h" role="src" /> <file baseinstalldir="/" name="third_party/boringssl/crypto/aes/internal.h" role="src" />

@ -0,0 +1,71 @@
/*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/ext/census/base_resources.h"
#include <stdio.h>
#include <string.h>
#include <grpc/census.h>
#include <grpc/support/log.h>
#include "src/core/ext/census/resource.h"
// Add base RPC resource definitions for use by RPC runtime.
//
// TODO(aveitch): All of these are currently hardwired definitions encoded in
// the code in this file. These should be converted to use an external
// configuration mechanism, in which these resources are defined in a text
// file, which is compiled to .pb format and read by still-to-be-written
// configuration functions.
// Define all base resources. This should be called by census initialization.
void define_base_resources() {
google_census_Resource_BasicUnit numerator =
google_census_Resource_BasicUnit_SECS;
resource r = {"client_rpc_latency", // name
"Client RPC latency in seconds", // description
0, // prefix
1, // n_numerators
&numerator, // numerators
0, // n_denominators
NULL}; // denominators
define_resource(&r);
r = (resource){"server_rpc_latency", // name
"Server RPC latency in seconds", // description
0, // prefix
1, // n_numerators
&numerator, // numerators
0, // n_denominators
NULL}; // denominators
define_resource(&r);
}

@ -0,0 +1,39 @@
/*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H
#define GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H
/* Define all base resources. This should be called by census initialization. */
void define_base_resources();
#endif /* GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H */

@ -53,29 +53,24 @@ const pb_field_t google_census_Timestamp_fields[3] = {
PB_LAST_FIELD PB_LAST_FIELD
}; };
const pb_field_t google_census_Metric_fields[5] = { const pb_field_t google_census_Resource_fields[4] = {
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Metric, name, name, 0), PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Resource, name, name, 0),
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Metric, description, name, 0), PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Resource, description, name, 0),
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Metric, unit, description, &google_census_Metric_MeasurementUnit_fields), PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Resource, unit, description, &google_census_Resource_MeasurementUnit_fields),
PB_FIELD( 4, INT32 , OPTIONAL, STATIC , OTHER, google_census_Metric, id, unit, 0),
PB_LAST_FIELD PB_LAST_FIELD
}; };
const pb_field_t google_census_Metric_BasicUnit_fields[2] = { const pb_field_t google_census_Resource_MeasurementUnit_fields[4] = {
PB_FIELD( 1, UENUM , OPTIONAL, STATIC , FIRST, google_census_Metric_BasicUnit, type, type, 0), PB_FIELD( 1, INT32 , OPTIONAL, STATIC , FIRST, google_census_Resource_MeasurementUnit, prefix, prefix, 0),
PB_FIELD( 2, UENUM , REPEATED, CALLBACK, OTHER, google_census_Resource_MeasurementUnit, numerator, prefix, 0),
PB_FIELD( 3, UENUM , REPEATED, CALLBACK, OTHER, google_census_Resource_MeasurementUnit, denominator, numerator, 0),
PB_LAST_FIELD PB_LAST_FIELD
}; };
const pb_field_t google_census_Metric_MeasurementUnit_fields[4] = { const pb_field_t google_census_AggregationDescriptor_fields[4] = {
PB_FIELD( 1, INT32 , OPTIONAL, STATIC , FIRST, google_census_Metric_MeasurementUnit, prefix, prefix, 0), PB_FIELD( 1, UENUM , OPTIONAL, STATIC , FIRST, google_census_AggregationDescriptor, type, type, 0),
PB_FIELD( 2, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Metric_MeasurementUnit, numerator, prefix, &google_census_Metric_BasicUnit_fields), PB_ONEOF_FIELD(options, 2, MESSAGE , ONEOF, STATIC , OTHER, google_census_AggregationDescriptor, bucket_boundaries, type, &google_census_AggregationDescriptor_BucketBoundaries_fields),
PB_FIELD( 3, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Metric_MeasurementUnit, denominator, numerator, &google_census_Metric_BasicUnit_fields), PB_ONEOF_FIELD(options, 3, MESSAGE , ONEOF, STATIC , OTHER, google_census_AggregationDescriptor, interval_boundaries, type, &google_census_AggregationDescriptor_IntervalBoundaries_fields),
PB_LAST_FIELD
};
const pb_field_t google_census_AggregationDescriptor_fields[3] = {
PB_ONEOF_FIELD(options, 1, MESSAGE , ONEOF, STATIC , FIRST, google_census_AggregationDescriptor, bucket_boundaries, bucket_boundaries, &google_census_AggregationDescriptor_BucketBoundaries_fields),
PB_ONEOF_FIELD(options, 2, MESSAGE , ONEOF, STATIC , FIRST, google_census_AggregationDescriptor, interval_boundaries, interval_boundaries, &google_census_AggregationDescriptor_IntervalBoundaries_fields),
PB_LAST_FIELD PB_LAST_FIELD
}; };
@ -124,25 +119,27 @@ const pb_field_t google_census_Tag_fields[3] = {
const pb_field_t google_census_View_fields[6] = { const pb_field_t google_census_View_fields[6] = {
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_View, name, name, 0), PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_View, name, name, 0),
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_View, description, name, 0), PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_View, description, name, 0),
PB_FIELD( 3, INT32 , OPTIONAL, STATIC , OTHER, google_census_View, metric_id, description, 0), PB_FIELD( 3, STRING , OPTIONAL, CALLBACK, OTHER, google_census_View, resource_name, description, 0),
PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_View, aggregation, metric_id, &google_census_AggregationDescriptor_fields), PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_View, aggregation, resource_name, &google_census_AggregationDescriptor_fields),
PB_FIELD( 5, STRING , REPEATED, CALLBACK, OTHER, google_census_View, tag_key, aggregation, 0), PB_FIELD( 5, STRING , REPEATED, CALLBACK, OTHER, google_census_View, tag_key, aggregation, 0),
PB_LAST_FIELD PB_LAST_FIELD
}; };
const pb_field_t google_census_Aggregation_fields[6] = { const pb_field_t google_census_Aggregation_fields[7] = {
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Aggregation, name, name, 0), PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Aggregation, name, name, 0),
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Aggregation, description, name, 0), PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Aggregation, description, name, 0),
PB_ONEOF_FIELD(data, 3, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, distribution, description, &google_census_Distribution_fields), PB_ONEOF_FIELD(data, 3, UINT64 , ONEOF, STATIC , OTHER, google_census_Aggregation, count, description, 0),
PB_ONEOF_FIELD(data, 4, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, interval_stats, description, &google_census_IntervalStats_fields), PB_ONEOF_FIELD(data, 4, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, distribution, description, &google_census_Distribution_fields),
PB_FIELD( 5, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Aggregation, tag, data.interval_stats, &google_census_Tag_fields), PB_ONEOF_FIELD(data, 5, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, interval_stats, description, &google_census_IntervalStats_fields),
PB_FIELD( 6, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Aggregation, tag, data.interval_stats, &google_census_Tag_fields),
PB_LAST_FIELD PB_LAST_FIELD
}; };
const pb_field_t google_census_ViewAggregations_fields[4] = { const pb_field_t google_census_Metric_fields[5] = {
PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, google_census_ViewAggregations, aggregation, aggregation, &google_census_Aggregation_fields), PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Metric, view_name, view_name, 0),
PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_ViewAggregations, start, aggregation, &google_census_Timestamp_fields), PB_FIELD( 2, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Metric, aggregation, view_name, &google_census_Aggregation_fields),
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_ViewAggregations, end, start, &google_census_Timestamp_fields), PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Metric, start, aggregation, &google_census_Timestamp_fields),
PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Metric, end, start, &google_census_Timestamp_fields),
PB_LAST_FIELD PB_LAST_FIELD
}; };
@ -156,7 +153,7 @@ const pb_field_t google_census_ViewAggregations_fields[4] = {
* numbers or field sizes that are larger than what can fit in 8 or 16 bit * numbers or field sizes that are larger than what can fit in 8 or 16 bit
* field descriptors. * field descriptors.
*/ */
PB_STATIC_ASSERT((pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Aggregation, tag) < 65536 && pb_membersize(google_census_ViewAggregations, aggregation) < 65536 && pb_membersize(google_census_ViewAggregations, start) < 65536 && pb_membersize(google_census_ViewAggregations, end) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Metric_google_census_Metric_BasicUnit_google_census_Metric_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_ViewAggregations) PB_STATIC_ASSERT((pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Aggregation, tag) < 65536 && pb_membersize(google_census_Metric, aggregation) < 65536 && pb_membersize(google_census_Metric, start) < 65536 && pb_membersize(google_census_Metric, end) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Resource_google_census_Resource_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_Metric)
#endif #endif
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) #if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)
@ -167,7 +164,7 @@ PB_STATIC_ASSERT((pb_membersize(google_census_Metric, unit) < 65536 && pb_member
* numbers or field sizes that are larger than what can fit in the default * numbers or field sizes that are larger than what can fit in the default
* 8 bit descriptors. * 8 bit descriptors.
*/ */
PB_STATIC_ASSERT((pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Aggregation, tag) < 256 && pb_membersize(google_census_ViewAggregations, aggregation) < 256 && pb_membersize(google_census_ViewAggregations, start) < 256 && pb_membersize(google_census_ViewAggregations, end) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Metric_google_census_Metric_BasicUnit_google_census_Metric_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_ViewAggregations) PB_STATIC_ASSERT((pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Aggregation, tag) < 256 && pb_membersize(google_census_Metric, aggregation) < 256 && pb_membersize(google_census_Metric, start) < 256 && pb_membersize(google_census_Metric, end) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Resource_google_census_Resource_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_Metric)
#endif #endif

@ -45,14 +45,21 @@ extern "C" {
#endif #endif
/* Enum definitions */ /* Enum definitions */
typedef enum _google_census_Metric_BasicUnit_Measure { typedef enum _google_census_Resource_BasicUnit {
google_census_Metric_BasicUnit_Measure_UNKNOWN = 0, google_census_Resource_BasicUnit_UNKNOWN = 0,
google_census_Metric_BasicUnit_Measure_BITS = 1, google_census_Resource_BasicUnit_BITS = 1,
google_census_Metric_BasicUnit_Measure_BYTES = 2, google_census_Resource_BasicUnit_BYTES = 2,
google_census_Metric_BasicUnit_Measure_SECS = 3, google_census_Resource_BasicUnit_SECS = 3,
google_census_Metric_BasicUnit_Measure_CORES = 4, google_census_Resource_BasicUnit_CORES = 4,
google_census_Metric_BasicUnit_Measure_MAX_UNITS = 5 google_census_Resource_BasicUnit_MAX_UNITS = 5
} google_census_Metric_BasicUnit_Measure; } google_census_Resource_BasicUnit;
typedef enum _google_census_AggregationDescriptor_AggregationType {
google_census_AggregationDescriptor_AggregationType_UNKNOWN = 0,
google_census_AggregationDescriptor_AggregationType_COUNT = 1,
google_census_AggregationDescriptor_AggregationType_DISTRIBUTION = 2,
google_census_AggregationDescriptor_AggregationType_INTERVAL = 3
} google_census_AggregationDescriptor_AggregationType;
/* Struct definitions */ /* Struct definitions */
typedef struct _google_census_AggregationDescriptor_BucketBoundaries { typedef struct _google_census_AggregationDescriptor_BucketBoundaries {
@ -68,6 +75,8 @@ typedef struct _google_census_IntervalStats {
} google_census_IntervalStats; } google_census_IntervalStats;
typedef struct _google_census_AggregationDescriptor { typedef struct _google_census_AggregationDescriptor {
bool has_type;
google_census_AggregationDescriptor_AggregationType type;
pb_size_t which_options; pb_size_t which_options;
union { union {
google_census_AggregationDescriptor_BucketBoundaries bucket_boundaries; google_census_AggregationDescriptor_BucketBoundaries bucket_boundaries;
@ -89,17 +98,12 @@ typedef struct _google_census_Duration {
int32_t nanos; int32_t nanos;
} google_census_Duration; } google_census_Duration;
typedef struct _google_census_Metric_BasicUnit { typedef struct _google_census_Resource_MeasurementUnit {
bool has_type;
google_census_Metric_BasicUnit_Measure type;
} google_census_Metric_BasicUnit;
typedef struct _google_census_Metric_MeasurementUnit {
bool has_prefix; bool has_prefix;
int32_t prefix; int32_t prefix;
pb_callback_t numerator; pb_callback_t numerator;
pb_callback_t denominator; pb_callback_t denominator;
} google_census_Metric_MeasurementUnit; } google_census_Resource_MeasurementUnit;
typedef struct _google_census_Tag { typedef struct _google_census_Tag {
bool has_key; bool has_key;
@ -135,37 +139,36 @@ typedef struct _google_census_IntervalStats_Window {
} google_census_IntervalStats_Window; } google_census_IntervalStats_Window;
typedef struct _google_census_Metric { typedef struct _google_census_Metric {
pb_callback_t view_name;
pb_callback_t aggregation;
bool has_start;
google_census_Timestamp start;
bool has_end;
google_census_Timestamp end;
} google_census_Metric;
typedef struct _google_census_Resource {
pb_callback_t name; pb_callback_t name;
pb_callback_t description; pb_callback_t description;
bool has_unit; bool has_unit;
google_census_Metric_MeasurementUnit unit; google_census_Resource_MeasurementUnit unit;
bool has_id; } google_census_Resource;
int32_t id;
} google_census_Metric;
typedef struct _google_census_View { typedef struct _google_census_View {
pb_callback_t name; pb_callback_t name;
pb_callback_t description; pb_callback_t description;
bool has_metric_id; pb_callback_t resource_name;
int32_t metric_id;
bool has_aggregation; bool has_aggregation;
google_census_AggregationDescriptor aggregation; google_census_AggregationDescriptor aggregation;
pb_callback_t tag_key; pb_callback_t tag_key;
} google_census_View; } google_census_View;
typedef struct _google_census_ViewAggregations {
pb_callback_t aggregation;
bool has_start;
google_census_Timestamp start;
bool has_end;
google_census_Timestamp end;
} google_census_ViewAggregations;
typedef struct _google_census_Aggregation { typedef struct _google_census_Aggregation {
pb_callback_t name; pb_callback_t name;
pb_callback_t description; pb_callback_t description;
pb_size_t which_data; pb_size_t which_data;
union { union {
uint64_t count;
google_census_Distribution distribution; google_census_Distribution distribution;
google_census_IntervalStats interval_stats; google_census_IntervalStats interval_stats;
} data; } data;
@ -177,10 +180,9 @@ typedef struct _google_census_Aggregation {
/* Initializer values for message structs */ /* Initializer values for message structs */
#define google_census_Duration_init_default {false, 0, false, 0} #define google_census_Duration_init_default {false, 0, false, 0}
#define google_census_Timestamp_init_default {false, 0, false, 0} #define google_census_Timestamp_init_default {false, 0, false, 0}
#define google_census_Metric_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Metric_MeasurementUnit_init_default, false, 0} #define google_census_Resource_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Resource_MeasurementUnit_init_default}
#define google_census_Metric_BasicUnit_init_default {false, (google_census_Metric_BasicUnit_Measure)0} #define google_census_Resource_MeasurementUnit_init_default {false, 0, {{NULL}, NULL}, {{NULL}, NULL}}
#define google_census_Metric_MeasurementUnit_init_default {false, 0, {{NULL}, NULL}, {{NULL}, NULL}} #define google_census_AggregationDescriptor_init_default {false, (google_census_AggregationDescriptor_AggregationType)0, 0, {google_census_AggregationDescriptor_BucketBoundaries_init_default}}
#define google_census_AggregationDescriptor_init_default {0, {google_census_AggregationDescriptor_BucketBoundaries_init_default}}
#define google_census_AggregationDescriptor_BucketBoundaries_init_default {{{NULL}, NULL}} #define google_census_AggregationDescriptor_BucketBoundaries_init_default {{{NULL}, NULL}}
#define google_census_AggregationDescriptor_IntervalBoundaries_init_default {{{NULL}, NULL}} #define google_census_AggregationDescriptor_IntervalBoundaries_init_default {{{NULL}, NULL}}
#define google_census_Distribution_init_default {false, 0, false, 0, false, google_census_Distribution_Range_init_default, {{NULL}, NULL}} #define google_census_Distribution_init_default {false, 0, false, 0, false, google_census_Distribution_Range_init_default, {{NULL}, NULL}}
@ -188,15 +190,14 @@ typedef struct _google_census_Aggregation {
#define google_census_IntervalStats_init_default {{{NULL}, NULL}} #define google_census_IntervalStats_init_default {{{NULL}, NULL}}
#define google_census_IntervalStats_Window_init_default {false, google_census_Duration_init_default, false, 0, false, 0} #define google_census_IntervalStats_Window_init_default {false, google_census_Duration_init_default, false, 0, false, 0}
#define google_census_Tag_init_default {false, "", false, ""} #define google_census_Tag_init_default {false, "", false, ""}
#define google_census_View_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, 0, false, google_census_AggregationDescriptor_init_default, {{NULL}, NULL}} #define google_census_View_init_default {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, google_census_AggregationDescriptor_init_default, {{NULL}, NULL}}
#define google_census_Aggregation_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0, {google_census_Distribution_init_default}, {{NULL}, NULL}} #define google_census_Aggregation_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0, {0}, {{NULL}, NULL}}
#define google_census_ViewAggregations_init_default {{{NULL}, NULL}, false, google_census_Timestamp_init_default, false, google_census_Timestamp_init_default} #define google_census_Metric_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Timestamp_init_default, false, google_census_Timestamp_init_default}
#define google_census_Duration_init_zero {false, 0, false, 0} #define google_census_Duration_init_zero {false, 0, false, 0}
#define google_census_Timestamp_init_zero {false, 0, false, 0} #define google_census_Timestamp_init_zero {false, 0, false, 0}
#define google_census_Metric_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Metric_MeasurementUnit_init_zero, false, 0} #define google_census_Resource_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Resource_MeasurementUnit_init_zero}
#define google_census_Metric_BasicUnit_init_zero {false, (google_census_Metric_BasicUnit_Measure)0} #define google_census_Resource_MeasurementUnit_init_zero {false, 0, {{NULL}, NULL}, {{NULL}, NULL}}
#define google_census_Metric_MeasurementUnit_init_zero {false, 0, {{NULL}, NULL}, {{NULL}, NULL}} #define google_census_AggregationDescriptor_init_zero {false, (google_census_AggregationDescriptor_AggregationType)0, 0, {google_census_AggregationDescriptor_BucketBoundaries_init_zero}}
#define google_census_AggregationDescriptor_init_zero {0, {google_census_AggregationDescriptor_BucketBoundaries_init_zero}}
#define google_census_AggregationDescriptor_BucketBoundaries_init_zero {{{NULL}, NULL}} #define google_census_AggregationDescriptor_BucketBoundaries_init_zero {{{NULL}, NULL}}
#define google_census_AggregationDescriptor_IntervalBoundaries_init_zero {{{NULL}, NULL}} #define google_census_AggregationDescriptor_IntervalBoundaries_init_zero {{{NULL}, NULL}}
#define google_census_Distribution_init_zero {false, 0, false, 0, false, google_census_Distribution_Range_init_zero, {{NULL}, NULL}} #define google_census_Distribution_init_zero {false, 0, false, 0, false, google_census_Distribution_Range_init_zero, {{NULL}, NULL}}
@ -204,25 +205,25 @@ typedef struct _google_census_Aggregation {
#define google_census_IntervalStats_init_zero {{{NULL}, NULL}} #define google_census_IntervalStats_init_zero {{{NULL}, NULL}}
#define google_census_IntervalStats_Window_init_zero {false, google_census_Duration_init_zero, false, 0, false, 0} #define google_census_IntervalStats_Window_init_zero {false, google_census_Duration_init_zero, false, 0, false, 0}
#define google_census_Tag_init_zero {false, "", false, ""} #define google_census_Tag_init_zero {false, "", false, ""}
#define google_census_View_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, 0, false, google_census_AggregationDescriptor_init_zero, {{NULL}, NULL}} #define google_census_View_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, google_census_AggregationDescriptor_init_zero, {{NULL}, NULL}}
#define google_census_Aggregation_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0, {google_census_Distribution_init_zero}, {{NULL}, NULL}} #define google_census_Aggregation_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0, {0}, {{NULL}, NULL}}
#define google_census_ViewAggregations_init_zero {{{NULL}, NULL}, false, google_census_Timestamp_init_zero, false, google_census_Timestamp_init_zero} #define google_census_Metric_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Timestamp_init_zero, false, google_census_Timestamp_init_zero}
/* Field tags (for use in manual encoding/decoding) */ /* Field tags (for use in manual encoding/decoding) */
#define google_census_AggregationDescriptor_BucketBoundaries_bounds_tag 1 #define google_census_AggregationDescriptor_BucketBoundaries_bounds_tag 1
#define google_census_AggregationDescriptor_IntervalBoundaries_window_size_tag 1 #define google_census_AggregationDescriptor_IntervalBoundaries_window_size_tag 1
#define google_census_IntervalStats_window_tag 1 #define google_census_IntervalStats_window_tag 1
#define google_census_AggregationDescriptor_bucket_boundaries_tag 1 #define google_census_AggregationDescriptor_bucket_boundaries_tag 2
#define google_census_AggregationDescriptor_interval_boundaries_tag 2 #define google_census_AggregationDescriptor_interval_boundaries_tag 3
#define google_census_AggregationDescriptor_type_tag 1
#define google_census_Distribution_Range_min_tag 1 #define google_census_Distribution_Range_min_tag 1
#define google_census_Distribution_Range_max_tag 2 #define google_census_Distribution_Range_max_tag 2
#define google_census_Duration_seconds_tag 1 #define google_census_Duration_seconds_tag 1
#define google_census_Duration_nanos_tag 2 #define google_census_Duration_nanos_tag 2
#define google_census_Metric_BasicUnit_type_tag 1 #define google_census_Resource_MeasurementUnit_prefix_tag 1
#define google_census_Metric_MeasurementUnit_prefix_tag 1 #define google_census_Resource_MeasurementUnit_numerator_tag 2
#define google_census_Metric_MeasurementUnit_numerator_tag 2 #define google_census_Resource_MeasurementUnit_denominator_tag 3
#define google_census_Metric_MeasurementUnit_denominator_tag 3
#define google_census_Tag_key_tag 1 #define google_census_Tag_key_tag 1
#define google_census_Tag_value_tag 2 #define google_census_Tag_value_tag 2
#define google_census_Timestamp_seconds_tag 1 #define google_census_Timestamp_seconds_tag 1
@ -234,32 +235,33 @@ typedef struct _google_census_Aggregation {
#define google_census_IntervalStats_Window_window_size_tag 1 #define google_census_IntervalStats_Window_window_size_tag 1
#define google_census_IntervalStats_Window_count_tag 2 #define google_census_IntervalStats_Window_count_tag 2
#define google_census_IntervalStats_Window_mean_tag 3 #define google_census_IntervalStats_Window_mean_tag 3
#define google_census_Metric_name_tag 1 #define google_census_Metric_view_name_tag 1
#define google_census_Metric_description_tag 2 #define google_census_Metric_aggregation_tag 2
#define google_census_Metric_unit_tag 3 #define google_census_Metric_start_tag 3
#define google_census_Metric_id_tag 4 #define google_census_Metric_end_tag 4
#define google_census_Resource_name_tag 1
#define google_census_Resource_description_tag 2
#define google_census_Resource_unit_tag 3
#define google_census_View_name_tag 1 #define google_census_View_name_tag 1
#define google_census_View_description_tag 2 #define google_census_View_description_tag 2
#define google_census_View_metric_id_tag 3 #define google_census_View_resource_name_tag 3
#define google_census_View_aggregation_tag 4 #define google_census_View_aggregation_tag 4
#define google_census_View_tag_key_tag 5 #define google_census_View_tag_key_tag 5
#define google_census_ViewAggregations_aggregation_tag 1 #define google_census_Aggregation_count_tag 3
#define google_census_ViewAggregations_start_tag 2
#define google_census_ViewAggregations_end_tag 3 #define google_census_Aggregation_distribution_tag 4
#define google_census_Aggregation_distribution_tag 3
#define google_census_Aggregation_interval_stats_tag 4 #define google_census_Aggregation_interval_stats_tag 5
#define google_census_Aggregation_name_tag 1 #define google_census_Aggregation_name_tag 1
#define google_census_Aggregation_description_tag 2 #define google_census_Aggregation_description_tag 2
#define google_census_Aggregation_tag_tag 5 #define google_census_Aggregation_tag_tag 6
/* Struct field encoding specification for nanopb */ /* Struct field encoding specification for nanopb */
extern const pb_field_t google_census_Duration_fields[3]; extern const pb_field_t google_census_Duration_fields[3];
extern const pb_field_t google_census_Timestamp_fields[3]; extern const pb_field_t google_census_Timestamp_fields[3];
extern const pb_field_t google_census_Metric_fields[5]; extern const pb_field_t google_census_Resource_fields[4];
extern const pb_field_t google_census_Metric_BasicUnit_fields[2]; extern const pb_field_t google_census_Resource_MeasurementUnit_fields[4];
extern const pb_field_t google_census_Metric_MeasurementUnit_fields[4]; extern const pb_field_t google_census_AggregationDescriptor_fields[4];
extern const pb_field_t google_census_AggregationDescriptor_fields[3];
extern const pb_field_t google_census_AggregationDescriptor_BucketBoundaries_fields[2]; extern const pb_field_t google_census_AggregationDescriptor_BucketBoundaries_fields[2];
extern const pb_field_t google_census_AggregationDescriptor_IntervalBoundaries_fields[2]; extern const pb_field_t google_census_AggregationDescriptor_IntervalBoundaries_fields[2];
extern const pb_field_t google_census_Distribution_fields[5]; extern const pb_field_t google_census_Distribution_fields[5];
@ -268,13 +270,12 @@ extern const pb_field_t google_census_IntervalStats_fields[2];
extern const pb_field_t google_census_IntervalStats_Window_fields[4]; extern const pb_field_t google_census_IntervalStats_Window_fields[4];
extern const pb_field_t google_census_Tag_fields[3]; extern const pb_field_t google_census_Tag_fields[3];
extern const pb_field_t google_census_View_fields[6]; extern const pb_field_t google_census_View_fields[6];
extern const pb_field_t google_census_Aggregation_fields[6]; extern const pb_field_t google_census_Aggregation_fields[7];
extern const pb_field_t google_census_ViewAggregations_fields[4]; extern const pb_field_t google_census_Metric_fields[5];
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define google_census_Duration_size 22 #define google_census_Duration_size 22
#define google_census_Timestamp_size 22 #define google_census_Timestamp_size 22
#define google_census_Metric_BasicUnit_size 2
#define google_census_Distribution_Range_size 18 #define google_census_Distribution_Range_size 18
#define google_census_IntervalStats_Window_size 44 #define google_census_IntervalStats_Window_size 44
#define google_census_Tag_size 516 #define google_census_Tag_size 516

@ -32,19 +32,31 @@
*/ */
#include <grpc/census.h> #include <grpc/census.h>
#include "src/core/ext/census/base_resources.h"
#include "src/core/ext/census/resource.h"
static int features_enabled = CENSUS_FEATURE_NONE; static int features_enabled = CENSUS_FEATURE_NONE;
int census_initialize(int features) { int census_initialize(int features) {
if (features_enabled != CENSUS_FEATURE_NONE) { if (features_enabled != CENSUS_FEATURE_NONE) {
// Must have been a previous call to census_initialize; return error // Must have been a previous call to census_initialize; return error
return 1; return -1;
} }
features_enabled = features; features_enabled = features & CENSUS_FEATURE_ALL;
return 0; if (features & CENSUS_FEATURE_STATS) {
initialize_resources();
define_base_resources();
}
return features_enabled;
} }
void census_shutdown(void) { features_enabled = CENSUS_FEATURE_NONE; } void census_shutdown(void) {
if (features_enabled & CENSUS_FEATURE_STATS) {
shutdown_resources();
}
features_enabled = CENSUS_FEATURE_NONE;
}
int census_supported(void) { int census_supported(void) {
/* TODO(aveitch): improve this as we implement features... */ /* TODO(aveitch): improve this as we implement features... */

@ -62,48 +62,3 @@ int census_trace_scan_start(int consume) {
(void)consume; (void)consume;
abort(); abort();
} }
const census_aggregation *census_view_aggregrations(const census_view *view) {
(void)view;
abort();
}
census_view *census_view_create(uint32_t metric_id, const census_context *tags,
const census_aggregation *aggregations,
size_t naggregations) {
(void)metric_id;
(void)tags;
(void)aggregations;
(void)naggregations;
abort();
}
const census_context *census_view_tags(const census_view *view) {
(void)view;
abort();
}
void census_view_delete(census_view *view) {
(void)view;
abort();
}
const census_view_data *census_view_get_data(const census_view *view) {
(void)view;
abort();
}
size_t census_view_metric(const census_view *view) {
(void)view;
abort();
}
size_t census_view_naggregations(const census_view *view) {
(void)view;
abort();
}
void census_view_reset(census_view *view) {
(void)view;
abort();
}

@ -0,0 +1,312 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/ext/census/resource.h"
#include "third_party/nanopb/pb_decode.h"
#include <grpc/census.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <stdbool.h>
#include <string.h>
// Protect local resource data structures.
static gpr_mu resource_lock;
// Deleteing and creating resources are relatively rare events, and should not
// be done in the critical path of performance sensitive code. We record
// current resource id's used in a simple array, and just search it each time
// we need to assign a new id, or look up a resource.
static resource **resources = NULL;
// Number of entries in *resources
static size_t n_resources = 0;
// Number of defined resources
static size_t n_defined_resources = 0;
void initialize_resources(void) {
gpr_mu_init(&resource_lock);
gpr_mu_lock(&resource_lock);
GPR_ASSERT(resources == NULL && n_resources == 0 && n_defined_resources == 0);
gpr_mu_unlock(&resource_lock);
}
// Delete a resource given it's ID. The ID must be a valid resource ID. Must be
// called with resource_lock held.
static void delete_resource_locked(size_t rid) {
GPR_ASSERT(resources[rid] != NULL);
gpr_free(resources[rid]->name);
gpr_free(resources[rid]->description);
gpr_free(resources[rid]->numerators);
gpr_free(resources[rid]->denominators);
gpr_free(resources[rid]);
resources[rid] = NULL;
n_defined_resources--;
}
void shutdown_resources(void) {
gpr_mu_lock(&resource_lock);
for (size_t i = 0; i < n_resources; i++) {
if (resources[i] != NULL) {
delete_resource_locked(i);
}
}
GPR_ASSERT(n_defined_resources == 0);
gpr_free(resources);
resources = NULL;
n_resources = 0;
gpr_mu_unlock(&resource_lock);
}
// Check the contents of string fields in a resource proto.
static bool validate_string(pb_istream_t *stream, const pb_field_t *field,
void **arg) {
resource *vresource = (resource *)*arg;
switch (field->tag) {
case google_census_Resource_name_tag:
// Name must have at least one character
if (stream->bytes_left == 0) {
gpr_log(GPR_INFO, "Zero-length Resource name.");
return false;
}
vresource->name = gpr_malloc(stream->bytes_left + 1);
vresource->name[stream->bytes_left] = '\0';
if (!pb_read(stream, (uint8_t *)vresource->name, stream->bytes_left)) {
return false;
}
// Can't have same name as an existing resource.
for (size_t i = 0; i < n_resources; i++) {
resource *compare = resources[i];
if (compare == vresource || compare == NULL) continue;
if (strcmp(compare->name, vresource->name) == 0) {
gpr_log(GPR_INFO, "Duplicate Resource name %s.", vresource->name);
return false;
}
}
break;
case google_census_Resource_description_tag:
if (stream->bytes_left == 0) {
return true;
}
vresource->description = gpr_malloc(stream->bytes_left + 1);
vresource->description[stream->bytes_left] = '\0';
if (!pb_read(stream, (uint8_t *)vresource->description,
stream->bytes_left)) {
return false;
}
break;
default:
// No other string fields in Resource. Print warning and skip.
gpr_log(GPR_INFO, "Unknown string field type in Resource protobuf.");
if (!pb_read(stream, NULL, stream->bytes_left)) {
return false;
}
break;
}
return true;
}
// Decode numerators/denominators in a stream. The `count` and `bup`
// (BasicUnit pointer) are pointers to the approriate fields in a resource
// struct.
static bool validate_units_helper(pb_istream_t *stream, int *count,
google_census_Resource_BasicUnit **bup) {
while (stream->bytes_left) {
(*count)++;
// Have to allocate a new array of values. Normal case is 0 or 1, so
// this should normally not be an issue.
google_census_Resource_BasicUnit *new_bup =
gpr_malloc((size_t)*count * sizeof(google_census_Resource_BasicUnit));
if (*count != 1) {
memcpy(new_bup, *bup,
(size_t)(*count - 1) * sizeof(google_census_Resource_BasicUnit));
gpr_free(*bup);
}
*bup = new_bup;
uint64_t value;
if (!pb_decode_varint(stream, &value)) {
return false;
}
*(*bup + *count - 1) = (google_census_Resource_BasicUnit)value;
}
return true;
}
// Validate units field of a Resource proto.
static bool validate_units(pb_istream_t *stream, const pb_field_t *field,
void **arg) {
resource *vresource = (resource *)(*arg);
switch (field->tag) {
case google_census_Resource_MeasurementUnit_numerator_tag:
return validate_units_helper(stream, &vresource->n_numerators,
&vresource->numerators);
break;
case google_census_Resource_MeasurementUnit_denominator_tag:
return validate_units_helper(stream, &vresource->n_denominators,
&vresource->denominators);
break;
default:
gpr_log(GPR_ERROR, "Unknown field type.");
return false;
break;
}
return true;
}
// Validate the contents of a Resource proto. `id` is the intended resource id.
static bool validate_resource_pb(const uint8_t *resource_pb,
size_t resource_pb_size, size_t id) {
GPR_ASSERT(id < n_resources);
if (resource_pb == NULL) {
return false;
}
google_census_Resource vresource;
vresource.name.funcs.decode = &validate_string;
vresource.name.arg = resources[id];
vresource.description.funcs.decode = &validate_string;
vresource.description.arg = resources[id];
vresource.unit.numerator.funcs.decode = &validate_units;
vresource.unit.numerator.arg = resources[id];
vresource.unit.denominator.funcs.decode = &validate_units;
vresource.unit.denominator.arg = resources[id];
pb_istream_t stream =
pb_istream_from_buffer((uint8_t *)resource_pb, resource_pb_size);
if (!pb_decode(&stream, google_census_Resource_fields, &vresource)) {
return false;
}
// A Resource must have a name, a unit, with at least one numerator.
return (resources[id]->name != NULL && vresource.has_unit &&
resources[id]->n_numerators > 0);
}
// Allocate a blank resource, and return associated ID. Must be called with
// resource_lock held.
size_t allocate_resource(void) {
// use next_id to optimize expected placement of next new resource.
static size_t next_id = 0;
size_t id = n_resources; // resource ID - initialize to invalid value.
// Expand resources if needed.
if (n_resources == n_defined_resources) {
size_t new_n_resources = n_resources ? n_resources * 2 : 2;
resource **new_resources = gpr_malloc(new_n_resources * sizeof(resource *));
memcpy(new_resources, resources, n_resources * sizeof(resource *));
memset(new_resources + n_resources, 0,
(new_n_resources - n_resources) * sizeof(resource *));
gpr_free(resources);
resources = new_resources;
n_resources = new_n_resources;
id = n_defined_resources;
} else {
GPR_ASSERT(n_defined_resources < n_resources);
// Find a free id.
for (size_t base = 0; base < n_resources; base++) {
id = (next_id + base) % n_resources;
if (resources[id] == NULL) break;
}
}
GPR_ASSERT(id < n_resources && resources[id] == NULL);
resources[id] = gpr_malloc(sizeof(resource));
memset(resources[id], 0, sizeof(resource));
n_defined_resources++;
next_id = (id + 1) % n_resources;
return id;
}
int32_t census_define_resource(const uint8_t *resource_pb,
size_t resource_pb_size) {
if (resource_pb == NULL) {
return -1;
}
gpr_mu_lock(&resource_lock);
size_t id = allocate_resource();
// Validate pb, extract name.
if (!validate_resource_pb(resource_pb, resource_pb_size, id)) {
delete_resource_locked(id);
gpr_mu_unlock(&resource_lock);
return -1;
}
gpr_mu_unlock(&resource_lock);
return (int32_t)id;
}
void census_delete_resource(int32_t rid) {
gpr_mu_lock(&resource_lock);
if (rid >= 0 && (size_t)rid < n_resources && resources[rid] != NULL) {
delete_resource_locked((size_t)rid);
}
gpr_mu_unlock(&resource_lock);
}
int32_t census_resource_id(const char *name) {
gpr_mu_lock(&resource_lock);
for (int32_t id = 0; (size_t)id < n_resources; id++) {
if (resources[id] != NULL && strcmp(resources[id]->name, name) == 0) {
gpr_mu_unlock(&resource_lock);
return id;
}
}
gpr_mu_unlock(&resource_lock);
return -1;
}
int32_t define_resource(const resource *base) {
GPR_ASSERT(base != NULL && base->name != NULL && base->n_numerators > 0 &&
base->numerators != NULL);
gpr_mu_lock(&resource_lock);
size_t id = allocate_resource();
size_t len = strlen(base->name) + 1;
resources[id]->name = gpr_malloc(len);
memcpy(resources[id]->name, base->name, len);
if (base->description) {
len = strlen(base->description) + 1;
resources[id]->description = gpr_malloc(len);
memcpy(resources[id]->description, base->description, len);
}
resources[id]->prefix = base->prefix;
resources[id]->n_numerators = base->n_numerators;
len = (size_t)base->n_numerators * sizeof(*base->numerators);
resources[id]->numerators = gpr_malloc(len);
memcpy(resources[id]->numerators, base->numerators, len);
resources[id]->n_denominators = base->n_denominators;
if (base->n_denominators != 0) {
len = (size_t)base->n_denominators * sizeof(*base->denominators);
resources[id]->denominators = gpr_malloc(len);
memcpy(resources[id]->denominators, base->denominators, len);
}
gpr_mu_unlock(&resource_lock);
return (int32_t)id;
}

@ -0,0 +1,63 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* Census-internal resource definition and manipluation functions. */
#ifndef GRPC_CORE_EXT_CENSUS_RESOURCE_H
#define GRPC_CORE_EXT_CENSUS_RESOURCE_H
#include <grpc/grpc.h>
#include "src/core/ext/census/gen/census.pb.h"
/* Internal representation of a resource. */
typedef struct {
char *name;
char *description;
int32_t prefix;
int n_numerators;
google_census_Resource_BasicUnit *numerators;
int n_denominators;
google_census_Resource_BasicUnit *denominators;
} resource;
/* Initialize and shutdown the resources subsystem. */
void initialize_resources(void);
void shutdown_resources(void);
/* Add a new resource, given a proposed resource structure. Returns the
resource ID, or -ve on failure.
TODO(aveitch): this function exists to support addition of the base
resources. It should be removed when we have the ability to add resources
from configuration files. */
int32_t define_resource(const resource *base);
#endif /* GRPC_CORE_EXT_CENSUS_RESOURCE_H */

@ -128,7 +128,7 @@ static void flush_read_staging_buffer(secure_endpoint *ep, uint8_t **cur,
static void call_read_cb(grpc_exec_ctx *exec_ctx, secure_endpoint *ep, static void call_read_cb(grpc_exec_ctx *exec_ctx, secure_endpoint *ep,
grpc_error *error) { grpc_error *error) {
if (false && grpc_trace_secure_endpoint) { if (grpc_trace_secure_endpoint) {
size_t i; size_t i;
for (i = 0; i < ep->read_buffer->count; i++) { for (i = 0; i < ep->read_buffer->count; i++) {
char *data = gpr_dump_slice(ep->read_buffer->slices[i], char *data = gpr_dump_slice(ep->read_buffer->slices[i],
@ -256,7 +256,7 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
gpr_slice_buffer_reset_and_unref(&ep->output_buffer); gpr_slice_buffer_reset_and_unref(&ep->output_buffer);
if (false && grpc_trace_secure_endpoint) { if (grpc_trace_secure_endpoint) {
for (i = 0; i < slices->count; i++) { for (i = 0; i < slices->count; i++) {
char *data = char *data =
gpr_dump_slice(slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_dump_slice(slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);

@ -1377,6 +1377,9 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
int num_completion_callbacks_needed = 1; int num_completion_callbacks_needed = 1;
grpc_call_error error = GRPC_CALL_OK; grpc_call_error error = GRPC_CALL_OK;
// sent_initial_metadata guards against variable reuse.
grpc_metadata compression_md;
GPR_TIMER_BEGIN("grpc_call_start_batch", 0); GPR_TIMER_BEGIN("grpc_call_start_batch", 0);
GRPC_CALL_LOG_BATCH(GPR_INFO, call, ops, nops, notify_tag); GRPC_CALL_LOG_BATCH(GPR_INFO, call, ops, nops, notify_tag);
@ -1422,8 +1425,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
goto done_with_error; goto done_with_error;
} }
/* process compression level */ /* process compression level */
grpc_metadata compression_md; memset(&compression_md, 0, sizeof(compression_md));
memset(&compression_md, 0, sizeof(grpc_metadata));
size_t additional_metadata_count = 0; size_t additional_metadata_count = 0;
grpc_compression_level effective_compression_level; grpc_compression_level effective_compression_level;
bool level_set = false; bool level_set = false;

@ -51,15 +51,15 @@ uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
const uint8_t grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT * 2] = const uint8_t grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT * 2] =
{11, 35, 10, 35, 12, 35, 12, 49, 13, 35, 14, 35, 15, 35, 16, 35, 17, 35, {11, 33, 10, 33, 12, 33, 12, 49, 13, 33, 14, 33, 15, 33, 16, 33, 17, 33,
19, 35, 20, 35, 21, 35, 24, 35, 25, 35, 26, 35, 27, 35, 28, 35, 29, 35, 19, 33, 20, 33, 21, 33, 22, 33, 23, 33, 24, 33, 25, 33, 26, 33, 27, 33,
30, 18, 30, 35, 31, 35, 32, 35, 36, 35, 37, 35, 38, 35, 39, 35, 42, 33, 28, 18, 28, 33, 29, 33, 30, 33, 34, 33, 35, 33, 36, 33, 37, 33, 40, 31,
42, 34, 42, 48, 42, 53, 42, 54, 42, 55, 42, 56, 43, 33, 43, 48, 43, 53, 40, 32, 40, 48, 40, 53, 40, 54, 40, 55, 40, 56, 42, 31, 42, 48, 42, 53,
46, 0, 46, 1, 46, 2, 50, 35, 57, 35, 58, 35, 59, 35, 60, 35, 61, 35, 45, 0, 45, 1, 45, 2, 50, 33, 57, 33, 58, 33, 59, 33, 60, 33, 61, 33,
62, 35, 63, 35, 64, 35, 65, 35, 66, 35, 67, 35, 68, 40, 68, 70, 68, 73, 62, 33, 63, 33, 64, 33, 65, 33, 66, 33, 67, 33, 68, 38, 68, 70, 68, 73,
69, 81, 69, 82, 71, 35, 72, 35, 74, 35, 75, 35, 76, 35, 77, 35, 78, 41, 69, 81, 69, 82, 71, 33, 72, 33, 74, 33, 75, 33, 76, 33, 77, 33, 78, 39,
78, 51, 78, 52, 79, 35, 80, 35, 83, 3, 83, 4, 83, 5, 83, 6, 83, 7, 78, 51, 78, 52, 79, 33, 80, 33, 83, 3, 83, 4, 83, 5, 83, 6, 83, 7,
83, 8, 83, 9, 84, 35, 85, 86, 87, 35, 88, 35, 89, 35, 90, 35, 91, 35}; 83, 8, 83, 9, 84, 33, 85, 86, 87, 33, 88, 33, 89, 33, 90, 33, 91, 33};
const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = { const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = {
"0", "0",
@ -84,8 +84,6 @@ const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = {
":authority", ":authority",
"authorization", "authorization",
"cache-control", "cache-control",
"census-bin",
"census-binary-bin",
"content-disposition", "content-disposition",
"content-encoding", "content-encoding",
"content-language", "content-language",
@ -105,11 +103,13 @@ const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = {
"GET", "GET",
"grpc", "grpc",
"grpc-accept-encoding", "grpc-accept-encoding",
"grpc-census-bin",
"grpc-encoding", "grpc-encoding",
"grpc-internal-encoding-request", "grpc-internal-encoding-request",
"grpc-message", "grpc-message",
"grpc-status", "grpc-status",
"grpc-timeout", "grpc-timeout",
"grpc-tracing-bin",
"gzip", "gzip",
"gzip, deflate", "gzip, deflate",
"host", "host",

@ -90,58 +90,58 @@ extern grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT];
#define GRPC_MDSTR_AUTHORIZATION (&grpc_static_mdstr_table[20]) #define GRPC_MDSTR_AUTHORIZATION (&grpc_static_mdstr_table[20])
/* "cache-control" */ /* "cache-control" */
#define GRPC_MDSTR_CACHE_CONTROL (&grpc_static_mdstr_table[21]) #define GRPC_MDSTR_CACHE_CONTROL (&grpc_static_mdstr_table[21])
/* "census-bin" */
#define GRPC_MDSTR_CENSUS_BIN (&grpc_static_mdstr_table[22])
/* "census-binary-bin" */
#define GRPC_MDSTR_CENSUS_BINARY_BIN (&grpc_static_mdstr_table[23])
/* "content-disposition" */ /* "content-disposition" */
#define GRPC_MDSTR_CONTENT_DISPOSITION (&grpc_static_mdstr_table[24]) #define GRPC_MDSTR_CONTENT_DISPOSITION (&grpc_static_mdstr_table[22])
/* "content-encoding" */ /* "content-encoding" */
#define GRPC_MDSTR_CONTENT_ENCODING (&grpc_static_mdstr_table[25]) #define GRPC_MDSTR_CONTENT_ENCODING (&grpc_static_mdstr_table[23])
/* "content-language" */ /* "content-language" */
#define GRPC_MDSTR_CONTENT_LANGUAGE (&grpc_static_mdstr_table[26]) #define GRPC_MDSTR_CONTENT_LANGUAGE (&grpc_static_mdstr_table[24])
/* "content-length" */ /* "content-length" */
#define GRPC_MDSTR_CONTENT_LENGTH (&grpc_static_mdstr_table[27]) #define GRPC_MDSTR_CONTENT_LENGTH (&grpc_static_mdstr_table[25])
/* "content-location" */ /* "content-location" */
#define GRPC_MDSTR_CONTENT_LOCATION (&grpc_static_mdstr_table[28]) #define GRPC_MDSTR_CONTENT_LOCATION (&grpc_static_mdstr_table[26])
/* "content-range" */ /* "content-range" */
#define GRPC_MDSTR_CONTENT_RANGE (&grpc_static_mdstr_table[29]) #define GRPC_MDSTR_CONTENT_RANGE (&grpc_static_mdstr_table[27])
/* "content-type" */ /* "content-type" */
#define GRPC_MDSTR_CONTENT_TYPE (&grpc_static_mdstr_table[30]) #define GRPC_MDSTR_CONTENT_TYPE (&grpc_static_mdstr_table[28])
/* "cookie" */ /* "cookie" */
#define GRPC_MDSTR_COOKIE (&grpc_static_mdstr_table[31]) #define GRPC_MDSTR_COOKIE (&grpc_static_mdstr_table[29])
/* "date" */ /* "date" */
#define GRPC_MDSTR_DATE (&grpc_static_mdstr_table[32]) #define GRPC_MDSTR_DATE (&grpc_static_mdstr_table[30])
/* "deflate" */ /* "deflate" */
#define GRPC_MDSTR_DEFLATE (&grpc_static_mdstr_table[33]) #define GRPC_MDSTR_DEFLATE (&grpc_static_mdstr_table[31])
/* "deflate,gzip" */ /* "deflate,gzip" */
#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (&grpc_static_mdstr_table[34]) #define GRPC_MDSTR_DEFLATE_COMMA_GZIP (&grpc_static_mdstr_table[32])
/* "" */ /* "" */
#define GRPC_MDSTR_EMPTY (&grpc_static_mdstr_table[35]) #define GRPC_MDSTR_EMPTY (&grpc_static_mdstr_table[33])
/* "etag" */ /* "etag" */
#define GRPC_MDSTR_ETAG (&grpc_static_mdstr_table[36]) #define GRPC_MDSTR_ETAG (&grpc_static_mdstr_table[34])
/* "expect" */ /* "expect" */
#define GRPC_MDSTR_EXPECT (&grpc_static_mdstr_table[37]) #define GRPC_MDSTR_EXPECT (&grpc_static_mdstr_table[35])
/* "expires" */ /* "expires" */
#define GRPC_MDSTR_EXPIRES (&grpc_static_mdstr_table[38]) #define GRPC_MDSTR_EXPIRES (&grpc_static_mdstr_table[36])
/* "from" */ /* "from" */
#define GRPC_MDSTR_FROM (&grpc_static_mdstr_table[39]) #define GRPC_MDSTR_FROM (&grpc_static_mdstr_table[37])
/* "GET" */ /* "GET" */
#define GRPC_MDSTR_GET (&grpc_static_mdstr_table[40]) #define GRPC_MDSTR_GET (&grpc_static_mdstr_table[38])
/* "grpc" */ /* "grpc" */
#define GRPC_MDSTR_GRPC (&grpc_static_mdstr_table[41]) #define GRPC_MDSTR_GRPC (&grpc_static_mdstr_table[39])
/* "grpc-accept-encoding" */ /* "grpc-accept-encoding" */
#define GRPC_MDSTR_GRPC_ACCEPT_ENCODING (&grpc_static_mdstr_table[42]) #define GRPC_MDSTR_GRPC_ACCEPT_ENCODING (&grpc_static_mdstr_table[40])
/* "grpc-census-bin" */
#define GRPC_MDSTR_GRPC_CENSUS_BIN (&grpc_static_mdstr_table[41])
/* "grpc-encoding" */ /* "grpc-encoding" */
#define GRPC_MDSTR_GRPC_ENCODING (&grpc_static_mdstr_table[43]) #define GRPC_MDSTR_GRPC_ENCODING (&grpc_static_mdstr_table[42])
/* "grpc-internal-encoding-request" */ /* "grpc-internal-encoding-request" */
#define GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST (&grpc_static_mdstr_table[44]) #define GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST (&grpc_static_mdstr_table[43])
/* "grpc-message" */ /* "grpc-message" */
#define GRPC_MDSTR_GRPC_MESSAGE (&grpc_static_mdstr_table[45]) #define GRPC_MDSTR_GRPC_MESSAGE (&grpc_static_mdstr_table[44])
/* "grpc-status" */ /* "grpc-status" */
#define GRPC_MDSTR_GRPC_STATUS (&grpc_static_mdstr_table[46]) #define GRPC_MDSTR_GRPC_STATUS (&grpc_static_mdstr_table[45])
/* "grpc-timeout" */ /* "grpc-timeout" */
#define GRPC_MDSTR_GRPC_TIMEOUT (&grpc_static_mdstr_table[47]) #define GRPC_MDSTR_GRPC_TIMEOUT (&grpc_static_mdstr_table[46])
/* "grpc-tracing-bin" */
#define GRPC_MDSTR_GRPC_TRACING_BIN (&grpc_static_mdstr_table[47])
/* "gzip" */ /* "gzip" */
#define GRPC_MDSTR_GZIP (&grpc_static_mdstr_table[48]) #define GRPC_MDSTR_GZIP (&grpc_static_mdstr_table[48])
/* "gzip, deflate" */ /* "gzip, deflate" */

@ -33,12 +33,12 @@ package google.census;
// All the census protos. // All the census protos.
// //
// Nomenclature note: capitalized names below (like Metric) are protos. // Nomenclature note: capitalized names below (like Resource) are protos.
// //
// Census lets you define a Metric - something which can be measured, like the // Census lets you define a Resource - something which can be measured, like the
// latency of an RPC, the number of CPU cycles spent on an operation, or // latency of an RPC, the number of CPU cycles spent on an operation, or
// anything else you care to measure. You can record individual instances of // anything else you care to measure. You can record individual instances of
// measurements (a double value) for every metric of interest. These // measurements (a double value) for every Resource of interest. These
// individual measurements are aggregated together into an Aggregation. There // individual measurements are aggregated together into an Aggregation. There
// are two Aggregation types available: Distribution (describes the // are two Aggregation types available: Distribution (describes the
// distribution of all measurements, possibly with a histogram) and // distribution of all measurements, possibly with a histogram) and
@ -47,8 +47,8 @@ package google.census;
// //
// You can define how your stats are broken down by Tag values and which // You can define how your stats are broken down by Tag values and which
// Aggregations to use through a View. The corresponding combination of // Aggregations to use through a View. The corresponding combination of
// Metric/View/Aggregation which is available to census clients is called a // Resource/View/Aggregation which is available to census clients is called a
// ViewAggregation. // Metric.
// The following two types are copied from // The following two types are copied from
@ -85,18 +85,17 @@ message Timestamp {
int32 nanos = 2; int32 nanos = 2;
} }
// Describes a metric // Describes a Resource.
message Metric { message Resource {
// name of metric, e.g. rpc_latency, cpu. // name of resource, e.g. rpc_latency, cpu. Must be unique.
string name = 1; string name = 1;
// More detailed description of the metric, used in documentation. // More detailed description of the resource, used in documentation.
string description = 2; string description = 2;
// Fundamental units of measurement supported by Census // Fundamental units of measurement supported by Census
// TODO(aveitch): expand this to include other S.I. units? // TODO(aveitch): expand this to include other S.I. units?
message BasicUnit { enum BasicUnit {
enum Measure {
UNKNOWN = 0; UNKNOWN = 0;
BITS = 1; BITS = 1;
BYTES = 2; BYTES = 2;
@ -104,8 +103,6 @@ message Metric {
CORES = 4; CORES = 4;
MAX_UNITS = 5; MAX_UNITS = 5;
} }
Measure type = 1;
}
// MeasurementUnit lets you build compound units of the form // MeasurementUnit lets you build compound units of the form
// 10^n * (A * B * ...) / (X * Y * ...), // 10^n * (A * B * ...) / (X * Y * ...),
@ -124,7 +121,7 @@ message Metric {
// denominator: SECS // denominator: SECS
// denominator: SECS // denominator: SECS
// //
// To specify multiples (in power of 10) units, specify a non-zero prefix // To specify multiples (in power of 10) of units, specify a non-zero prefix
// value, for example: // value, for example:
// //
// - MB/s (i.e. megabytes / s): // - MB/s (i.e. megabytes / s):
@ -141,32 +138,40 @@ message Metric {
repeated BasicUnit denominator = 3; repeated BasicUnit denominator = 3;
} }
// The units in which the Metric value is reported. // The units in which Resource values are measured.
MeasurementUnit unit = 3; MeasurementUnit unit = 3;
// Metrics will be assigned an ID when registered. Invalid if <= 0.
int32 id = 4;
} }
// An Aggregation summarizes a series of individual Metric measurements, an // An Aggregation summarizes a series of individual Resource measurements, an
// AggregationDescriptor describes an Aggregation. // AggregationDescriptor describes an Aggregation.
message AggregationDescriptor { message AggregationDescriptor {
// At most one set of options. If neither option is set, a default type enum AggregationType {
// of Distribution (without a histogram component) will be used. // Unspecified. Should not be used.
UNKNOWN = 0;
// A count of measurements made.
COUNT = 1;
// A Distribution.
DISTRIBUTION = 2;
// Counts over fixed time intervals.
INTERVAL = 3;
}
// The type of Aggregation.
AggregationType type = 1;
// At most one set of options. It is illegal to specifiy an option for
// COUNT Aggregations. interval_boundaries must be set for INTERVAL types.
// bucket_boundaries are optional for DISTRIBUTION types.
oneof options { oneof options {
// Defines the histogram bucket boundaries for Distributions. // Defines histogram bucket boundaries for Distributions.
BucketBoundaries bucket_boundaries = 1; BucketBoundaries bucket_boundaries = 2;
// Defines the time windows to record for IntervalStats. // Defines the time windows to record for IntervalStats.
IntervalBoundaries interval_boundaries = 2; IntervalBoundaries interval_boundaries = 3;
} }
// A Distribution may optionally contain a histogram of the values in the // A Distribution may optionally contain a histogram of the values in the
// population. The bucket boundaries for that histogram is described by // population. The bucket boundaries for that histogram are described by
// `bucket_boundaries`. // `bucket_boundaries`. This defines `size(bounds) + 1` (= N) buckets. The
// // boundaries for bucket index i are:
// Describes histogram bucket boundaries. Defines `size(bounds) + 1` (= N)
// buckets (for size(bounds) >= 1; if size(bounds) == 0, then no histogram
// will be defined. The boundaries for bucket index i are:
// //
// [-infinity, bounds[i]) for i == 0 // [-infinity, bounds[i]) for i == 0
// [bounds[i-1], bounds[i]) for 0 < i < N-2 // [bounds[i-1], bounds[i]) for 0 < i < N-2
@ -196,8 +201,8 @@ message AggregationDescriptor {
// a specified set of histogram buckets, as defined in // a specified set of histogram buckets, as defined in
// Aggregation.bucket_options. // Aggregation.bucket_options.
// //
// The summary statistics are the count, mean, sum of the squared deviation from // The summary statistics are the count, mean, minimum, and the maximum of the
// the mean, the minimum, and the maximum of the set of population of values. // set of population of values.
// //
// Although it is not forbidden, it is generally a bad idea to include // Although it is not forbidden, it is generally a bad idea to include
// non-finite values (infinities or NaNs) in the population of values, as this // non-finite values (infinities or NaNs) in the population of values, as this
@ -243,7 +248,7 @@ message Distribution {
message IntervalStats { message IntervalStats {
// Summary statistic over a single time window. // Summary statistic over a single time window.
message Window { message Window {
// The window duration. // The window duration. Must be positive.
Duration window_size = 1; Duration window_size = 1;
// The number of measurements in this window. // The number of measurements in this window.
int64 count = 2; int64 count = 2;
@ -251,7 +256,7 @@ message IntervalStats {
double mean = 3; double mean = 3;
} }
// Full set of windows for this metric. // Full set of windows for this aggregation.
repeated Window window = 1; repeated Window window = 1;
} }
@ -264,24 +269,24 @@ message Tag {
// A View specifies an Aggregation and a set of tag keys. The Aggregation will // A View specifies an Aggregation and a set of tag keys. The Aggregation will
// be broken down by the unique set of matching tag values for each measurement. // be broken down by the unique set of matching tag values for each measurement.
message View { message View {
// Name of view. // Name of view. Must be unique.
string name = 1; string name = 1;
// More detailed description, for documentation purposes. // More detailed description, for documentation purposes.
string description = 2; string description = 2;
// ID of Metric to associate with this View. // Name of Resource to be broken down for this view.
int32 metric_id = 3; string resource_name = 3;
// Aggregation type to associate with this View. // Aggregation type to associate with this View.
AggregationDescriptor aggregation = 4; AggregationDescriptor aggregation = 4;
// Tag keys to match with a given Metric. If no keys are specified, then all // Tag keys to match with a given Resource measurement. If no keys are
// stats for the Metric are recorded. Keys must be unique. // specified, then all stats are recorded. Keys must be unique.
repeated string tag_key = 5; repeated string tag_key = 5;
} }
// An Aggregation summarizes a series of individual Metric measures. // An Aggregation summarizes a series of individual Resource measurements.
message Aggregation { message Aggregation {
// Name of this aggregation. // Name of this aggregation.
string name = 1; string name = 1;
@ -291,23 +296,27 @@ message Aggregation {
// The data for this Aggregation. // The data for this Aggregation.
oneof data { oneof data {
Distribution distribution = 3; uint64 count = 3;
IntervalStats interval_stats = 4; Distribution distribution = 4;
IntervalStats interval_stats = 5;
} }
// Tags associated with this Aggregation. // Tags associated with this Aggregation.
repeated Tag tag = 5; repeated Tag tag = 6;
} }
// A ViewAggregations represents all the Aggregations for a particular view. // A Metric represents all the Aggregations for a particular view.
message ViewAggregations { message Metric {
// View associated with this Metric.
string view_name = 1;
// Aggregations - each will have a unique set of tag values for the tag_keys // Aggregations - each will have a unique set of tag values for the tag_keys
// associated with the corresponding View. // associated with the corresponding View.
repeated Aggregation aggregation = 1; repeated Aggregation aggregation = 2;
// Start and end timestamps over which the value was accumulated. These // Start and end timestamps over which the metric was accumulated. These
// values are not relevant/defined for IntervalStats aggregations, which are // values are not relevant/defined for IntervalStats aggregations, which are
// always accumulated over a fixed time period. // always accumulated over a fixed time period.
Timestamp start = 2; Timestamp start = 3;
Timestamp end = 3; Timestamp end = 4;
} }

@ -252,6 +252,7 @@ CORE_SOURCE_FILES = [
'src/core/ext/resolver/sockaddr/sockaddr_resolver.c', 'src/core/ext/resolver/sockaddr/sockaddr_resolver.c',
'src/core/ext/load_reporting/load_reporting.c', 'src/core/ext/load_reporting/load_reporting.c',
'src/core/ext/load_reporting/load_reporting_filter.c', 'src/core/ext/load_reporting/load_reporting_filter.c',
'src/core/ext/census/base_resources.c',
'src/core/ext/census/context.c', 'src/core/ext/census/context.c',
'src/core/ext/census/gen/census.pb.c', 'src/core/ext/census/gen/census.pb.c',
'src/core/ext/census/grpc_context.c', 'src/core/ext/census/grpc_context.c',
@ -261,6 +262,7 @@ CORE_SOURCE_FILES = [
'src/core/ext/census/mlog.c', 'src/core/ext/census/mlog.c',
'src/core/ext/census/operation.c', 'src/core/ext/census/operation.c',
'src/core/ext/census/placeholders.c', 'src/core/ext/census/placeholders.c',
'src/core/ext/census/resource.c',
'src/core/ext/census/tracing.c', 'src/core/ext/census/tracing.c',
'src/core/plugin_registry/grpc_plugin_registry.c', 'src/core/plugin_registry/grpc_plugin_registry.c',
'src/boringssl/err_data.c', 'src/boringssl/err_data.c',

@ -61,15 +61,10 @@ census_trace_print_type census_trace_print_import;
census_trace_scan_start_type census_trace_scan_start_import; census_trace_scan_start_type census_trace_scan_start_import;
census_get_trace_record_type census_get_trace_record_import; census_get_trace_record_type census_get_trace_record_import;
census_trace_scan_end_type census_trace_scan_end_import; census_trace_scan_end_type census_trace_scan_end_import;
census_define_resource_type census_define_resource_import;
census_delete_resource_type census_delete_resource_import;
census_resource_id_type census_resource_id_import;
census_record_values_type census_record_values_import; census_record_values_type census_record_values_import;
census_view_create_type census_view_create_import;
census_view_delete_type census_view_delete_import;
census_view_metric_type census_view_metric_import;
census_view_naggregations_type census_view_naggregations_import;
census_view_tags_type census_view_tags_import;
census_view_aggregrations_type census_view_aggregrations_import;
census_view_get_data_type census_view_get_data_import;
census_view_reset_type census_view_reset_import;
grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import; grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import;
grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import; grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import; grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
@ -334,15 +329,10 @@ void grpc_rb_load_imports(HMODULE library) {
census_trace_scan_start_import = (census_trace_scan_start_type) GetProcAddress(library, "census_trace_scan_start"); census_trace_scan_start_import = (census_trace_scan_start_type) GetProcAddress(library, "census_trace_scan_start");
census_get_trace_record_import = (census_get_trace_record_type) GetProcAddress(library, "census_get_trace_record"); census_get_trace_record_import = (census_get_trace_record_type) GetProcAddress(library, "census_get_trace_record");
census_trace_scan_end_import = (census_trace_scan_end_type) GetProcAddress(library, "census_trace_scan_end"); census_trace_scan_end_import = (census_trace_scan_end_type) GetProcAddress(library, "census_trace_scan_end");
census_define_resource_import = (census_define_resource_type) GetProcAddress(library, "census_define_resource");
census_delete_resource_import = (census_delete_resource_type) GetProcAddress(library, "census_delete_resource");
census_resource_id_import = (census_resource_id_type) GetProcAddress(library, "census_resource_id");
census_record_values_import = (census_record_values_type) GetProcAddress(library, "census_record_values"); census_record_values_import = (census_record_values_type) GetProcAddress(library, "census_record_values");
census_view_create_import = (census_view_create_type) GetProcAddress(library, "census_view_create");
census_view_delete_import = (census_view_delete_type) GetProcAddress(library, "census_view_delete");
census_view_metric_import = (census_view_metric_type) GetProcAddress(library, "census_view_metric");
census_view_naggregations_import = (census_view_naggregations_type) GetProcAddress(library, "census_view_naggregations");
census_view_tags_import = (census_view_tags_type) GetProcAddress(library, "census_view_tags");
census_view_aggregrations_import = (census_view_aggregrations_type) GetProcAddress(library, "census_view_aggregrations");
census_view_get_data_import = (census_view_get_data_type) GetProcAddress(library, "census_view_get_data");
census_view_reset_import = (census_view_reset_type) GetProcAddress(library, "census_view_reset");
grpc_compression_algorithm_parse_import = (grpc_compression_algorithm_parse_type) GetProcAddress(library, "grpc_compression_algorithm_parse"); grpc_compression_algorithm_parse_import = (grpc_compression_algorithm_parse_type) GetProcAddress(library, "grpc_compression_algorithm_parse");
grpc_compression_algorithm_name_import = (grpc_compression_algorithm_name_type) GetProcAddress(library, "grpc_compression_algorithm_name"); grpc_compression_algorithm_name_import = (grpc_compression_algorithm_name_type) GetProcAddress(library, "grpc_compression_algorithm_name");
grpc_compression_algorithm_for_level_import = (grpc_compression_algorithm_for_level_type) GetProcAddress(library, "grpc_compression_algorithm_for_level"); grpc_compression_algorithm_for_level_import = (grpc_compression_algorithm_for_level_type) GetProcAddress(library, "grpc_compression_algorithm_for_level");

@ -134,33 +134,18 @@ extern census_get_trace_record_type census_get_trace_record_import;
typedef void(*census_trace_scan_end_type)(); typedef void(*census_trace_scan_end_type)();
extern census_trace_scan_end_type census_trace_scan_end_import; extern census_trace_scan_end_type census_trace_scan_end_import;
#define census_trace_scan_end census_trace_scan_end_import #define census_trace_scan_end census_trace_scan_end_import
typedef int32_t(*census_define_resource_type)(const uint8_t *resource_pb, size_t resource_pb_size);
extern census_define_resource_type census_define_resource_import;
#define census_define_resource census_define_resource_import
typedef void(*census_delete_resource_type)(int32_t resource_id);
extern census_delete_resource_type census_delete_resource_import;
#define census_delete_resource census_delete_resource_import
typedef int32_t(*census_resource_id_type)(const char *name);
extern census_resource_id_type census_resource_id_import;
#define census_resource_id census_resource_id_import
typedef void(*census_record_values_type)(census_context *context, census_value *values, size_t nvalues); typedef void(*census_record_values_type)(census_context *context, census_value *values, size_t nvalues);
extern census_record_values_type census_record_values_import; extern census_record_values_type census_record_values_import;
#define census_record_values census_record_values_import #define census_record_values census_record_values_import
typedef census_view *(*census_view_create_type)(uint32_t metric_id, const census_context *tags, const census_aggregation *aggregations, size_t naggregations);
extern census_view_create_type census_view_create_import;
#define census_view_create census_view_create_import
typedef void(*census_view_delete_type)(census_view *view);
extern census_view_delete_type census_view_delete_import;
#define census_view_delete census_view_delete_import
typedef size_t(*census_view_metric_type)(const census_view *view);
extern census_view_metric_type census_view_metric_import;
#define census_view_metric census_view_metric_import
typedef size_t(*census_view_naggregations_type)(const census_view *view);
extern census_view_naggregations_type census_view_naggregations_import;
#define census_view_naggregations census_view_naggregations_import
typedef const census_context *(*census_view_tags_type)(const census_view *view);
extern census_view_tags_type census_view_tags_import;
#define census_view_tags census_view_tags_import
typedef const census_aggregation *(*census_view_aggregrations_type)(const census_view *view);
extern census_view_aggregrations_type census_view_aggregrations_import;
#define census_view_aggregrations census_view_aggregrations_import
typedef const census_view_data *(*census_view_get_data_type)(const census_view *view);
extern census_view_get_data_type census_view_get_data_import;
#define census_view_get_data census_view_get_data_import
typedef void(*census_view_reset_type)(census_view *view);
extern census_view_reset_type census_view_reset_import;
#define census_view_reset census_view_reset_import
typedef int(*grpc_compression_algorithm_parse_type)(const char *name, size_t name_length, grpc_compression_algorithm *algorithm); typedef int(*grpc_compression_algorithm_parse_type)(const char *name, size_t name_length, grpc_compression_algorithm *algorithm);
extern grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import; extern grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import;
#define grpc_compression_algorithm_parse grpc_compression_algorithm_parse_import #define grpc_compression_algorithm_parse grpc_compression_algorithm_parse_import

@ -0,0 +1,7 @@
Test source and data files for Census.
binary proto files (*.pb) in data directory are generated from the *.txt file,
via:
BASE="filename"
cat $BASE.txt | protoc --encode=google.census.Resource census.proto > $BASE.pb

@ -0,0 +1,5 @@
# Name is present, but empty.
name : ''
unit {
numerator : SECS
}

@ -0,0 +1,2 @@
full_resource"A resource with everything defined

@ -0,0 +1,9 @@
# A full resource definition - all fields filled out.
name : 'full_resource'
description : 'A resource with everything defined'
unit {
# Megabits per second.
prefix : 6
numerator : BITS
denominator : SECS
}

@ -0,0 +1,5 @@
# A minimal "good" Resource definition: has a name and numerator/unit.
name : 'minimal_good'
unit {
numerator : SECS
}

@ -0,0 +1,4 @@
# The minimal good Resource without a name.
unit {
numerator : SECS
}

@ -0,0 +1,2 @@
resource_no_numeratorýÿÿÿÿÿÿÿÿ

@ -0,0 +1,6 @@
# Resource without a numerator
name : 'resource_no_numerator'
unit {
prefix : -3
denominator : SECS
}

@ -0,0 +1,2 @@
# The minimal good resource without a unit
name : 'resource_no_unit'

@ -0,0 +1,157 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/ext/census/resource.h"
#include <grpc/census.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/useful.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "src/core/ext/census/base_resources.h"
#include "test/core/util/test_config.h"
// Test all the functionality for dealing with Resources.
// Just startup and shutdown resources subsystem.
static void test_enable_disable() {
initialize_resources();
shutdown_resources();
}
// A blank/empty initialization should not work.
static void test_empty_definition() {
initialize_resources();
int32_t rid = census_define_resource(NULL, 0);
GPR_ASSERT(rid == -1);
uint8_t buffer[50] = {0};
rid = census_define_resource(buffer, 50);
GPR_ASSERT(rid == -1);
shutdown_resources();
}
// Given a file name, read raw proto and define the resource included within.
// Returns resource id from census_define_resource().
static int32_t define_resource_from_file(const char *file) {
#define BUF_SIZE 512
uint8_t buffer[BUF_SIZE];
FILE *input = fopen(file, "rb");
GPR_ASSERT(input != NULL);
size_t nbytes = fread(buffer, 1, BUF_SIZE, input);
GPR_ASSERT(nbytes != 0 && nbytes < BUF_SIZE && feof(input) && !ferror(input));
int32_t rid = census_define_resource(buffer, nbytes);
GPR_ASSERT(fclose(input) == 0);
return rid;
}
// Test definition of a single resource, using a proto read from a file. The
// `succeed` parameter indicates whether we expect the definition to succeed or
// fail. `name` is used to check that the returned resource can be looked up by
// name.
static void test_define_single_resource(const char *file, const char *name,
bool succeed) {
gpr_log(GPR_INFO, "Test defining resource \"%s\"\n", name);
initialize_resources();
int32_t rid = define_resource_from_file(file);
if (succeed) {
GPR_ASSERT(rid >= 0);
int32_t rid2 = census_resource_id(name);
GPR_ASSERT(rid == rid2);
} else {
GPR_ASSERT(rid < 0);
}
shutdown_resources();
}
// Try deleting various resources (both those that exist and those that don't).
static void test_delete_resource() {
initialize_resources();
// Try deleting resource before any are defined.
census_delete_resource(0);
// Create and check a couple of resources.
int32_t rid1 = define_resource_from_file(
"test/core/census/data/resource_minimal_good.pb");
int32_t rid2 =
define_resource_from_file("test/core/census/data/resource_full.pb");
GPR_ASSERT(rid1 >= 0 && rid2 >= 0 && rid1 != rid2);
int32_t rid3 = census_resource_id("minimal_good");
int32_t rid4 = census_resource_id("full_resource");
GPR_ASSERT(rid1 == rid3 && rid2 == rid4);
// Try deleting non-existant resources.
census_delete_resource(-1);
census_delete_resource(rid1 + rid2 + 1);
census_delete_resource(10000000);
// Delete one of the previously defined resources and check for deletion.
census_delete_resource(rid1);
rid3 = census_resource_id("minimal_good");
GPR_ASSERT(rid3 < 0);
// Check that re-adding works.
rid1 = define_resource_from_file(
"test/core/census/data/resource_minimal_good.pb");
GPR_ASSERT(rid1 >= 0);
rid3 = census_resource_id("minimal_good");
GPR_ASSERT(rid1 == rid3);
shutdown_resources();
}
// Test define base resources.
static void test_base_resources() {
initialize_resources();
define_base_resources();
int32_t rid1 = census_resource_id("client_rpc_latency");
int32_t rid2 = census_resource_id("server_rpc_latency");
GPR_ASSERT(rid1 >= 0 && rid2 >= 0 && rid1 != rid2);
shutdown_resources();
}
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
test_enable_disable();
test_empty_definition();
test_define_single_resource("test/core/census/data/resource_minimal_good.pb",
"minimal_good", true);
test_define_single_resource("test/core/census/data/resource_full.pb",
"full_resource", true);
test_define_single_resource("test/core/census/data/resource_no_name.pb",
"resource_no_name", false);
test_define_single_resource("test/core/census/data/resource_no_numerator.pb",
"resource_no_numerator", false);
test_define_single_resource("test/core/census/data/resource_no_unit.pb",
"resource_no_unit", false);
test_define_single_resource("test/core/census/data/resource_empty_name.pb",
"resource_empty_name", false);
test_delete_resource();
test_base_resources();
return 0;
}

@ -21,8 +21,6 @@
"\x0A:authority" "\x0A:authority"
"\x0Dauthorization" "\x0Dauthorization"
"\x0Dcache-control" "\x0Dcache-control"
"\x0Acensus-bin"
"\x11census-binary-bin"
"\x13content-disposition" "\x13content-disposition"
"\x10content-encoding" "\x10content-encoding"
"\x10content-language" "\x10content-language"
@ -42,11 +40,13 @@
"\x03GET" "\x03GET"
"\x04grpc" "\x04grpc"
"\x14grpc-accept-encoding" "\x14grpc-accept-encoding"
"\x0Fgrpc-census-bin"
"\x0Dgrpc-encoding" "\x0Dgrpc-encoding"
"\x1Egrpc-internal-encoding-request" "\x1Egrpc-internal-encoding-request"
"\x0Cgrpc-message" "\x0Cgrpc-message"
"\x0Bgrpc-status" "\x0Bgrpc-status"
"\x0Cgrpc-timeout" "\x0Cgrpc-timeout"
"\x10grpc-tracing-bin"
"\x04gzip" "\x04gzip"
"\x0Dgzip, deflate" "\x0Dgzip, deflate"
"\x04host" "\x04host"

@ -68,9 +68,9 @@ int LimitCores(const int* cores, int cores_size) {
cores_set++; cores_set++;
} }
} }
GPR_ASSERT(sched_setaffinity(0, size, cpup) == 0); bool affinity_set = (sched_setaffinity(0, size, cpup) == 0);
CPU_FREE(cpup); CPU_FREE(cpup);
return cores_set; return affinity_set ? cores_set : num_cores;
} }
} // namespace testing } // namespace testing

@ -50,8 +50,8 @@ CONFIG = [
'host', 'host',
'grpc-message', 'grpc-message',
'grpc-status', 'grpc-status',
'census-bin', 'grpc-tracing-bin',
'census-binary-bin', 'grpc-census-bin',
'', '',
('grpc-status', '0'), ('grpc-status', '0'),
('grpc-status', '1'), ('grpc-status', '1'),

@ -200,6 +200,6 @@ validator = GuardValidator()
for filename in filename_list: for filename in filename_list:
if filename in KNOWN_BAD: continue if filename in KNOWN_BAD: continue
ok = validator.check(filename, args.fix) ok = ok and validator.check(filename, args.fix)
sys.exit(0 if ok else 1) sys.exit(0 if ok else 1)

@ -941,11 +941,13 @@ third_party/nanopb/pb_encode.h \
src/core/ext/load_reporting/load_reporting.h \ src/core/ext/load_reporting/load_reporting.h \
src/core/ext/load_reporting/load_reporting_filter.h \ src/core/ext/load_reporting/load_reporting_filter.h \
src/core/ext/census/aggregation.h \ src/core/ext/census/aggregation.h \
src/core/ext/census/base_resources.h \
src/core/ext/census/census_interface.h \ src/core/ext/census/census_interface.h \
src/core/ext/census/census_rpc_stats.h \ src/core/ext/census/census_rpc_stats.h \
src/core/ext/census/gen/census.pb.h \ src/core/ext/census/gen/census.pb.h \
src/core/ext/census/grpc_filter.h \ src/core/ext/census/grpc_filter.h \
src/core/ext/census/mlog.h \ src/core/ext/census/mlog.h \
src/core/ext/census/resource.h \
src/core/ext/census/rpc_metric_id.h \ src/core/ext/census/rpc_metric_id.h \
src/core/lib/surface/init.c \ src/core/lib/surface/init.c \
src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_args.c \
@ -1124,6 +1126,7 @@ src/core/ext/resolver/dns/native/dns_resolver.c \
src/core/ext/resolver/sockaddr/sockaddr_resolver.c \ src/core/ext/resolver/sockaddr/sockaddr_resolver.c \
src/core/ext/load_reporting/load_reporting.c \ src/core/ext/load_reporting/load_reporting.c \
src/core/ext/load_reporting/load_reporting_filter.c \ src/core/ext/load_reporting/load_reporting_filter.c \
src/core/ext/census/base_resources.c \
src/core/ext/census/context.c \ src/core/ext/census/context.c \
src/core/ext/census/gen/census.pb.c \ src/core/ext/census/gen/census.pb.c \
src/core/ext/census/grpc_context.c \ src/core/ext/census/grpc_context.c \
@ -1133,6 +1136,7 @@ src/core/ext/census/initialize.c \
src/core/ext/census/mlog.c \ src/core/ext/census/mlog.c \
src/core/ext/census/operation.c \ src/core/ext/census/operation.c \
src/core/ext/census/placeholders.c \ src/core/ext/census/placeholders.c \
src/core/ext/census/resource.c \
src/core/ext/census/tracing.c \ src/core/ext/census/tracing.c \
src/core/plugin_registry/grpc_plugin_registry.c \ src/core/plugin_registry/grpc_plugin_registry.c \
include/grpc/support/alloc.h \ include/grpc/support/alloc.h \

@ -140,6 +140,22 @@
"third_party": false, "third_party": false,
"type": "target" "type": "target"
}, },
{
"deps": [
"gpr",
"gpr_test_util",
"grpc",
"grpc_test_util"
],
"headers": [],
"language": "c",
"name": "census_resource_test",
"src": [
"test/core/census/resource_test.c"
],
"third_party": false,
"type": "target"
},
{ {
"deps": [ "deps": [
"gpr", "gpr",
@ -5528,11 +5544,13 @@
"headers": [ "headers": [
"include/grpc/census.h", "include/grpc/census.h",
"src/core/ext/census/aggregation.h", "src/core/ext/census/aggregation.h",
"src/core/ext/census/base_resources.h",
"src/core/ext/census/census_interface.h", "src/core/ext/census/census_interface.h",
"src/core/ext/census/census_rpc_stats.h", "src/core/ext/census/census_rpc_stats.h",
"src/core/ext/census/gen/census.pb.h", "src/core/ext/census/gen/census.pb.h",
"src/core/ext/census/grpc_filter.h", "src/core/ext/census/grpc_filter.h",
"src/core/ext/census/mlog.h", "src/core/ext/census/mlog.h",
"src/core/ext/census/resource.h",
"src/core/ext/census/rpc_metric_id.h" "src/core/ext/census/rpc_metric_id.h"
], ],
"language": "c", "language": "c",
@ -5540,6 +5558,8 @@
"src": [ "src": [
"include/grpc/census.h", "include/grpc/census.h",
"src/core/ext/census/aggregation.h", "src/core/ext/census/aggregation.h",
"src/core/ext/census/base_resources.c",
"src/core/ext/census/base_resources.h",
"src/core/ext/census/census_interface.h", "src/core/ext/census/census_interface.h",
"src/core/ext/census/census_rpc_stats.h", "src/core/ext/census/census_rpc_stats.h",
"src/core/ext/census/context.c", "src/core/ext/census/context.c",
@ -5554,6 +5574,8 @@
"src/core/ext/census/mlog.h", "src/core/ext/census/mlog.h",
"src/core/ext/census/operation.c", "src/core/ext/census/operation.c",
"src/core/ext/census/placeholders.c", "src/core/ext/census/placeholders.c",
"src/core/ext/census/resource.c",
"src/core/ext/census/resource.h",
"src/core/ext/census/rpc_metric_id.h", "src/core/ext/census/rpc_metric_id.h",
"src/core/ext/census/tracing.c" "src/core/ext/census/tracing.c"
], ],

@ -169,6 +169,27 @@
"windows" "windows"
] ]
}, },
{
"args": [],
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"flaky": false,
"gtest": false,
"language": "c",
"name": "census_resource_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
]
},
{ {
"args": [], "args": [],
"ci_platforms": [ "ci_platforms": [

@ -109,6 +109,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "census_context_test", "vcxp
{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "census_resource_test", "vcxproj\test\census_resource_test\census_resource_test.vcxproj", "{18CF99B5-3C61-EC3D-9509-3C95334C3B88}"
ProjectSection(myProperties) = preProject
lib = "False"
EndProjectSection
ProjectSection(ProjectDependencies) = postProject
{17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} = {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}
{29D16885-7228-4C31-81ED-5F9187C7F2A9} = {29D16885-7228-4C31-81ED-5F9187C7F2A9}
{EAB0A629-17A9-44DB-B5FF-E91A721FE037} = {EAB0A629-17A9-44DB-B5FF-E91A721FE037}
{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "channel_create_test", "vcxproj\test\channel_create_test\channel_create_test.vcxproj", "{AFC88484-3A2E-32BC-25B2-23DF741D4F3D}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "channel_create_test", "vcxproj\test\channel_create_test\channel_create_test.vcxproj", "{AFC88484-3A2E-32BC-25B2-23DF741D4F3D}"
ProjectSection(myProperties) = preProject ProjectSection(myProperties) = preProject
lib = "False" lib = "False"
@ -1599,6 +1610,22 @@ Global
{5C1CFC2D-AF3C-D7CB-BA74-D267E91CBC73}.Release-DLL|Win32.Build.0 = Release|Win32 {5C1CFC2D-AF3C-D7CB-BA74-D267E91CBC73}.Release-DLL|Win32.Build.0 = Release|Win32
{5C1CFC2D-AF3C-D7CB-BA74-D267E91CBC73}.Release-DLL|x64.ActiveCfg = Release|x64 {5C1CFC2D-AF3C-D7CB-BA74-D267E91CBC73}.Release-DLL|x64.ActiveCfg = Release|x64
{5C1CFC2D-AF3C-D7CB-BA74-D267E91CBC73}.Release-DLL|x64.Build.0 = Release|x64 {5C1CFC2D-AF3C-D7CB-BA74-D267E91CBC73}.Release-DLL|x64.Build.0 = Release|x64
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Debug|Win32.ActiveCfg = Debug|Win32
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Debug|x64.ActiveCfg = Debug|x64
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Release|Win32.ActiveCfg = Release|Win32
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Release|x64.ActiveCfg = Release|x64
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Debug|Win32.Build.0 = Debug|Win32
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Debug|x64.Build.0 = Debug|x64
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Release|Win32.Build.0 = Release|Win32
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Release|x64.Build.0 = Release|x64
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Debug-DLL|Win32.ActiveCfg = Debug|Win32
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Debug-DLL|Win32.Build.0 = Debug|Win32
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Debug-DLL|x64.ActiveCfg = Debug|x64
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Debug-DLL|x64.Build.0 = Debug|x64
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Release-DLL|Win32.ActiveCfg = Release|Win32
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Release-DLL|Win32.Build.0 = Release|Win32
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Release-DLL|x64.ActiveCfg = Release|x64
{18CF99B5-3C61-EC3D-9509-3C95334C3B88}.Release-DLL|x64.Build.0 = Release|x64
{AFC88484-3A2E-32BC-25B2-23DF741D4F3D}.Debug|Win32.ActiveCfg = Debug|Win32 {AFC88484-3A2E-32BC-25B2-23DF741D4F3D}.Debug|Win32.ActiveCfg = Debug|Win32
{AFC88484-3A2E-32BC-25B2-23DF741D4F3D}.Debug|x64.ActiveCfg = Debug|x64 {AFC88484-3A2E-32BC-25B2-23DF741D4F3D}.Debug|x64.ActiveCfg = Debug|x64
{AFC88484-3A2E-32BC-25B2-23DF741D4F3D}.Release|Win32.ActiveCfg = Release|Win32 {AFC88484-3A2E-32BC-25B2-23DF741D4F3D}.Release|Win32.ActiveCfg = Release|Win32

@ -450,11 +450,13 @@
<ClInclude Include="$(SolutionDir)\..\src\core\ext\load_reporting\load_reporting.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\load_reporting\load_reporting.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\load_reporting\load_reporting_filter.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\load_reporting\load_reporting_filter.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\aggregation.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\aggregation.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\base_resources.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_interface.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_interface.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_rpc_stats.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_rpc_stats.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\gen\census.pb.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\gen\census.pb.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\grpc_filter.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\grpc_filter.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\mlog.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\mlog.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\resource.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\rpc_metric_id.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\rpc_metric_id.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -812,6 +814,8 @@
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\load_reporting\load_reporting_filter.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\load_reporting\load_reporting_filter.c">
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\base_resources.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\context.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\context.c">
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\gen\census.pb.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\gen\census.pb.c">
@ -830,6 +834,8 @@
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\placeholders.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\placeholders.c">
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\resource.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\tracing.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\tracing.c">
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\plugin_registry\grpc_plugin_registry.c"> <ClCompile Include="$(SolutionDir)\..\src\core\plugin_registry\grpc_plugin_registry.c">

@ -532,6 +532,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\ext\load_reporting\load_reporting_filter.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\load_reporting\load_reporting_filter.c">
<Filter>src\core\ext\load_reporting</Filter> <Filter>src\core\ext\load_reporting</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\base_resources.c">
<Filter>src\core\ext\census</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\context.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\context.c">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClCompile> </ClCompile>
@ -559,6 +562,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\placeholders.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\placeholders.c">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\resource.c">
<Filter>src\core\ext\census</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\tracing.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\tracing.c">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClCompile> </ClCompile>
@ -1112,6 +1118,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\aggregation.h"> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\aggregation.h">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\base_resources.h">
<Filter>src\core\ext\census</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_interface.h"> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_interface.h">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClInclude> </ClInclude>
@ -1127,6 +1136,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\mlog.h"> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\mlog.h">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\resource.h">
<Filter>src\core\ext\census</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\rpc_metric_id.h"> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\rpc_metric_id.h">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClInclude> </ClInclude>

@ -415,11 +415,13 @@
<ClInclude Include="$(SolutionDir)\..\third_party\nanopb\pb_decode.h" /> <ClInclude Include="$(SolutionDir)\..\third_party\nanopb\pb_decode.h" />
<ClInclude Include="$(SolutionDir)\..\third_party\nanopb\pb_encode.h" /> <ClInclude Include="$(SolutionDir)\..\third_party\nanopb\pb_encode.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\aggregation.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\aggregation.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\base_resources.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_interface.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_interface.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_rpc_stats.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_rpc_stats.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\gen\census.pb.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\gen\census.pb.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\grpc_filter.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\grpc_filter.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\mlog.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\mlog.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\resource.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\rpc_metric_id.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\rpc_metric_id.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -719,6 +721,8 @@
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\round_robin\round_robin.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\round_robin\round_robin.c">
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\base_resources.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\context.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\context.c">
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\gen\census.pb.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\gen\census.pb.c">
@ -737,6 +741,8 @@
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\placeholders.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\placeholders.c">
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\resource.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\tracing.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\tracing.c">
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\plugin_registry\grpc_unsecure_plugin_registry.c"> <ClCompile Include="$(SolutionDir)\..\src\core\plugin_registry\grpc_unsecure_plugin_registry.c">

@ -445,6 +445,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\round_robin\round_robin.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\lb_policy\round_robin\round_robin.c">
<Filter>src\core\ext\lb_policy\round_robin</Filter> <Filter>src\core\ext\lb_policy\round_robin</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\base_resources.c">
<Filter>src\core\ext\census</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\context.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\context.c">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClCompile> </ClCompile>
@ -472,6 +475,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\placeholders.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\placeholders.c">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\resource.c">
<Filter>src\core\ext\census</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\ext\census\tracing.c"> <ClCompile Include="$(SolutionDir)\..\src\core\ext\census\tracing.c">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClCompile> </ClCompile>
@ -947,6 +953,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\aggregation.h"> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\aggregation.h">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\base_resources.h">
<Filter>src\core\ext\census</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_interface.h"> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\census_interface.h">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClInclude> </ClInclude>
@ -962,6 +971,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\mlog.h"> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\mlog.h">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\resource.h">
<Filter>src\core\ext\census</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\ext\census\rpc_metric_id.h"> <ClInclude Include="$(SolutionDir)\..\src\core\ext\census\rpc_metric_id.h">
<Filter>src\core\ext\census</Filter> <Filter>src\core\ext\census</Filter>
</ClInclude> </ClInclude>

@ -0,0 +1,199 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\1.0.204.1.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{18CF99B5-3C61-EC3D-9509-3C95334C3B88}</ProjectGuid>
<IgnoreWarnIntDirInTempDetected>true</IgnoreWarnIntDirInTempDetected>
<IntDir>$(SolutionDir)IntDir\$(MSBuildProjectName)\</IntDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(VisualStudioVersion)' == '10.0'" Label="Configuration">
<PlatformToolset>v100</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0'" Label="Configuration">
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '12.0'" Label="Configuration">
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '14.0'" Label="Configuration">
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(SolutionDir)\..\vsprojects\global.props" />
<Import Project="$(SolutionDir)\..\vsprojects\openssl.props" />
<Import Project="$(SolutionDir)\..\vsprojects\winsock.props" />
<Import Project="$(SolutionDir)\..\vsprojects\zlib.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<TargetName>census_resource_test</TargetName>
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib>
<Configuration-grpc_dependencies_zlib>Debug</Configuration-grpc_dependencies_zlib>
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl>
<Configuration-grpc_dependencies_openssl>Debug</Configuration-grpc_dependencies_openssl>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<TargetName>census_resource_test</TargetName>
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib>
<Configuration-grpc_dependencies_zlib>Release</Configuration-grpc_dependencies_zlib>
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl>
<Configuration-grpc_dependencies_openssl>Release</Configuration-grpc_dependencies_openssl>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat>
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation>
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat>
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation>
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat>
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation>
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat>
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation>
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="$(SolutionDir)\..\test\core\census\resource_test.c">
</ClCompile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc_test_util\grpc_test_util.vcxproj">
<Project>{17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}</Project>
</ProjectReference>
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc\grpc.vcxproj">
<Project>{29D16885-7228-4C31-81ED-5F9187C7F2A9}</Project>
</ProjectReference>
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr_test_util\gpr_test_util.vcxproj">
<Project>{EAB0A629-17A9-44DB-B5FF-E91A721FE037}</Project>
</ProjectReference>
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr\gpr.vcxproj">
<Project>{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" />
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" />
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" />
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" />
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" />
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" />
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" />
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" />
</Target>
</Project>

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="$(SolutionDir)\..\test\core\census\resource_test.c">
<Filter>test\core\census</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="test">
<UniqueIdentifier>{313aad4e-d33b-88c5-7d94-e04a4cb0c912}</UniqueIdentifier>
</Filter>
<Filter Include="test\core">
<UniqueIdentifier>{ff2d74ef-228a-1739-7fa7-7dccbec5b0c5}</UniqueIdentifier>
</Filter>
<Filter Include="test\core\census">
<UniqueIdentifier>{4f529bd9-396f-027c-bc49-f9a6bbc97c72}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
Loading…
Cancel
Save