You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2022/07/27 12:05:31 UTC

[rocketmq-clients] branch cpp_cmake updated (7927146 -> c7040f5)

This is an automated email from the ASF dual-hosted git repository.

lizhanhui pushed a change to branch cpp_cmake
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git


    from 7927146  WIP: build stats with cmake
     new 130b0ca  WIP
     new c7040f5  WIP: Support build with cmake

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 cpp/source/CMakeLists.txt                          |   6 +-
 .../rocketmq/AsyncReceiveMessageCallback.cpp       |   3 +-
 cpp/source/rocketmq/CMakeLists.txt                 |   4 +
 cpp/source/rocketmq/ClientImpl.cpp                 |   3 +-
 cpp/source/rocketmq/ConsumeMessageServiceImpl.cpp  |   3 +-
 cpp/source/rocketmq/ConsumeTask.cpp                |   3 +-
 cpp/source/rocketmq/TopicPublishInfo.cpp           |   3 +-
 cpp/source/rocketmq/include/ProcessQueueImpl.h     |   3 -
 cpp/source/stats/CMakeLists.txt                    |   3 +-
 cpp/source/trace/CMakeLists.txt                    |  13 +
 cpp/third_party/CMakeLists.txt                     |   2 +-
 .../0.4.0/opencensus/common/internal/hash_mix.h    |  49 ---
 .../opencensus/0.4.0/opencensus/doc/benchmarks.md  |  35 --
 .../exporters/stats/stdout/CMakeLists.txt          |  30 --
 .../exporters/trace/stdout/CMakeLists.txt          |  28 --
 .../0.4.0/opencensus/stats/CMakeLists.txt          | 129 --------
 .../0.4.0/opencensus/tags/CMakeLists.txt           |  41 ---
 .../0.4.0/opencensus/trace/CMakeLists.txt          | 238 --------------
 .../{0.4.0 => 0.5.0-alpha}/CMakeLists.txt          |   0
 cpp/third_party/opencensus/0.5.0-alpha/README.md   |   1 +
 .../{0.4.0 => 0.5.0-alpha}/opencensus/BUILD        |   0
 .../opencensus/CMakeLists.txt                      |   0
 .../{0.4.0 => 0.5.0-alpha}/opencensus/common/BUILD |   0
 .../opencensus/common/CMakeLists.txt               |   0
 .../opencensus/common/internal/BUILD               |  75 ++++-
 .../opencensus/common/internal/CMakeLists.txt      |  42 ++-
 .../opencensus/common/internal/grpc/BUILD          |   0
 .../opencensus/common/internal/grpc/status.cc      |   0
 .../opencensus/common/internal/grpc/status.h       |   0
 .../opencensus/common/internal/grpc/status_test.cc |   0
 .../common/internal/grpc/with_user_agent.cc        |   0
 .../common/internal/grpc/with_user_agent.h         |   0
 .../opencensus/common/internal/hostname.cc         |  69 ++++
 .../opencensus/common/internal/hostname.h}         |  18 +-
 .../opencensus/common/internal/hostname_test.cc}   |  20 +-
 .../opencensus/common/internal/random.cc           |   0
 .../opencensus/common/internal/random.h            |   4 +-
 .../opencensus/common/internal/random_benchmark.cc |   0
 .../opencensus/common/internal/random_test.cc      |   0
 .../opencensus/common/internal/stats_object.h      |   2 +-
 .../common/internal/stats_object_test.cc           |   0
 .../common/internal/string_vector_hash.h           |   9 +-
 .../opencensus/common/internal/timestamp.cc}       |  19 +-
 .../opencensus/common/internal/timestamp.h}        |  17 +-
 .../common/internal/timestamp_benchmark.cc}        |  29 +-
 .../opencensus/common/internal/timestamp_test.cc   |  40 +++
 .../opencensus/common/internal/varint.cc           |  59 ++++
 .../opencensus/common/internal/varint.h}           |  19 +-
 .../opencensus/common/internal/varint_test.cc      |  75 +++++
 .../opencensus/common/version.h                    |   2 +-
 .../opencensus/context/BUILD                       |   1 -
 .../opencensus/context/CMakeLists.txt              |  32 +-
 .../opencensus/context/README.md                   |   0
 .../opencensus/context/context.h                   |   1 +
 .../opencensus/context/internal/context.cc         |  21 +-
 .../context/internal/context_benchmark.cc          |   0
 .../opencensus/context/internal/context_test.cc    |  13 +
 .../opencensus/context/internal/with_context.cc    |   0
 .../context/internal/with_context_test.cc          |   0
 .../opencensus/context/with_context.h              |   0
 .../{0.4.0 => 0.5.0-alpha}/opencensus/copts.bzl    |   9 +-
 .../{0.4.0 => 0.5.0-alpha}/opencensus/curl.bzl     |   1 -
 .../0.5.0-alpha/opencensus/doc/benchmarks.md       |  59 ++++
 .../opencensus/doc/context.md                      |   0
 .../opencensus/doc/conventions.md                  |   0
 .../opencensus/doc/fuzzing.md                      |   0
 .../opencensus/exporters/CMakeLists.txt            |   0
 .../opencensus/exporters/stats/CMakeLists.txt      |   4 -
 .../opencensus/exporters/stats/stdout/BUILD        |   0
 .../exporters/stats/stdout}/CMakeLists.txt         |  16 +-
 .../stats/stdout/internal/stdout_exporter.cc       |  24 +-
 .../stats/stdout/internal/stdout_exporter_test.cc  |   0
 .../exporters/stats/stdout/stdout_exporter.h       |   0
 .../opencensus/exporters/trace/CMakeLists.txt      |   0
 .../opencensus/exporters/trace/ocagent}/BUILD      |  29 +-
 .../opencensus/exporters/trace/ocagent/README.md   |  75 +++++
 .../trace/ocagent/internal/ocagent_exporter.cc     | 359 +++++++++++++++++++++
 .../ocagent/internal/ocagent_exporter_test.cc}     |  34 +-
 .../exporters/trace/ocagent/ocagent_exporter.h     |  60 ++++
 .../opencensus/exporters/trace/stackdriver/BUILD   |   5 +-
 .../exporters/trace/stackdriver/README.md          |   0
 .../stackdriver/internal/stackdriver_exporter.cc   |  43 +--
 .../trace/stackdriver/stackdriver_exporter.h       |  12 +-
 .../opencensus/exporters/trace/stdout/BUILD        |   0
 .../exporters/trace/stdout}/CMakeLists.txt         |  15 +-
 .../trace/stdout/internal/stdout_exporter.cc       |   0
 .../trace/stdout/internal/stdout_exporter_test.cc  |   0
 .../exporters/trace/stdout/stdout_exporter.h       |   0
 .../opencensus/exporters/trace/zipkin/BUILD        |   1 -
 .../opencensus/exporters/trace/zipkin/README.md    |   0
 .../trace/zipkin/internal/zipkin_exporter.cc       |   8 +-
 .../trace/zipkin/internal/zipkin_exporter_test.cc  |   1 -
 .../exporters/trace/zipkin/zipkin_exporter.h       |   2 +-
 .../{0.4.0 => 0.5.0-alpha}/opencensus/stats/BUILD  |   1 -
 .../0.5.0-alpha/opencensus/stats/CMakeLists.txt    | 115 +++++++
 .../opencensus/stats/README.md                     |   0
 .../opencensus/stats/aggregation.h                 |   0
 .../opencensus/stats/bucket_boundaries.h           |   0
 .../opencensus/stats/distribution.h                |   0
 .../opencensus/stats/examples/BUILD                |   0
 .../opencensus/stats/examples/exporter_example.cc  |   8 +-
 .../stats/examples/view_and_recording_example.cc   |   0
 .../opencensus/stats/internal/aggregation.cc       |   0
 .../stats/internal/aggregation_window.cc           |   0
 .../opencensus/stats/internal/aggregation_window.h |   0
 .../opencensus/stats/internal/bucket_boundaries.cc |   0
 .../stats/internal/bucket_boundaries_test.cc       |   0
 .../opencensus/stats/internal/debug_string_test.cc |   0
 .../opencensus/stats/internal/delta_producer.cc    |   0
 .../opencensus/stats/internal/delta_producer.h     |  20 +-
 .../opencensus/stats/internal/distribution.cc      |   0
 .../opencensus/stats/internal/distribution_test.cc |   0
 .../opencensus/stats/internal/measure.cc           |   0
 .../opencensus/stats/internal/measure_data.cc      |   0
 .../opencensus/stats/internal/measure_data.h       |   0
 .../opencensus/stats/internal/measure_data_test.cc |   0
 .../stats/internal/measure_descriptor.cc           |   0
 .../opencensus/stats/internal/measure_registry.cc  |   0
 .../stats/internal/measure_registry_impl.cc        |   6 +-
 .../stats/internal/measure_registry_impl.h         |  28 +-
 .../stats/internal/measure_registry_test.cc        |  14 +
 .../opencensus/stats/internal/recording.cc         |   0
 .../stats/internal/set_aggregation_window.cc       |   0
 .../stats/internal/set_aggregation_window.h        |   0
 .../opencensus/stats/internal/stats_exporter.cc    |  29 +-
 .../stats/internal/stats_exporter_impl.h           |  24 +-
 .../stats/internal/stats_exporter_test.cc          |  57 ++--
 .../opencensus/stats/internal/stats_manager.cc     |   0
 .../opencensus/stats/internal/stats_manager.h      |  18 +-
 .../stats/internal/stats_manager_benchmark.cc      |   0
 .../stats/internal/stats_manager_test.cc           |   0
 .../opencensus/stats/internal/view.cc              |   0
 .../opencensus/stats/internal/view_data.cc         |  13 +-
 .../opencensus/stats/internal/view_data_impl.cc    |  94 +++++-
 .../opencensus/stats/internal/view_data_impl.h     |  41 ++-
 .../stats/internal/view_data_impl_test.cc          |  70 ++--
 .../opencensus/stats/internal/view_data_test.cc    |   0
 .../opencensus/stats/internal/view_descriptor.cc   |  12 +-
 .../opencensus/stats/measure.h                     |   0
 .../opencensus/stats/measure_descriptor.h          |   0
 .../opencensus/stats/measure_registry.h            |   0
 .../opencensus/stats/recording.h                   |   0
 .../opencensus/stats/stats.h                       |   0
 .../opencensus/stats/stats_exporter.h              |   9 +
 .../opencensus/stats/tag_key.h                     |   0
 .../opencensus/stats/tag_set.h                     |   0
 .../opencensus/stats/testing/test_utils.cc         |  21 +-
 .../opencensus/stats/testing/test_utils.h          |  13 +
 .../{0.4.0 => 0.5.0-alpha}/opencensus/stats/view.h |   0
 .../opencensus/stats/view_data.h                   |   9 +
 .../opencensus/stats/view_descriptor.h             |   6 +
 .../{0.4.0 => 0.5.0-alpha}/opencensus/tags/BUILD   |  59 +++-
 .../0.5.0-alpha/opencensus/tags/CMakeLists.txt     |  77 +++++
 .../opencensus/tags/README.md                      |   0
 .../opencensus/tags/context_util.h                 |   0
 .../opencensus/tags/internal/context_util.cc       |   0
 .../opencensus/tags/internal/context_util_test.cc  |   0
 .../opencensus/tags/internal/grpc_tags_bin.cc      | 129 ++++++++
 .../tags/internal/grpc_tags_bin_benchmark.cc}      |  42 +--
 .../tags/internal/grpc_tags_bin_corpus/kv          | Bin 0 -> 9 bytes
 .../tags/internal/grpc_tags_bin_fuzzer.cc}         |  15 +-
 .../opencensus/tags/internal/grpc_tags_bin_test.cc | 169 ++++++++++
 .../opencensus/tags/internal/tag_key.cc            |  19 +-
 .../opencensus/tags/internal/tag_key_test.cc       |  18 +-
 .../opencensus/tags/internal/tag_map.cc            |  10 +-
 .../opencensus/tags/internal/tag_map_benchmark.cc  |   0
 .../opencensus/tags/internal/tag_map_test.cc       |   0
 .../opencensus/tags/internal/with_tag_map.cc       |   0
 .../tags/internal/with_tag_map_benchmark.cc        |   0
 .../opencensus/tags/internal/with_tag_map_test.cc  |   0
 .../opencensus/tags/propagation/grpc_tags_bin.h    |  42 +++
 .../opencensus/tags/tag_key.h                      |  10 +
 .../opencensus/tags/tag_map.h                      |   0
 .../opencensus/tags/with_tag_map.h                 |   0
 .../{0.4.0 => 0.5.0-alpha}/opencensus/trace/BUILD  |  63 ++++
 .../0.5.0-alpha/opencensus/trace/CMakeLists.txt    | 229 +++++++++++++
 .../opencensus/trace/README.md                     |   0
 .../opencensus/trace/attribute_value_ref.h         |   0
 .../opencensus/trace/context_util.h                |   0
 .../opencensus/trace/examples/BUILD                |   0
 .../opencensus/trace/examples/span_example.cc      |   0
 .../opencensus/trace/exporter/annotation.h         |   0
 .../opencensus/trace/exporter/attribute_value.h    |   0
 .../opencensus/trace/exporter/link.h               |   0
 .../opencensus/trace/exporter/message_event.h      |   0
 .../opencensus/trace/exporter/span_data.h          |   0
 .../opencensus/trace/exporter/span_exporter.h      |  18 ++
 .../opencensus/trace/exporter/status.h             |   0
 .../opencensus/trace/internal/annotation.cc        |   0
 .../opencensus/trace/internal/annotation_test.cc   |   0
 .../opencensus/trace/internal/attribute_list.cc    |   0
 .../opencensus/trace/internal/attribute_list.h     |   0
 .../opencensus/trace/internal/attribute_value.cc   |   0
 .../trace/internal/attribute_value_ref.cc          |   0
 .../internal/attribute_value_ref_benchmark.cc      |   0
 .../trace/internal/attribute_value_ref_test.cc     |   0
 .../trace/internal/attribute_value_test.cc         |   0
 .../0.5.0-alpha/opencensus/trace/internal/b3.cc    | 113 +++++++
 .../opencensus/trace/internal/b3_benchmark.cc}     |  28 +-
 .../trace/internal/b3_corpus/trace_id_64bit        |   1 +
 .../opencensus/trace/internal/b3_fuzzer.cc}        |  23 +-
 .../opencensus/trace/internal/b3_test.cc           | 118 +++++++
 .../trace/internal/cloud_trace_context.cc          |   0
 .../internal/cloud_trace_context_benchmark.cc      |   0
 .../cloud_trace_context_corpus/span_id_overflow    |   0
 .../internal/cloud_trace_context_corpus/valid      |   0
 .../trace/internal/cloud_trace_context_fuzzer.cc   |   0
 .../trace/internal/cloud_trace_context_test.cc     |   0
 .../opencensus/trace/internal/context_util.cc      |   0
 .../opencensus/trace/internal/context_util_test.cc |   0
 .../opencensus/trace/internal/event_with_time.h    |   0
 .../opencensus/trace/internal/grpc_trace_bin.cc    |   0
 .../trace/internal/grpc_trace_bin_benchmark.cc     |   0
 .../trace/internal/grpc_trace_bin_corpus/valid     | Bin
 .../trace/internal/grpc_trace_bin_fuzzer.cc        |   2 +-
 .../trace/internal/grpc_trace_bin_test.cc          |   0
 .../opencensus/trace/internal/link.cc              |   0
 .../opencensus/trace/internal/link_test.cc         |   0
 .../opencensus/trace/internal/local_span_store.cc  |   0
 .../opencensus/trace/internal/local_span_store.h   |   0
 .../trace/internal/local_span_store_impl.cc        |   0
 .../trace/internal/local_span_store_impl.h         |  15 +-
 .../trace/internal/local_span_store_test.cc        |   0
 .../opencensus/trace/internal/message_event.cc     |   0
 .../trace/internal/running_span_store.cc           |   0
 .../opencensus/trace/internal/running_span_store.h |   0
 .../trace/internal/running_span_store_impl.cc      |   2 +-
 .../trace/internal/running_span_store_impl.h       |  13 +-
 .../trace/internal/running_span_store_test.cc      |   0
 .../opencensus/trace/internal/sampler.cc           |   4 +-
 .../opencensus/trace/internal/sampler_benchmark.cc |  53 +++
 .../opencensus/trace/internal/sampler_test.cc      |   0
 .../opencensus/trace/internal/span.cc              |   0
 .../opencensus/trace/internal/span_benchmark.cc    |   0
 .../opencensus/trace/internal/span_context.cc      |   0
 .../opencensus/trace/internal/span_context_test.cc |   0
 .../opencensus/trace/internal/span_data.cc         |   0
 .../opencensus/trace/internal/span_exporter.cc     |  11 +
 .../trace/internal/span_exporter_impl.cc           |  51 +--
 .../opencensus/trace/internal/span_exporter_impl.h |  31 +-
 .../trace/internal/span_exporter_test.cc           |   6 +-
 .../opencensus/trace/internal/span_id.cc           |   2 +
 .../opencensus/trace/internal/span_id_benchmark.cc |   0
 .../opencensus/trace/internal/span_id_test.cc      |   0
 .../opencensus/trace/internal/span_impl.cc         |   5 +
 .../opencensus/trace/internal/span_impl.h          |  40 +--
 .../opencensus/trace/internal/span_options_test.cc |   2 +-
 .../opencensus/trace/internal/span_test.cc         |   0
 .../opencensus/trace/internal/status.cc            |   0
 .../opencensus/trace/internal/status_test.cc       |   0
 .../opencensus/trace/internal/trace_config.cc      |   0
 .../opencensus/trace/internal/trace_config_impl.cc |   0
 .../opencensus/trace/internal/trace_config_impl.h  |   0
 .../opencensus/trace/internal/trace_config_test.cc |   0
 .../opencensus/trace/internal/trace_context.cc     |   0
 .../trace/internal/trace_context_benchmark.cc      |   0
 .../internal/trace_context_corpus/bad_options      |   0
 .../internal/trace_context_corpus/bad_span_id      |   0
 .../internal/trace_context_corpus/bad_trace_id     |   0
 .../trace/internal/trace_context_corpus/valid      |   0
 .../trace/internal/trace_context_fuzzer.cc         |   0
 .../trace/internal/trace_context_test.cc           |   0
 .../opencensus/trace/internal/trace_events.h       |   0
 .../opencensus/trace/internal/trace_id.cc          |   2 +
 .../opencensus/trace/internal/trace_options.cc     |   0
 .../trace/internal/trace_options_test.cc           |   0
 .../opencensus/trace/internal/trace_params_impl.h  |   0
 .../opencensus/trace/internal/with_span.cc         |   0
 .../trace/internal/with_span_benchmark.cc          |   0
 .../opencensus/trace/internal/with_span_test.cc    |   0
 .../0.5.0-alpha/opencensus/trace/propagation/b3.h  |  68 ++++
 .../trace/propagation/cloud_trace_context.h        |   0
 .../opencensus/trace/propagation/grpc_trace_bin.h  |   0
 .../opencensus/trace/propagation/trace_context.h   |   0
 .../opencensus/trace/sampler.h                     |   0
 .../{0.4.0 => 0.5.0-alpha}/opencensus/trace/span.h |   0
 .../opencensus/trace/span_context.h                |   0
 .../opencensus/trace/span_id.h                     |   3 +
 .../opencensus/trace/status_code.h                 |   0
 .../opencensus/trace/trace_config.h                |   0
 .../opencensus/trace/trace_id.h                    |   3 +
 .../opencensus/trace/trace_options.h               |   0
 .../opencensus/trace/trace_params.h                |   0
 .../opencensus/trace/with_span.h                   |   0
 284 files changed, 3006 insertions(+), 1019 deletions(-)
 create mode 100644 cpp/source/trace/CMakeLists.txt
 delete mode 100644 cpp/third_party/opencensus/0.4.0/opencensus/common/internal/hash_mix.h
 delete mode 100644 cpp/third_party/opencensus/0.4.0/opencensus/doc/benchmarks.md
 delete mode 100644 cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/stdout/CMakeLists.txt
 delete mode 100644 cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stdout/CMakeLists.txt
 delete mode 100644 cpp/third_party/opencensus/0.4.0/opencensus/stats/CMakeLists.txt
 delete mode 100644 cpp/third_party/opencensus/0.4.0/opencensus/tags/CMakeLists.txt
 delete mode 100644 cpp/third_party/opencensus/0.4.0/opencensus/trace/CMakeLists.txt
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/CMakeLists.txt (100%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/README.md
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/BUILD (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/CMakeLists.txt (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/BUILD (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/CMakeLists.txt (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/BUILD (59%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/CMakeLists.txt (54%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/grpc/BUILD (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/grpc/status.cc (100%)
 copy cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/grpc/status.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/grpc/status_test.cc (100%)
 copy cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/grpc/with_user_agent.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/grpc/with_user_agent.h (100%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/hostname.cc
 copy cpp/third_party/opencensus/{0.4.0/opencensus/common/internal/grpc/status.h => 0.5.0-alpha/opencensus/common/internal/hostname.h} (63%)
 copy cpp/third_party/opencensus/{0.4.0/opencensus/common/internal/grpc/status.h => 0.5.0-alpha/opencensus/common/internal/hostname_test.cc} (64%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/random.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/random.h (95%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/random_benchmark.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/random_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/stats_object.h (99%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/stats_object_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/internal/string_vector_hash.h (83%)
 rename cpp/third_party/opencensus/{0.4.0/opencensus/common/internal/grpc/with_user_agent.cc => 0.5.0-alpha/opencensus/common/internal/timestamp.cc} (60%)
 copy cpp/third_party/opencensus/{0.4.0/opencensus/common/internal/grpc/status.h => 0.5.0-alpha/opencensus/common/internal/timestamp.h} (64%)
 copy cpp/third_party/opencensus/{0.4.0/opencensus/stats/internal/set_aggregation_window.cc => 0.5.0-alpha/opencensus/common/internal/timestamp_benchmark.cc} (53%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/timestamp_test.cc
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/varint.cc
 rename cpp/third_party/opencensus/{0.4.0/opencensus/common/internal/grpc/status.h => 0.5.0-alpha/opencensus/common/internal/varint.h} (54%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/varint_test.cc
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/common/version.h (95%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/context/BUILD (96%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/context/CMakeLists.txt (63%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/context/README.md (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/context/context.h (98%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/context/internal/context.cc (80%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/context/internal/context_benchmark.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/context/internal/context_test.cc (89%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/context/internal/with_context.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/context/internal/with_context_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/context/with_context.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/copts.bzl (80%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/curl.bzl (99%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/doc/benchmarks.md
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/doc/context.md (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/doc/conventions.md (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/doc/fuzzing.md (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/CMakeLists.txt (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/stats/CMakeLists.txt (89%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/stats/stdout/BUILD (100%)
 copy cpp/third_party/opencensus/{0.4.0/opencensus/exporters/trace => 0.5.0-alpha/opencensus/exporters/stats/stdout}/CMakeLists.txt (66%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/stats/stdout/internal/stdout_exporter.cc (84%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/stats/stdout/internal/stdout_exporter_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/stats/stdout/stdout_exporter.h (100%)
 copy cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/CMakeLists.txt (100%)
 copy cpp/third_party/opencensus/{0.4.0/opencensus/exporters/trace/stackdriver => 0.5.0-alpha/opencensus/exporters/trace/ocagent}/BUILD (60%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/README.md
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/internal/ocagent_exporter.cc
 copy cpp/third_party/opencensus/{0.4.0/opencensus/exporters/trace/zipkin/internal/zipkin_exporter_test.cc => 0.5.0-alpha/opencensus/exporters/trace/ocagent/internal/ocagent_exporter_test.cc} (70%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/ocagent_exporter.h
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/stackdriver/BUILD (86%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/stackdriver/README.md (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/stackdriver/internal/stackdriver_exporter.cc (91%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/stackdriver/stackdriver_exporter.h (82%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/stdout/BUILD (100%)
 rename cpp/third_party/opencensus/{0.4.0/opencensus/exporters/trace => 0.5.0-alpha/opencensus/exporters/trace/stdout}/CMakeLists.txt (68%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/stdout/internal/stdout_exporter.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/stdout/internal/stdout_exporter_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/stdout/stdout_exporter.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/zipkin/BUILD (96%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/zipkin/README.md (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/zipkin/internal/zipkin_exporter.cc (99%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/zipkin/internal/zipkin_exporter_test.cc (97%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/exporters/trace/zipkin/zipkin_exporter.h (98%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/BUILD (98%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/CMakeLists.txt
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/README.md (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/aggregation.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/bucket_boundaries.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/distribution.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/examples/BUILD (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/examples/exporter_example.cc (94%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/examples/view_and_recording_example.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/aggregation.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/aggregation_window.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/aggregation_window.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/bucket_boundaries.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/bucket_boundaries_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/debug_string_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/delta_producer.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/delta_producer.h (87%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/distribution.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/distribution_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/measure.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/measure_data.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/measure_data.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/measure_data_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/measure_descriptor.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/measure_registry.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/measure_registry_impl.cc (96%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/measure_registry_impl.h (80%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/measure_registry_test.cc (91%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/recording.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/set_aggregation_window.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/set_aggregation_window.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/stats_exporter.cc (84%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/stats_exporter_impl.h (80%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/stats_exporter_test.cc (80%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/stats_manager.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/stats_manager.h (89%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/stats_manager_benchmark.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/stats_manager_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/view.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/view_data.cc (89%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/view_data_impl.cc (76%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/view_data_impl.h (77%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/view_data_impl_test.cc (83%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/view_data_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/internal/view_descriptor.cc (91%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/measure.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/measure_descriptor.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/measure_registry.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/recording.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/stats.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/stats_exporter.h (90%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/tag_key.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/tag_set.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/testing/test_utils.cc (76%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/testing/test_utils.h (78%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/view.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/view_data.h (88%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/stats/view_descriptor.h (93%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/BUILD (69%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/CMakeLists.txt
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/README.md (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/context_util.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/internal/context_util.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/internal/context_util_test.cc (100%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin.cc
 copy cpp/third_party/opencensus/{0.4.0/opencensus/tags/internal/tag_map_benchmark.cc => 0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_benchmark.cc} (52%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_corpus/kv
 copy cpp/third_party/opencensus/{0.4.0/opencensus/trace/internal/trace_context_fuzzer.cc => 0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_fuzzer.cc} (61%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_test.cc
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/internal/tag_key.cc (75%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/internal/tag_key_test.cc (66%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/internal/tag_map.cc (90%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/internal/tag_map_benchmark.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/internal/tag_map_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/internal/with_tag_map.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/internal/with_tag_map_benchmark.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/internal/with_tag_map_test.cc (100%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/propagation/grpc_tags_bin.h
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/tag_key.h (84%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/tag_map.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/tags/with_tag_map.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/BUILD (91%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/CMakeLists.txt
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/README.md (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/attribute_value_ref.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/context_util.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/examples/BUILD (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/examples/span_example.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/exporter/annotation.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/exporter/attribute_value.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/exporter/link.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/exporter/message_event.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/exporter/span_data.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/exporter/span_exporter.h (71%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/exporter/status.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/annotation.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/annotation_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/attribute_list.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/attribute_list.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/attribute_value.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/attribute_value_ref.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/attribute_value_ref_benchmark.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/attribute_value_ref_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/attribute_value_test.cc (100%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3.cc
 copy cpp/third_party/opencensus/{0.4.0/opencensus/trace/internal/trace_context_benchmark.cc => 0.5.0-alpha/opencensus/trace/internal/b3_benchmark.cc} (54%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_corpus/trace_id_64bit
 copy cpp/third_party/opencensus/{0.4.0/opencensus/trace/internal/trace_context_fuzzer.cc => 0.5.0-alpha/opencensus/trace/internal/b3_fuzzer.cc} (50%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_test.cc
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/cloud_trace_context.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/cloud_trace_context_benchmark.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/cloud_trace_context_corpus/span_id_overflow (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/cloud_trace_context_corpus/valid (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/cloud_trace_context_fuzzer.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/cloud_trace_context_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/context_util.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/context_util_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/event_with_time.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/grpc_trace_bin.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/grpc_trace_bin_benchmark.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/grpc_trace_bin_corpus/valid (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/grpc_trace_bin_fuzzer.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/grpc_trace_bin_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/link.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/link_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/local_span_store.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/local_span_store.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/local_span_store_impl.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/local_span_store_impl.h (82%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/local_span_store_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/message_event.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/running_span_store.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/running_span_store.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/running_span_store_impl.cc (97%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/running_span_store_impl.h (84%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/running_span_store_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/sampler.cc (93%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/sampler_benchmark.cc
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/sampler_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_benchmark.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_context.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_context_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_data.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_exporter.cc (81%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_exporter_impl.cc (75%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_exporter_impl.h (79%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_exporter_test.cc (93%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_id.cc (96%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_id_benchmark.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_id_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_impl.cc (98%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_impl.h (81%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_options_test.cc (98%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/span_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/status.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/status_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_config.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_config_impl.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_config_impl.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_config_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_context.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_context_benchmark.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_context_corpus/bad_options (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_context_corpus/bad_span_id (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_context_corpus/bad_trace_id (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_context_corpus/valid (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_context_fuzzer.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_context_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_events.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_id.cc (96%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_options.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_options_test.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/trace_params_impl.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/with_span.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/with_span_benchmark.cc (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/internal/with_span_test.cc (100%)
 create mode 100644 cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/propagation/b3.h
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/propagation/cloud_trace_context.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/propagation/grpc_trace_bin.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/propagation/trace_context.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/sampler.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/span.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/span_context.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/span_id.h (95%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/status_code.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/trace_config.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/trace_id.h (95%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/trace_options.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/trace_params.h (100%)
 rename cpp/third_party/opencensus/{0.4.0 => 0.5.0-alpha}/opencensus/trace/with_span.h (100%)


[rocketmq-clients] 02/02: WIP: Support build with cmake

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lizhanhui pushed a commit to branch cpp_cmake
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git

commit c7040f58f81558ad56369833122c47f4d83bd3df
Author: Li Zhanhui <li...@gmail.com>
AuthorDate: Wed Jul 27 20:05:21 2022 +0800

    WIP: Support build with cmake
---
 cpp/source/CMakeLists.txt                          |   3 +
 cpp/third_party/CMakeLists.txt                     |   2 +-
 .../0.4.0/opencensus/common/internal/hash_mix.h    |  49 ---
 .../opencensus/0.4.0/opencensus/doc/benchmarks.md  |  35 --
 .../exporters/stats/stdout/CMakeLists.txt          |  30 --
 .../exporters/trace/stdout/CMakeLists.txt          |  28 --
 .../0.4.0/opencensus/stats/CMakeLists.txt          | 129 --------
 .../0.4.0/opencensus/tags/CMakeLists.txt           |  41 ---
 .../0.4.0/opencensus/trace/CMakeLists.txt          | 238 --------------
 .../{0.4.0 => 0.5.0-alpha}/CMakeLists.txt          |   0
 cpp/third_party/opencensus/0.5.0-alpha/README.md   |   1 +
 .../{0.4.0 => 0.5.0-alpha}/opencensus/BUILD        |   0
 .../opencensus/CMakeLists.txt                      |   0
 .../{0.4.0 => 0.5.0-alpha}/opencensus/common/BUILD |   0
 .../opencensus/common/CMakeLists.txt               |   0
 .../opencensus/common/internal/BUILD               |  75 ++++-
 .../opencensus/common/internal/CMakeLists.txt      |  42 ++-
 .../opencensus/common/internal/grpc/BUILD          |   0
 .../opencensus/common/internal/grpc/status.cc      |   0
 .../opencensus/common/internal/grpc/status.h       |   0
 .../opencensus/common/internal/grpc/status_test.cc |   0
 .../common/internal/grpc/with_user_agent.cc        |   0
 .../common/internal/grpc/with_user_agent.h         |   0
 .../opencensus/common/internal/hostname.cc         |  69 ++++
 .../opencensus/common/internal/hostname.h}         |  18 +-
 .../opencensus/common/internal/hostname_test.cc}   |  20 +-
 .../opencensus/common/internal/random.cc           |   0
 .../opencensus/common/internal/random.h            |   4 +-
 .../opencensus/common/internal/random_benchmark.cc |   0
 .../opencensus/common/internal/random_test.cc      |   0
 .../opencensus/common/internal/stats_object.h      |   2 +-
 .../common/internal/stats_object_test.cc           |   0
 .../common/internal/string_vector_hash.h           |   9 +-
 .../opencensus/common/internal/timestamp.cc}       |  19 +-
 .../opencensus/common/internal/timestamp.h}        |  18 +-
 .../common/internal/timestamp_benchmark.cc}        |  30 +-
 .../opencensus/common/internal/timestamp_test.cc   |  40 +++
 .../opencensus/common/internal/varint.cc           |  59 ++++
 .../opencensus/common/internal/varint.h}           |  19 +-
 .../opencensus/common/internal/varint_test.cc      |  75 +++++
 .../opencensus/common/version.h                    |   2 +-
 .../opencensus/context/BUILD                       |   1 -
 .../opencensus/context/CMakeLists.txt              |  32 +-
 .../opencensus/context/README.md                   |   0
 .../opencensus/context/context.h                   |   1 +
 .../opencensus/context/internal/context.cc         |  21 +-
 .../context/internal/context_benchmark.cc          |   0
 .../opencensus/context/internal/context_test.cc    |  13 +
 .../opencensus/context/internal/with_context.cc    |   0
 .../context/internal/with_context_test.cc          |   0
 .../opencensus/context/with_context.h              |   0
 .../{0.4.0 => 0.5.0-alpha}/opencensus/copts.bzl    |   9 +-
 .../{0.4.0 => 0.5.0-alpha}/opencensus/curl.bzl     |   1 -
 .../0.5.0-alpha/opencensus/doc/benchmarks.md       |  59 ++++
 .../opencensus/doc/context.md                      |   0
 .../opencensus/doc/conventions.md                  |   0
 .../opencensus/doc/fuzzing.md                      |   0
 .../opencensus/exporters/CMakeLists.txt            |   0
 .../opencensus/exporters/stats/CMakeLists.txt      |   4 -
 .../opencensus/exporters/stats/stdout/BUILD        |   0
 .../exporters/stats/stdout}/CMakeLists.txt         |  16 +-
 .../stats/stdout/internal/stdout_exporter.cc       |  24 +-
 .../stats/stdout/internal/stdout_exporter_test.cc  |   0
 .../exporters/stats/stdout/stdout_exporter.h       |   0
 .../opencensus/exporters/trace/CMakeLists.txt      |   0
 .../opencensus/exporters/trace/ocagent}/BUILD      |  29 +-
 .../opencensus/exporters/trace/ocagent/README.md   |  75 +++++
 .../trace/ocagent/internal/ocagent_exporter.cc     | 359 +++++++++++++++++++++
 .../ocagent/internal/ocagent_exporter_test.cc}     |  34 +-
 .../exporters/trace/ocagent/ocagent_exporter.h     |  60 ++++
 .../opencensus/exporters/trace/stackdriver/BUILD   |   5 +-
 .../exporters/trace/stackdriver/README.md          |   0
 .../stackdriver/internal/stackdriver_exporter.cc   |  43 +--
 .../trace/stackdriver/stackdriver_exporter.h       |  12 +-
 .../opencensus/exporters/trace/stdout/BUILD        |   0
 .../exporters/trace/stdout}/CMakeLists.txt         |  15 +-
 .../trace/stdout/internal/stdout_exporter.cc       |   0
 .../trace/stdout/internal/stdout_exporter_test.cc  |   0
 .../exporters/trace/stdout/stdout_exporter.h       |   0
 .../opencensus/exporters/trace/zipkin/BUILD        |   1 -
 .../opencensus/exporters/trace/zipkin/README.md    |   0
 .../trace/zipkin/internal/zipkin_exporter.cc       |   8 +-
 .../trace/zipkin/internal/zipkin_exporter_test.cc  |   1 -
 .../exporters/trace/zipkin/zipkin_exporter.h       |   2 +-
 .../{0.4.0 => 0.5.0-alpha}/opencensus/stats/BUILD  |   1 -
 .../0.5.0-alpha/opencensus/stats/CMakeLists.txt    | 115 +++++++
 .../opencensus/stats/README.md                     |   0
 .../opencensus/stats/aggregation.h                 |   0
 .../opencensus/stats/bucket_boundaries.h           |   0
 .../opencensus/stats/distribution.h                |   0
 .../opencensus/stats/examples/BUILD                |   0
 .../opencensus/stats/examples/exporter_example.cc  |   8 +-
 .../stats/examples/view_and_recording_example.cc   |   0
 .../opencensus/stats/internal/aggregation.cc       |   0
 .../stats/internal/aggregation_window.cc           |   0
 .../opencensus/stats/internal/aggregation_window.h |   0
 .../opencensus/stats/internal/bucket_boundaries.cc |   0
 .../stats/internal/bucket_boundaries_test.cc       |   0
 .../opencensus/stats/internal/debug_string_test.cc |   0
 .../opencensus/stats/internal/delta_producer.cc    |   0
 .../opencensus/stats/internal/delta_producer.h     |  20 +-
 .../opencensus/stats/internal/distribution.cc      |   0
 .../opencensus/stats/internal/distribution_test.cc |   0
 .../opencensus/stats/internal/measure.cc           |   0
 .../opencensus/stats/internal/measure_data.cc      |   0
 .../opencensus/stats/internal/measure_data.h       |   0
 .../opencensus/stats/internal/measure_data_test.cc |   0
 .../stats/internal/measure_descriptor.cc           |   0
 .../opencensus/stats/internal/measure_registry.cc  |   0
 .../stats/internal/measure_registry_impl.cc        |   6 +-
 .../stats/internal/measure_registry_impl.h         |  28 +-
 .../stats/internal/measure_registry_test.cc        |  14 +
 .../opencensus/stats/internal/recording.cc         |   0
 .../stats/internal/set_aggregation_window.cc       |   0
 .../stats/internal/set_aggregation_window.h        |   0
 .../opencensus/stats/internal/stats_exporter.cc    |  29 +-
 .../stats/internal/stats_exporter_impl.h           |  24 +-
 .../stats/internal/stats_exporter_test.cc          |  57 ++--
 .../opencensus/stats/internal/stats_manager.cc     |   0
 .../opencensus/stats/internal/stats_manager.h      |  18 +-
 .../stats/internal/stats_manager_benchmark.cc      |   0
 .../stats/internal/stats_manager_test.cc           |   0
 .../opencensus/stats/internal/view.cc              |   0
 .../opencensus/stats/internal/view_data.cc         |  13 +-
 .../opencensus/stats/internal/view_data_impl.cc    |  94 +++++-
 .../opencensus/stats/internal/view_data_impl.h     |  41 ++-
 .../stats/internal/view_data_impl_test.cc          |  70 ++--
 .../opencensus/stats/internal/view_data_test.cc    |   0
 .../opencensus/stats/internal/view_descriptor.cc   |  12 +-
 .../opencensus/stats/measure.h                     |   0
 .../opencensus/stats/measure_descriptor.h          |   0
 .../opencensus/stats/measure_registry.h            |   0
 .../opencensus/stats/recording.h                   |   0
 .../opencensus/stats/stats.h                       |   0
 .../opencensus/stats/stats_exporter.h              |   9 +
 .../opencensus/stats/tag_key.h                     |   0
 .../opencensus/stats/tag_set.h                     |   0
 .../opencensus/stats/testing/test_utils.cc         |  21 +-
 .../opencensus/stats/testing/test_utils.h          |  13 +
 .../{0.4.0 => 0.5.0-alpha}/opencensus/stats/view.h |   0
 .../opencensus/stats/view_data.h                   |   9 +
 .../opencensus/stats/view_descriptor.h             |   6 +
 .../{0.4.0 => 0.5.0-alpha}/opencensus/tags/BUILD   |  59 +++-
 .../0.5.0-alpha/opencensus/tags/CMakeLists.txt     |  77 +++++
 .../opencensus/tags/README.md                      |   0
 .../opencensus/tags/context_util.h                 |   0
 .../opencensus/tags/internal/context_util.cc       |   0
 .../opencensus/tags/internal/context_util_test.cc  |   0
 .../opencensus/tags/internal/grpc_tags_bin.cc      | 129 ++++++++
 .../tags/internal/grpc_tags_bin_benchmark.cc}      |  42 +--
 .../tags/internal/grpc_tags_bin_corpus/kv          | Bin 0 -> 9 bytes
 .../tags/internal/grpc_tags_bin_fuzzer.cc}         |  15 +-
 .../opencensus/tags/internal/grpc_tags_bin_test.cc | 169 ++++++++++
 .../opencensus/tags/internal/tag_key.cc            |  19 +-
 .../opencensus/tags/internal/tag_key_test.cc       |  18 +-
 .../opencensus/tags/internal/tag_map.cc            |  10 +-
 .../opencensus/tags/internal/tag_map_benchmark.cc  |   0
 .../opencensus/tags/internal/tag_map_test.cc       |   0
 .../opencensus/tags/internal/with_tag_map.cc       |   0
 .../tags/internal/with_tag_map_benchmark.cc        |   0
 .../opencensus/tags/internal/with_tag_map_test.cc  |   0
 .../opencensus/tags/propagation/grpc_tags_bin.h    |  42 +++
 .../opencensus/tags/tag_key.h                      |  10 +
 .../opencensus/tags/tag_map.h                      |   0
 .../opencensus/tags/with_tag_map.h                 |   0
 .../{0.4.0 => 0.5.0-alpha}/opencensus/trace/BUILD  |  63 ++++
 .../0.5.0-alpha/opencensus/trace/CMakeLists.txt    | 229 +++++++++++++
 .../opencensus/trace/README.md                     |   0
 .../opencensus/trace/attribute_value_ref.h         |   0
 .../opencensus/trace/context_util.h                |   0
 .../opencensus/trace/examples/BUILD                |   0
 .../opencensus/trace/examples/span_example.cc      |   0
 .../opencensus/trace/exporter/annotation.h         |   0
 .../opencensus/trace/exporter/attribute_value.h    |   0
 .../opencensus/trace/exporter/link.h               |   0
 .../opencensus/trace/exporter/message_event.h      |   0
 .../opencensus/trace/exporter/span_data.h          |   0
 .../opencensus/trace/exporter/span_exporter.h      |  18 ++
 .../opencensus/trace/exporter/status.h             |   0
 .../opencensus/trace/internal/annotation.cc        |   0
 .../opencensus/trace/internal/annotation_test.cc   |   0
 .../opencensus/trace/internal/attribute_list.cc    |   0
 .../opencensus/trace/internal/attribute_list.h     |   0
 .../opencensus/trace/internal/attribute_value.cc   |   0
 .../trace/internal/attribute_value_ref.cc          |   0
 .../internal/attribute_value_ref_benchmark.cc      |   0
 .../trace/internal/attribute_value_ref_test.cc     |   0
 .../trace/internal/attribute_value_test.cc         |   0
 .../0.5.0-alpha/opencensus/trace/internal/b3.cc    | 113 +++++++
 .../opencensus/trace/internal/b3_benchmark.cc}     |  28 +-
 .../trace/internal/b3_corpus/trace_id_64bit        |   1 +
 .../opencensus/trace/internal/b3_fuzzer.cc}        |  23 +-
 .../opencensus/trace/internal/b3_test.cc           | 118 +++++++
 .../trace/internal/cloud_trace_context.cc          |   0
 .../internal/cloud_trace_context_benchmark.cc      |   0
 .../cloud_trace_context_corpus/span_id_overflow    |   0
 .../internal/cloud_trace_context_corpus/valid      |   0
 .../trace/internal/cloud_trace_context_fuzzer.cc   |   0
 .../trace/internal/cloud_trace_context_test.cc     |   0
 .../opencensus/trace/internal/context_util.cc      |   0
 .../opencensus/trace/internal/context_util_test.cc |   0
 .../opencensus/trace/internal/event_with_time.h    |   0
 .../opencensus/trace/internal/grpc_trace_bin.cc    |   0
 .../trace/internal/grpc_trace_bin_benchmark.cc     |   0
 .../trace/internal/grpc_trace_bin_corpus/valid     | Bin
 .../trace/internal/grpc_trace_bin_fuzzer.cc        |   2 +-
 .../trace/internal/grpc_trace_bin_test.cc          |   0
 .../opencensus/trace/internal/link.cc              |   0
 .../opencensus/trace/internal/link_test.cc         |   0
 .../opencensus/trace/internal/local_span_store.cc  |   0
 .../opencensus/trace/internal/local_span_store.h   |   0
 .../trace/internal/local_span_store_impl.cc        |   0
 .../trace/internal/local_span_store_impl.h         |  15 +-
 .../trace/internal/local_span_store_test.cc        |   0
 .../opencensus/trace/internal/message_event.cc     |   0
 .../trace/internal/running_span_store.cc           |   0
 .../opencensus/trace/internal/running_span_store.h |   0
 .../trace/internal/running_span_store_impl.cc      |   2 +-
 .../trace/internal/running_span_store_impl.h       |  13 +-
 .../trace/internal/running_span_store_test.cc      |   0
 .../opencensus/trace/internal/sampler.cc           |   4 +-
 .../opencensus/trace/internal/sampler_benchmark.cc |  53 +++
 .../opencensus/trace/internal/sampler_test.cc      |   0
 .../opencensus/trace/internal/span.cc              |   0
 .../opencensus/trace/internal/span_benchmark.cc    |   0
 .../opencensus/trace/internal/span_context.cc      |   0
 .../opencensus/trace/internal/span_context_test.cc |   0
 .../opencensus/trace/internal/span_data.cc         |   0
 .../opencensus/trace/internal/span_exporter.cc     |  11 +
 .../trace/internal/span_exporter_impl.cc           |  51 +--
 .../opencensus/trace/internal/span_exporter_impl.h |  31 +-
 .../trace/internal/span_exporter_test.cc           |   6 +-
 .../opencensus/trace/internal/span_id.cc           |   2 +
 .../opencensus/trace/internal/span_id_benchmark.cc |   0
 .../opencensus/trace/internal/span_id_test.cc      |   0
 .../opencensus/trace/internal/span_impl.cc         |   5 +
 .../opencensus/trace/internal/span_impl.h          |  40 +--
 .../opencensus/trace/internal/span_options_test.cc |   2 +-
 .../opencensus/trace/internal/span_test.cc         |   0
 .../opencensus/trace/internal/status.cc            |   0
 .../opencensus/trace/internal/status_test.cc       |   0
 .../opencensus/trace/internal/trace_config.cc      |   0
 .../opencensus/trace/internal/trace_config_impl.cc |   0
 .../opencensus/trace/internal/trace_config_impl.h  |   0
 .../opencensus/trace/internal/trace_config_test.cc |   0
 .../opencensus/trace/internal/trace_context.cc     |   0
 .../trace/internal/trace_context_benchmark.cc      |   0
 .../internal/trace_context_corpus/bad_options      |   0
 .../internal/trace_context_corpus/bad_span_id      |   0
 .../internal/trace_context_corpus/bad_trace_id     |   0
 .../trace/internal/trace_context_corpus/valid      |   0
 .../trace/internal/trace_context_fuzzer.cc         |   0
 .../trace/internal/trace_context_test.cc           |   0
 .../opencensus/trace/internal/trace_events.h       |   0
 .../opencensus/trace/internal/trace_id.cc          |   2 +
 .../opencensus/trace/internal/trace_options.cc     |   0
 .../trace/internal/trace_options_test.cc           |   0
 .../opencensus/trace/internal/trace_params_impl.h  |   0
 .../opencensus/trace/internal/with_span.cc         |   0
 .../trace/internal/with_span_benchmark.cc          |   0
 .../opencensus/trace/internal/with_span_test.cc    |   0
 .../0.5.0-alpha/opencensus/trace/propagation/b3.h  |  68 ++++
 .../trace/propagation/cloud_trace_context.h        |   0
 .../opencensus/trace/propagation/grpc_trace_bin.h  |   0
 .../opencensus/trace/propagation/trace_context.h   |   0
 .../opencensus/trace/sampler.h                     |   0
 .../{0.4.0 => 0.5.0-alpha}/opencensus/trace/span.h |   0
 .../opencensus/trace/span_context.h                |   0
 .../opencensus/trace/span_id.h                     |   3 +
 .../opencensus/trace/status_code.h                 |   0
 .../opencensus/trace/trace_config.h                |   0
 .../opencensus/trace/trace_id.h                    |   3 +
 .../opencensus/trace/trace_options.h               |   0
 .../opencensus/trace/trace_params.h                |   0
 .../opencensus/trace/with_span.h                   |   0
 275 files changed, 2977 insertions(+), 1009 deletions(-)

diff --git a/cpp/source/CMakeLists.txt b/cpp/source/CMakeLists.txt
index e1547e4..8973fb4 100644
--- a/cpp/source/CMakeLists.txt
+++ b/cpp/source/CMakeLists.txt
@@ -14,4 +14,7 @@ add_library(rocketmq
             $<TARGET_OBJECTS:client>
             $<TARGET_OBJECTS:concurrent>
             $<TARGET_OBJECTS:log>
+            $<TARGET_OBJECTS:rocketmq_stats>
+            $<TARGET_OBJECTS:rocketmq_trace>
+            $<TARGET_OBJECTS:impl>
             $<TARGET_OBJECTS:scheduler>)
\ No newline at end of file
diff --git a/cpp/third_party/CMakeLists.txt b/cpp/third_party/CMakeLists.txt
index c00c963..e2ba5ac 100644
--- a/cpp/third_party/CMakeLists.txt
+++ b/cpp/third_party/CMakeLists.txt
@@ -4,5 +4,5 @@ add_subdirectory(fmt/9.0.0)
 add_subdirectory(spdlog/1.10.0)
 
 include(OpenCensusHelpers)
-add_subdirectory(opencensus/0.4.0)
+add_subdirectory(opencensus/0.5.0-alpha)
 add_subdirectory(opencensus/proto)
\ No newline at end of file
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/hash_mix.h b/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/hash_mix.h
deleted file mode 100644
index ed6e736..0000000
--- a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/hash_mix.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2018, OpenCensus Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef OPENCENSUS_COMMON_INTERNAL_HASH_MIX_H_
-#define OPENCENSUS_COMMON_INTERNAL_HASH_MIX_H_
-
-#include <cstddef>
-#include <limits>
-
-namespace opencensus {
-namespace common {
-
-// HashMix provides efficient mixing of hash values.
-class HashMix final {
- public:
-  HashMix() : hash_(1) {}
-
-  // Mixes in another *hashed* value.
-  void Mix(std::size_t hash) {
-    // A multiplier that has been found to provide good mixing.
-    constexpr std::size_t kMul =
-        static_cast<std::size_t>(0xdc3eb94af8ab4c93ULL);
-    hash_ *= kMul;
-    hash_ =
-        ((hash << 19) | (hash >> (std::numeric_limits<size_t>::digits - 19))) +
-        hash;
-  }
-
-  size_t get() const { return hash_; }
-
- private:
-  std::size_t hash_;
-};
-
-}  // namespace common
-}  // namespace opencensus
-
-#endif  // OPENCENSUS_COMMON_INTERNAL_HASH_MIX_H_
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/doc/benchmarks.md b/cpp/third_party/opencensus/0.4.0/opencensus/doc/benchmarks.md
deleted file mode 100644
index c02f050..0000000
--- a/cpp/third_party/opencensus/0.4.0/opencensus/doc/benchmarks.md
+++ /dev/null
@@ -1,35 +0,0 @@
-# Benchmarks
-
-## Running
-
-Benchmarks are implemented as binary rules in bazel, and can be either built and
-then run from the binary location in `bazel-bin` or run with `bazel run`, e.g.
-```shell
-bazel run -c opt opencensus/stats:stats_manager_benchmark [-- BENCHMARK_FLAGS]
-```
-Benchmarks use the [Google benchmark](https://github.com/google/benchmark)
-library. This accepts several helpful flags, including
- - --benchmark_filter=REGEX: Run only benchmarks whose names match REGEX.
- - --benchmark_repetitions=N: Repeat each benchmark and calculate
-   mean/median/stddev.
- - --benchmark_report_aggregates_only={true|false}: In conjunction with
-   benchmark_repetitions, report only summary statistics and not single-run
-   timings.
-
-## Profiling
-
-Benchmarks can be profiled using the
-[gperftools](https://github.com/gperftools/gperftools) library. On
-Debian/Ubuntu, install the `google-perftools` (profile analysis tools) and
-`libgoogle-perftools-dev` (profiling library) packages. When running the
-benchmark, set `LD_PRELOAD=/usr/lib/libprofiler.so` to enable the profiler and
-`CPUPROFILE=PATH` to save a profile, and analyze the profile with
-`google-pprof` (which needs a path to the binary for symbolization). For
-example,
-```shell
-bazel build -c opt opencensus/stats:stats_manager_benchmark
-LD_PRELOAD=/usr/lib/libprofiler.so CPUPROFILE=/tmp/prof \
-    ./bazel-bin/opencensus/stats/stats_manager_benchmark
-google-pprof --web bazel-bin/opencensus/stats/stats_manager_benchmark /tmp/prof
-```
-pprof supports many analysis types--see its documentation for options.
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/stdout/CMakeLists.txt b/cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/stdout/CMakeLists.txt
deleted file mode 100644
index b4f3110..0000000
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/stdout/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2018, OpenCensus Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-opencensus_lib(exporters_stats_stdout
-               PUBLIC
-               SRCS
-               internal/stdout_exporter.cc
-               DEPS
-               stats
-               absl::memory
-               absl::strings
-               absl::time)
-
-opencensus_test(exporters_stats_stdout_test
-                internal/stdout_exporter_test.cc
-                exporters_stats_stdout
-                stats
-                stats_test_utils
-                absl::time)
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stdout/CMakeLists.txt b/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stdout/CMakeLists.txt
deleted file mode 100644
index 2b8bc78..0000000
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stdout/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2018, OpenCensus Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-opencensus_lib(exporters_trace_stdout
-               PUBLIC
-               SRCS
-               internal/stdout_exporter.cc
-               DEPS
-               trace
-               absl::base
-               absl::memory)
-
-opencensus_test(exporters_trace_stdout_test
-                internal/stdout_exporter_test.cc
-                exporters_trace_stdout
-                trace
-                absl::time)
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/CMakeLists.txt b/cpp/third_party/opencensus/0.4.0/opencensus/stats/CMakeLists.txt
deleted file mode 100644
index 3bc10b9..0000000
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/CMakeLists.txt
+++ /dev/null
@@ -1,129 +0,0 @@
-# Copyright 2018, OpenCensus Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-opencensus_lib(stats
-               PUBLIC
-               DEPS
-               stats_core
-               stats_recording)
-
-opencensus_lib(stats_test_utils
-               PUBLIC
-               SRCS
-               testing/test_utils.cc
-               DEPS
-               stats_core
-               absl::memory
-               absl::time)
-
-opencensus_lib(stats_core
-               SRCS
-               internal/aggregation.cc
-               internal/aggregation_window.cc
-               internal/bucket_boundaries.cc
-               internal/delta_producer.cc
-               internal/distribution.cc
-               internal/measure.cc
-               internal/measure_data.cc
-               internal/measure_descriptor.cc
-               internal/measure_registry.cc
-               internal/measure_registry_impl.cc
-               internal/set_aggregation_window.cc
-               internal/stats_exporter.cc
-               internal/stats_manager.cc
-               internal/view.cc
-               internal/view_data.cc
-               internal/view_data_impl.cc
-               internal/view_descriptor.cc
-               DEPS
-               absl::base
-               common_stats_object
-               common_string_vector_hash
-               tags
-               absl::memory
-               absl::strings
-               absl::synchronization
-               absl::time
-               absl::optional
-               absl::span)
-
-# Define NOMINMAX to fix build errors when compiling with MSVC.
-target_compile_definitions(opencensus_stats_core PUBLIC
-                           $<$<CXX_COMPILER_ID:MSVC>:NOMINMAX>)
-
-opencensus_lib(stats_recording
-               SRCS
-               internal/recording.cc
-               DEPS
-               stats_core
-               tags
-               tags_context_util
-               absl::strings
-               absl::time)
-
-# ----------------------------------------------------------------------
-# Tests
-# ----------------------------------------------------------------------
-
-opencensus_test(stats_debug_string_test
-                internal/debug_string_test.cc
-                stats_core
-                absl::time)
-
-opencensus_test(stats_distribution_test
-                internal/distribution_test.cc
-                stats_core
-                stats_test_utils)
-
-opencensus_test(stats_bucket_boundaries_test internal/bucket_boundaries_test.cc
-                stats_core)
-
-opencensus_test(stats_measure_data_test
-                internal/measure_data_test.cc
-                stats_core
-                stats_test_utils
-                absl::span)
-
-opencensus_test(stats_measure_registry_test
-                internal/measure_registry_test.cc
-                stats_core
-                absl::strings)
-
-opencensus_test(stats_stats_exporter_test
-                internal/stats_exporter_test.cc
-                stats_core
-                stats_recording
-                absl::memory
-                absl::time)
-
-opencensus_test(stats_stats_manager_test
-                internal/stats_manager_test.cc
-                stats_core
-                stats_recording
-                stats_test_utils
-                tags
-                tags_with_tag_map)
-
-opencensus_test(stats_view_data_impl_test
-                internal/view_data_impl_test.cc
-                stats_core
-                absl::time)
-
-opencensus_benchmark(stats_stats_manager_benchmark
-                     internal/stats_manager_benchmark.cc
-                     stats_core
-                     stats_recording
-                     absl::memory
-                     absl::strings
-                     absl::time)
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/CMakeLists.txt b/cpp/third_party/opencensus/0.4.0/opencensus/tags/CMakeLists.txt
deleted file mode 100644
index f73b0ac..0000000
--- a/cpp/third_party/opencensus/0.4.0/opencensus/tags/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2018, OpenCensus Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-opencensus_lib(tags
-               PUBLIC
-               SRCS
-               internal/tag_key.cc
-               internal/tag_map.cc
-               DEPS
-               absl::strings
-               common_hash_mix
-               absl::base
-               absl::synchronization)
-
-opencensus_lib(tags_context_util
-               PUBLIC
-               SRCS
-               internal/context_util.cc
-               DEPS
-               tags
-               context)
-
-opencensus_lib(tags_with_tag_map
-               PUBLIC
-               SRCS
-               internal/with_tag_map.cc
-               DEPS
-               tags
-               context
-               absl::strings)
\ No newline at end of file
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/CMakeLists.txt b/cpp/third_party/opencensus/0.4.0/opencensus/trace/CMakeLists.txt
deleted file mode 100644
index fa5ba36..0000000
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/CMakeLists.txt
+++ /dev/null
@@ -1,238 +0,0 @@
-# Copyright 2018, OpenCensus Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-opencensus_lib(trace
-               PUBLIC
-               SRCS
-               internal/annotation.cc
-               internal/attribute_list.cc
-               internal/attribute_value.cc
-               internal/attribute_value_ref.cc
-               internal/context_util.cc
-               internal/link.cc
-               internal/local_span_store.cc
-               internal/local_span_store_impl.cc
-               internal/message_event.cc
-               internal/running_span_store.cc
-               internal/running_span_store_impl.cc
-               internal/sampler.cc
-               internal/span.cc
-               internal/span_data.cc
-               internal/span_exporter.cc
-               internal/span_exporter_impl.cc
-               internal/span_impl.cc
-               internal/status.cc
-               internal/trace_config.cc
-               internal/trace_config_impl.cc
-               internal/with_span.cc
-               DEPS
-               common_random
-               trace_cloud_trace_context
-               trace_span_context
-               trace_trace_context
-               absl::strings
-               absl::base
-               absl::memory
-               absl::synchronization
-               absl::time
-               absl::span)
-
-opencensus_lib(trace_cloud_trace_context
-               PUBLIC
-               SRCS
-               internal/cloud_trace_context.cc
-               DEPS
-               trace_span_context
-               absl::base
-               absl::strings)
-
-opencensus_lib(trace_context_util
-               PUBLIC
-               SRCS
-               internal/context_util.cc
-               DEPS
-               trace
-               context)
-
-opencensus_lib(trace_grpc_trace_bin
-               PUBLIC
-               SRCS
-               internal/grpc_trace_bin.cc
-               DEPS
-               trace_span_context
-               absl::base
-               absl::strings)
-
-opencensus_lib(trace_span_context
-               PUBLIC
-               SRCS
-               internal/span_context.cc
-               internal/span_id.cc
-               internal/trace_id.cc
-               internal/trace_options.cc
-               DEPS
-               absl::strings)
-
-opencensus_lib(trace_trace_context
-               PUBLIC
-               SRCS
-               internal/trace_context.cc
-               DEPS
-               trace_span_context
-               absl::base
-               absl::strings)
-
-opencensus_lib(trace_with_span
-               PUBLIC
-               SRCS
-               internal/with_span.cc
-               DEPS
-               trace
-               context)
-
-# ----------------------------------------------------------------------
-# Tests
-# ----------------------------------------------------------------------
-
-opencensus_test(trace_annotation_test internal/annotation_test.cc trace)
-
-opencensus_test(trace_attribute_value_ref_test
-                internal/attribute_value_ref_test.cc trace)
-
-opencensus_test(trace_attribute_value_test internal/attribute_value_test.cc
-                trace)
-
-opencensus_test(trace_cloud_trace_context_test
-                internal/cloud_trace_context_test.cc trace_cloud_trace_context)
-
-opencensus_test(trace_context_util_test
-                internal/context_util_test.cc
-                trace
-                trace_context_util
-                trace_with_span
-                context)
-
-opencensus_test(trace_grpc_trace_bin_test internal/grpc_trace_bin_test.cc
-                trace_grpc_trace_bin)
-
-opencensus_test(trace_link_test internal/link_test.cc trace)
-
-opencensus_test(trace_local_span_store_test
-                internal/local_span_store_test.cc
-                trace
-                absl::memory
-                absl::synchronization)
-
-opencensus_test(trace_running_span_store_test
-                internal/running_span_store_test.cc
-                trace
-                absl::base
-                absl::memory
-                absl::synchronization)
-
-opencensus_test(trace_sampler_test
-                internal/sampler_test.cc
-                trace
-                absl::strings
-                absl::synchronization
-                absl::time)
-
-opencensus_test(trace_span_test
-                internal/span_test.cc
-                trace
-                absl::strings)
-
-opencensus_test(trace_span_id_test internal/span_id_test.cc trace)
-
-opencensus_test(trace_span_options_test
-                internal/span_options_test.cc
-                trace
-                absl::strings
-                absl::synchronization)
-
-opencensus_test(trace_span_context_test
-                internal/span_context_test.cc
-                trace_span_context
-                absl::strings
-                absl::span)
-
-opencensus_test(trace_span_exporter_test
-                internal/span_exporter_test.cc
-                trace
-                absl::memory
-                absl::strings
-                absl::synchronization
-                absl::time)
-
-opencensus_test(trace_status_test
-                internal/status_test.cc
-                trace
-                absl::strings)
-
-opencensus_test(trace_trace_config_test
-                internal/trace_config_test.cc
-                trace
-                absl::time)
-
-opencensus_test(trace_trace_options_test internal/trace_options_test.cc trace)
-
-opencensus_test(trace_trace_context_test internal/trace_context_test.cc
-                trace_trace_context)
-
-opencensus_test(trace_with_span_test
-                internal/with_span_test.cc
-                trace
-                trace_with_span
-                context)
-
-opencensus_benchmark(trace_attribute_value_ref_benchmark
-                     internal/attribute_value_ref_benchmark.cc trace)
-
-opencensus_benchmark(trace_cloud_trace_context_benchmark
-                     internal/cloud_trace_context_benchmark.cc
-                     trace_cloud_trace_context)
-
-opencensus_benchmark(trace_grpc_trace_bin_benchmark
-                     internal/grpc_trace_bin_benchmark.cc trace_grpc_trace_bin)
-
-opencensus_benchmark(trace_span_benchmark
-                     internal/span_benchmark.cc
-                     trace_span_context
-                     trace)
-
-opencensus_benchmark(trace_span_id_benchmark internal/span_id_benchmark.cc
-                     trace_span_context)
-
-opencensus_benchmark(trace_context_benchmark internal/trace_context_benchmark.cc
-                     trace_trace_context)
-
-opencensus_benchmark(trace_with_span_benchmark
-                     internal/with_span_benchmark.cc
-                     trace
-                     trace_with_span)
-
-opencensus_fuzzer(trace_cloud_trace_context_fuzzer
-                  internal/cloud_trace_context_fuzzer.cc
-                  trace_cloud_trace_context
-                  absl::strings)
-
-opencensus_fuzzer(trace_grpc_trace_bin_fuzzer
-                  internal/grpc_trace_bin_fuzzer.cc
-                  trace_grpc_trace_bin
-                  absl::strings)
-
-opencensus_fuzzer(trace_trace_context_fuzzer
-                  internal/trace_context_fuzzer.cc
-                  trace_trace_context
-                  absl::strings)
diff --git a/cpp/third_party/opencensus/0.4.0/CMakeLists.txt b/cpp/third_party/opencensus/0.5.0-alpha/CMakeLists.txt
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/CMakeLists.txt
rename to cpp/third_party/opencensus/0.5.0-alpha/CMakeLists.txt
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/README.md b/cpp/third_party/opencensus/0.5.0-alpha/README.md
new file mode 100644
index 0000000..0eeb8d4
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/README.md
@@ -0,0 +1 @@
+Based on commit-id: 3e6aa4c0fb31d2f39a2d38365483599ab50bef6d
\ No newline at end of file
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/BUILD
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/BUILD
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/CMakeLists.txt b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/CMakeLists.txt
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/CMakeLists.txt
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/CMakeLists.txt
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/BUILD
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/BUILD
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/CMakeLists.txt b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/CMakeLists.txt
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/CMakeLists.txt
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/CMakeLists.txt
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/BUILD
similarity index 59%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/BUILD
index 3b9333b..8afef74 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/BUILD
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/BUILD
@@ -21,9 +21,11 @@ licenses(["notice"])  # Apache 2.0
 package(default_visibility = ["//opencensus:__subpackages__"])
 
 cc_library(
-    name = "hash_mix",
-    hdrs = ["hash_mix.h"],
+    name = "hostname",
+    srcs = ["hostname.cc"],
+    hdrs = ["hostname.h"],
     copts = DEFAULT_COPTS,
+    deps = ["@com_google_absl//absl/strings"],
 )
 
 cc_library(
@@ -54,12 +56,41 @@ cc_library(
     name = "string_vector_hash",
     hdrs = ["string_vector_hash.h"],
     copts = DEFAULT_COPTS,
-    deps = [":hash_mix"],
+    deps = ["@com_google_absl//absl/hash"],
+)
+
+cc_library(
+    name = "timestamp",
+    srcs = ["timestamp.cc"],
+    hdrs = ["timestamp.h"],
+    copts = DEFAULT_COPTS,
+    deps = [
+        "@com_google_absl//absl/time",
+        "@com_google_protobuf//:protobuf",
+    ],
+)
+
+cc_library(
+    name = "varint",
+    srcs = ["varint.cc"],
+    hdrs = ["varint.h"],
+    copts = DEFAULT_COPTS,
+    deps = ["@com_google_absl//absl/strings"],
 )
 
 # Tests
 # ========================================================================= #
 
+cc_test(
+    name = "hostname_test",
+    srcs = ["hostname_test.cc"],
+    copts = TEST_COPTS,
+    deps = [
+        ":hostname",
+        "@com_google_googletest//:gtest_main",
+    ],
+)
+
 cc_test(
     name = "random_test",
     srcs = ["random_test.cc"],
@@ -75,7 +106,6 @@ cc_binary(
     testonly = 1,
     srcs = ["random_benchmark.cc"],
     copts = TEST_COPTS,
-    linkopts = ["-pthread"],  # Required for absl/synchronization bits.
     linkstatic = 1,
     deps = [
         ":random_lib",
@@ -94,3 +124,40 @@ cc_test(
         "@com_google_googletest//:gtest_main",
     ],
 )
+
+cc_binary(
+    name = "timestamp_benchmark",
+    testonly = 1,
+    srcs = ["timestamp_benchmark.cc"],
+    copts = TEST_COPTS,
+    linkstatic = 1,
+    deps = [
+        ":timestamp",
+        "@com_github_google_benchmark//:benchmark",
+        "@com_google_absl//absl/time",
+        "@com_google_protobuf//:protobuf",
+    ],
+)
+
+cc_test(
+    name = "timestamp_test",
+    srcs = ["timestamp_test.cc"],
+    copts = TEST_COPTS,
+    deps = [
+        ":timestamp",
+        "@com_google_absl//absl/time",
+        "@com_google_googletest//:gtest_main",
+        "@com_google_protobuf//:protobuf",
+    ],
+)
+
+cc_test(
+    name = "varint_test",
+    srcs = ["varint_test.cc"],
+    copts = TEST_COPTS,
+    deps = [
+        ":varint",
+        "@com_google_absl//absl/strings",
+        "@com_google_googletest//:gtest_main",
+    ],
+)
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/CMakeLists.txt b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/CMakeLists.txt
similarity index 54%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/CMakeLists.txt
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/CMakeLists.txt
index c18859d..a9dbd87 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/CMakeLists.txt
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/CMakeLists.txt
@@ -12,30 +12,38 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-opencensus_lib(common_hash_mix)
+opencensus_lib(common_hostname SRCS hostname.cc DEPS absl::strings)
 
-opencensus_lib(common_random
-               SRCS
-               random.cc
-               DEPS
-               absl::base
-               absl::synchronization
-               absl::time)
+opencensus_lib(
+  common_random
+  SRCS
+  random.cc
+  DEPS
+  absl::base
+  absl::synchronization
+  absl::time)
 
 opencensus_lib(common_stats_object DEPS absl::time)
 
 # Define NOMINMAX to fix build errors when compiling with MSVC.
-target_compile_definitions(opencensus_common_stats_object INTERFACE
-                           $<$<CXX_COMPILER_ID:MSVC>:NOMINMAX>)
+target_compile_definitions(opencensus_common_stats_object
+                           INTERFACE $<$<CXX_COMPILER_ID:MSVC>:NOMINMAX>)
 
-opencensus_lib(common_string_vector_hash)
+opencensus_lib(common_string_vector_hash DEPS absl::hash)
+
+opencensus_lib(common_varint SRCS varint.cc DEPS absl::strings)
+
+# Tests.
+
+opencensus_test(common_hostname_test hostname_test.cc common_hostname)
 
 opencensus_test(common_random_test random_test.cc common_random)
 
-opencensus_benchmark(common_random_benchmark random_benchmark.cc common_random)
+opencensus_test(common_stats_object_test stats_object_test.cc
+                common_stats_object absl::strings absl::span)
 
-opencensus_test(common_stats_object_test
-                stats_object_test.cc
-                common_stats_object
-                absl::strings
-                absl::span)
+opencensus_test(common_varint_test varint_test.cc common_varint)
+
+# Benchmarks.
+
+opencensus_benchmark(common_random_benchmark random_benchmark.cc common_random)
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/grpc/BUILD
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/grpc/BUILD
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/grpc/status.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/grpc/status.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/grpc/status.h
similarity index 100%
copy from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status.h
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/grpc/status.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/grpc/status_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/grpc/status_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/with_user_agent.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/grpc/with_user_agent.cc
similarity index 100%
copy from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/with_user_agent.cc
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/grpc/with_user_agent.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/with_user_agent.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/grpc/with_user_agent.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/with_user_agent.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/grpc/with_user_agent.h
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/hostname.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/hostname.cc
new file mode 100644
index 0000000..83b8ec5
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/hostname.cc
@@ -0,0 +1,69 @@
+// Copyright 2019, OpenCensus Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "opencensus/common/internal/hostname.h"
+
+#if defined(_MSC_VER)
+#define WIN32_LEAN_AND_MEAN
+#include <process.h>
+#include <windows.h>
+#include <winsock2.h>
+#pragma comment(lib, "ws2_32.lib")
+#else
+#include <unistd.h>
+#endif
+
+#include "absl/strings/str_cat.h"
+
+namespace opencensus {
+namespace common {
+namespace {
+constexpr char kUnknownHostname[] = "unknown_hostname";
+}  // namespace
+
+#if defined(_MSC_VER)
+std::string Hostname() {
+  WSADATA data;
+  if (WSAStartup(MAKEWORD(2, 2), &data) != 0) {
+    return kUnknownHostname;
+  }
+  // SUSv2 says 255 is the limit for hostnames.
+  char buf[256];
+  if (gethostname(buf, sizeof(buf)) != 0) {
+    return kUnknownHostname;
+  }
+  // NUL terminate just in case.
+  buf[sizeof(buf) - 1] = 0;
+  WSACleanup();
+  return buf;
+}
+#else
+std::string Hostname() {
+  // SUSv2 says 255 is the limit for hostnames.
+  char buf[256];
+  if (gethostname(buf, sizeof(buf)) == -1) {
+    return kUnknownHostname;
+  }
+  // gethostname() doesn't guarantee NUL termination.
+  buf[sizeof(buf) - 1] = 0;
+  return buf;
+}
+#endif
+
+std::string OpenCensusTask() {
+  return absl::StrCat("cpp-", getpid(), "@", Hostname());
+}
+
+}  // namespace common
+}  // namespace opencensus
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/hostname.h
similarity index 63%
copy from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status.h
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/hostname.h
index ca55343..43036d8 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/hostname.h
@@ -1,4 +1,4 @@
-// Copyright 2018, OpenCensus Authors
+// Copyright 2019, OpenCensus Authors
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -12,20 +12,22 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#ifndef OPENCENSUS_COMMON_INTERNAL_GRPC_STATUS_H_
-#define OPENCENSUS_COMMON_INTERNAL_GRPC_STATUS_H_
+#ifndef OPENCENSUS_COMMON_INTERNAL_HOST_H_
+#define OPENCENSUS_COMMON_INTERNAL_HOST_H_
 
 #include <string>
 
-#include <grpcpp/support/status.h>
-
 namespace opencensus {
 namespace common {
 
-// Returns a string of the status code name and message.
-std::string ToString(const grpc::Status& status);
+// Returns the current hostname or "unknown_hostname" on error.
+std::string Hostname();
+
+// Returns a default opencensus_task value for stats exporters, in
+// the format "cpp-{PID}@{HOSTNAME}"
+std::string OpenCensusTask();
 
 }  // namespace common
 }  // namespace opencensus
 
-#endif  // OPENCENSUS_COMMON_INTERNAL_GRPC_STATUS_H_
+#endif  // OPENCENSUS_COMMON_INTERNAL_HOST_H_
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/hostname_test.cc
similarity index 64%
copy from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status.h
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/hostname_test.cc
index ca55343..c90b7c5 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/hostname_test.cc
@@ -1,4 +1,4 @@
-// Copyright 2018, OpenCensus Authors
+// Copyright 2019, OpenCensus Authors
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -12,20 +12,22 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#ifndef OPENCENSUS_COMMON_INTERNAL_GRPC_STATUS_H_
-#define OPENCENSUS_COMMON_INTERNAL_GRPC_STATUS_H_
+#include "opencensus/common/internal/hostname.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
 
 #include <string>
 
-#include <grpcpp/support/status.h>
-
 namespace opencensus {
 namespace common {
+namespace {
 
-// Returns a string of the status code name and message.
-std::string ToString(const grpc::Status& status);
+TEST(HostnameTest, OpenCensusTaskSmokeTest) {
+  const std::string task = OpenCensusTask();
+  std::cout << "opencensus_task = \"" << task << "\"\n";
+  EXPECT_THAT(task, ::testing::StartsWith("cpp-"));
+}
 
+}  // namespace
 }  // namespace common
 }  // namespace opencensus
-
-#endif  // OPENCENSUS_COMMON_INTERNAL_GRPC_STATUS_H_
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/random.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/random.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/random.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/random.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/random.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/random.h
similarity index 95%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/random.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/random.h
index 6877b14..2ada6a3 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/random.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/random.h
@@ -31,13 +31,13 @@ class Generator {
   Generator() : rng_(absl::GetCurrentTimeNanos()) {}
   explicit Generator(uint64_t seed) : rng_(seed) {}
 
-  uint64_t Random64() LOCKS_EXCLUDED(mu_);
+  uint64_t Random64() ABSL_LOCKS_EXCLUDED(mu_);
 
  private:
   friend class Random;
 
   absl::Mutex mu_;
-  std::mt19937_64 rng_ GUARDED_BY(mu_);
+  std::mt19937_64 rng_ ABSL_GUARDED_BY(mu_);
 };
 
 class Random {
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/random_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/random_benchmark.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/random_benchmark.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/random_benchmark.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/random_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/random_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/random_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/random_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/stats_object.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/stats_object.h
similarity index 99%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/stats_object.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/stats_object.h
index b8c9840..f70a6f9 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/stats_object.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/stats_object.h
@@ -78,7 +78,7 @@ class StatsObject {
 
   // Create a new StatsObject keeping num_stats distinct stats over the past
   // 'interval'. 'interval' will be rounded to 1 second if it is smaller.
-  StatsObject<N>(uint16_t num_stats, absl::Duration interval, absl::Time now);
+  StatsObject(uint16_t num_stats, absl::Duration interval, absl::Time now);
 
   // The number of distinct stats we keep data for.
   uint16_t num_stats() const { return num_stats_; }
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/stats_object_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/stats_object_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/stats_object_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/stats_object_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/string_vector_hash.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/string_vector_hash.h
similarity index 83%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/string_vector_hash.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/string_vector_hash.h
index 66d961a..c0f230f 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/string_vector_hash.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/string_vector_hash.h
@@ -19,19 +19,14 @@
 #include <string>
 #include <vector>
 
-#include "opencensus/common/internal/hash_mix.h"
+#include "absl/hash/hash.h"
 
 namespace opencensus {
 namespace common {
 
 struct StringVectorHash {
   std::size_t operator()(const std::vector<std::string>& container) const {
-    std::hash<std::string> hasher;
-    HashMix mixer;
-    for (const auto& elem : container) {
-      mixer.Mix(hasher(elem));
-    }
-    return mixer.get();
+    return absl::Hash<std::vector<std::string>>()(container);
   }
 };
 
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/with_user_agent.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/timestamp.cc
similarity index 60%
copy from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/with_user_agent.cc
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/timestamp.cc
index ee56b13..d994d37 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/with_user_agent.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/timestamp.cc
@@ -1,4 +1,4 @@
-// Copyright 2018, OpenCensus Authors
+// Copyright 2019, OpenCensus Authors
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -12,18 +12,21 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "opencensus/common/internal/grpc/with_user_agent.h"
+#include "opencensus/common/internal/timestamp.h"
 
-#include <grpcpp/support/channel_arguments.h>
-#include "opencensus/common/version.h"
+#include <cstdint>
+
+#include "absl/time/time.h"
+#include "google/protobuf/timestamp.pb.h"
 
 namespace opencensus {
 namespace common {
 
-grpc::ChannelArguments WithUserAgent() {
-  grpc::ChannelArguments args;
-  args.SetUserAgentPrefix("opencensus-cpp/" OPENCENSUS_VERSION);
-  return args;
+void SetTimestamp(absl::Time time, google::protobuf::Timestamp* proto) {
+  const int64_t seconds = absl::ToUnixSeconds(time);
+  proto->set_seconds(seconds);
+  proto->set_nanos(
+      absl::ToInt64Nanoseconds(time - absl::FromUnixSeconds(seconds)));
 }
 
 }  // namespace common
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/with_user_agent.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/timestamp.h
similarity index 64%
copy from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/with_user_agent.cc
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/timestamp.h
index ee56b13..65bb4ea 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/with_user_agent.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/timestamp.h
@@ -1,4 +1,4 @@
-// Copyright 2018, OpenCensus Authors
+// Copyright 2019, OpenCensus Authors
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -12,19 +12,19 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "opencensus/common/internal/grpc/with_user_agent.h"
+#ifndef OPENCENSUS_COMMON_INTERNAL_TIMESTAMP_H_
+#define OPENCENSUS_COMMON_INTERNAL_TIMESTAMP_H_
 
-#include <grpcpp/support/channel_arguments.h>
-#include "opencensus/common/version.h"
+#include "absl/time/time.h"
+#include "google/protobuf/timestamp.pb.h"
 
 namespace opencensus {
 namespace common {
 
-grpc::ChannelArguments WithUserAgent() {
-  grpc::ChannelArguments args;
-  args.SetUserAgentPrefix("opencensus-cpp/" OPENCENSUS_VERSION);
-  return args;
-}
+// Converts time to proto.
+void SetTimestamp(absl::Time time, google::protobuf::Timestamp* proto);
 
 }  // namespace common
 }  // namespace opencensus
+
+#endif  // OPENCENSUS_COMMON_INTERNAL_TIMESTAMP_H_
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/with_user_agent.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/timestamp_benchmark.cc
similarity index 53%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/with_user_agent.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/timestamp_benchmark.cc
index ee56b13..628d8c9 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/with_user_agent.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/timestamp_benchmark.cc
@@ -1,4 +1,4 @@
-// Copyright 2018, OpenCensus Authors
+// Copyright 2019, OpenCensus Authors
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -12,19 +12,23 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "opencensus/common/internal/grpc/with_user_agent.h"
+#include "absl/time/clock.h"
+#include "absl/time/time.h"
+#include "benchmark/benchmark.h"
+#include "google/protobuf/timestamp.pb.h"
+#include "opencensus/common/internal/timestamp.h"
 
-#include <grpcpp/support/channel_arguments.h>
-#include "opencensus/common/version.h"
+namespace {
 
-namespace opencensus {
-namespace common {
-
-grpc::ChannelArguments WithUserAgent() {
-  grpc::ChannelArguments args;
-  args.SetUserAgentPrefix("opencensus-cpp/" OPENCENSUS_VERSION);
-  return args;
+void BM_SetTimestamp(benchmark::State& state) {
+  absl::Time t = absl::Now();
+  google::protobuf::Timestamp proto;
+  for (auto _ : state) {
+    ::opencensus::common::SetTimestamp(t, &proto);
+  }
 }
+BENCHMARK(BM_SetTimestamp);
+
+}  // namespace
 
-}  // namespace common
-}  // namespace opencensus
+BENCHMARK_MAIN();
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/timestamp_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/timestamp_test.cc
new file mode 100644
index 0000000..5d6b603
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/timestamp_test.cc
@@ -0,0 +1,40 @@
+// Copyright 2019, OpenCensus Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "opencensus/common/internal/timestamp.h"
+
+#include "absl/time/time.h"
+#include "google/protobuf/timestamp.pb.h"
+#include "gtest/gtest.h"
+
+namespace {
+
+TEST(TimestampTest, Zero) {
+  absl::Time t;
+  google::protobuf::Timestamp proto;
+  ::opencensus::common::SetTimestamp(t, &proto);
+  EXPECT_EQ(0, proto.seconds());
+  EXPECT_EQ(0, proto.nanos());
+}
+
+TEST(TimestampTest, NonZero) {
+  absl::Time t =
+      absl::FromUnixSeconds(1561234567) + absl::Nanoseconds(123456789);
+  google::protobuf::Timestamp proto;
+  ::opencensus::common::SetTimestamp(t, &proto);
+  EXPECT_EQ(1561234567, proto.seconds());
+  EXPECT_EQ(123456789, proto.nanos());
+}
+
+}  // namespace
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/varint.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/varint.cc
new file mode 100644
index 0000000..5eee9f7
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/varint.cc
@@ -0,0 +1,59 @@
+// Copyright 2019, OpenCensus Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cstdint>
+#include <string>
+
+#include "absl/strings/string_view.h"
+#include "opencensus/common/internal/varint.h"
+
+namespace opencensus {
+namespace common {
+
+void AppendVarint32(uint32_t i, std::string* out) {
+  do {
+    // Encode 7 bits.
+    uint8_t c = i & 0x7F;
+    i = i >> 7;
+    if (i != 0) {
+      c |= 0x80;
+    }
+    out->push_back(c);
+  } while (i != 0);
+}
+
+bool ParseVarint32(absl::string_view* input, uint32_t* out) {
+  absl::string_view s = *input;
+  uint32_t i = 0;
+  uint8_t c;
+  int shift = 0;
+  do {
+    if (s.empty()) {
+      return false;  // Too short.
+    }
+    c = s[0];
+    s = s.substr(1);
+    if (shift == 28 && c > 0x0f) {
+      return false;  // Out of range for uint32_t.
+    }
+    i |= (c & 0x7F) << shift;
+    shift += 7;
+  } while (c & 0x80);
+  *input = s;
+  *out = i;
+  return true;
+}
+
+}  // namespace common
+}  // namespace opencensus
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/varint.h
similarity index 54%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/varint.h
index ca55343..26cf39e 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/common/internal/grpc/status.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/varint.h
@@ -1,4 +1,4 @@
-// Copyright 2018, OpenCensus Authors
+// Copyright 2019, OpenCensus Authors
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -12,20 +12,25 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#ifndef OPENCENSUS_COMMON_INTERNAL_GRPC_STATUS_H_
-#define OPENCENSUS_COMMON_INTERNAL_GRPC_STATUS_H_
+#ifndef OPENCENSUS_COMMON_INTERNAL_VARINT_H_
+#define OPENCENSUS_COMMON_INTERNAL_VARINT_H_
 
+#include <cstdint>
 #include <string>
 
-#include <grpcpp/support/status.h>
+#include "absl/strings/string_view.h"
 
 namespace opencensus {
 namespace common {
 
-// Returns a string of the status code name and message.
-std::string ToString(const grpc::Status& status);
+// Appends a variable-length encoded integer to the destination string.
+void AppendVarint32(uint32_t i, std::string* out);
+
+// Parses a variable-length encoded integer from the input. Returns false on
+// failure. Returns true and consumes the bytes from the input, on success.
+bool ParseVarint32(absl::string_view* input, uint32_t* out);
 
 }  // namespace common
 }  // namespace opencensus
 
-#endif  // OPENCENSUS_COMMON_INTERNAL_GRPC_STATUS_H_
+#endif  // OPENCENSUS_COMMON_INTERNAL_VARINT_H_
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/varint_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/varint_test.cc
new file mode 100644
index 0000000..d198142
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/internal/varint_test.cc
@@ -0,0 +1,75 @@
+// Copyright 2019, OpenCensus Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "opencensus/common/internal/varint.h"
+
+#include <iostream>
+
+#include "absl/strings/escaping.h"
+#include "absl/strings/string_view.h"
+#include "gtest/gtest.h"
+
+namespace opencensus {
+namespace common {
+namespace {
+
+TEST(Varint, EncodeDecode) {
+  auto test = [](uint32_t i) {
+    std::string s;
+    AppendVarint32(i, &s);
+    std::cout << " int " << i << " encoded to hex " << absl::BytesToHexString(s)
+              << "\n";
+    absl::string_view sv(s);
+    uint32_t j = i + 1;
+    EXPECT_TRUE(ParseVarint32(&sv, &j));
+    EXPECT_EQ(i, j);
+  };
+  test(0);
+  test(1);
+  test(10);
+  test(100);
+
+  test(127);
+  test(128);
+  test(129);
+
+  test(255);
+  test(256);
+  test(257);
+
+  test(16383);
+  test(16384);
+  test(16385);
+
+  test(2097151);
+  test(2097152);
+  test(2097153);
+
+  test(268435455);
+  test(268435456);
+  test(268435457);
+
+  test(4294967295);
+}
+
+TEST(Varint, DecodeOutOfRange) {
+  constexpr uint8_t input[] = {0xff, 0xff, 0xff, 0xff, 0x10};
+  absl::string_view sv(reinterpret_cast<const char*>(input), sizeof(input));
+  uint32_t i;
+  EXPECT_FALSE(ParseVarint32(&sv, &i));
+}
+
+}  // namespace
+}  // namespace common
+}  // namespace opencensus
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/common/version.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/version.h
similarity index 95%
rename from cpp/third_party/opencensus/0.4.0/opencensus/common/version.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/version.h
index f98f634..0b82421 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/common/version.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/common/version.h
@@ -17,6 +17,6 @@
 
 // The current version of the opencensus core library. Macro to allow literal
 // string concatenation in constexpr statements.
-#define OPENCENSUS_VERSION "0.4.0"
+#define OPENCENSUS_VERSION "0.5.0-dev"
 
 #endif  // OPENCENSUS_COMMON_VERSION_H_
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/context/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/BUILD
similarity index 96%
rename from cpp/third_party/opencensus/0.4.0/opencensus/context/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/BUILD
index 4ec4fb2..e60ec92 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/context/BUILD
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/BUILD
@@ -78,7 +78,6 @@ cc_binary(
     testonly = 1,
     srcs = ["internal/context_benchmark.cc"],
     copts = TEST_COPTS,
-    linkopts = ["-pthread"],  # Required for absl/synchronization bits.
     linkstatic = 1,
     deps = [
         ":context",
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/context/CMakeLists.txt b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/CMakeLists.txt
similarity index 63%
rename from cpp/third_party/opencensus/0.4.0/opencensus/context/CMakeLists.txt
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/CMakeLists.txt
index 525885b..149958c 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/context/CMakeLists.txt
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/CMakeLists.txt
@@ -12,22 +12,24 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-opencensus_lib(context
-               PUBLIC
-               SRCS
-               internal/context.cc
-               internal/with_context.cc
-               DEPS
-               tags
-               trace)
+opencensus_lib(
+  context
+  PUBLIC
+  SRCS
+  internal/context.cc
+  internal/with_context.cc
+  DEPS
+  tags
+  trace)
 
-opencensus_test(context_context_test
-                internal/context_test.cc
-                context
-                tags_context_util
-                tags_with_tag_map
-                trace_context_util
-                trace_with_span)
+opencensus_test(
+  context_context_test
+  internal/context_test.cc
+  context
+  tags_context_util
+  tags_with_tag_map
+  trace_context_util
+  trace_with_span)
 
 opencensus_test(context_with_context_test internal/with_context_test.cc context)
 
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/context/README.md b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/README.md
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/context/README.md
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/README.md
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/context/context.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/context.h
similarity index 98%
rename from cpp/third_party/opencensus/0.4.0/opencensus/context/context.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/context.h
index 2cc757e..020488d 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/context/context.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/context.h
@@ -67,6 +67,7 @@ class Context {
 
   friend class ContextTestPeer;
   friend class WithContext;
+  friend class ContextWrapper;
   friend class ::opencensus::tags::ContextPeer;
   friend class ::opencensus::tags::WithTagMap;
   friend class ::opencensus::trace::ContextPeer;
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/context/internal/context.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/internal/context.cc
similarity index 80%
rename from cpp/third_party/opencensus/0.4.0/opencensus/context/internal/context.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/internal/context.cc
index 4988e51..0142fea 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/context/internal/context.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/internal/context.cc
@@ -15,6 +15,7 @@
 #include "opencensus/context/context.h"
 
 #include <functional>
+#include <memory>
 #include <utility>
 
 #include "absl/strings/str_cat.h"
@@ -25,6 +26,20 @@
 namespace opencensus {
 namespace context {
 
+// Wrapper for per-thread Context, frees the Context on thread shutdown.
+class ContextWrapper {
+ public:
+  ContextWrapper() : ptr_(new Context) {}
+  Context* get() { return ptr_.get(); }
+
+ private:
+  std::unique_ptr<Context> ptr_;
+};
+
+namespace {
+thread_local ContextWrapper g_wrapper;
+}  // namespace
+
 Context::Context()
     : tags_(opencensus::tags::TagMap({})),
       span_(opencensus::trace::Span::BlankSpan()) {}
@@ -47,11 +62,7 @@ std::string Context::DebugString() const {
 }
 
 // static
-Context* Context::InternalMutableCurrent() {
-  static thread_local Context* thread_ctx = nullptr;
-  if (thread_ctx == nullptr) thread_ctx = new Context;
-  return thread_ctx;
-}
+Context* Context::InternalMutableCurrent() { return g_wrapper.get(); }
 
 void swap(Context& a, Context& b) {
   using std::swap;
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/context/internal/context_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/internal/context_benchmark.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/context/internal/context_benchmark.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/internal/context_benchmark.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/context/internal/context_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/internal/context_test.cc
similarity index 89%
rename from cpp/third_party/opencensus/0.4.0/opencensus/context/internal/context_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/internal/context_test.cc
index ade92cc..5e2a2e1 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/context/internal/context_test.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/internal/context_test.cc
@@ -16,6 +16,7 @@
 
 #include <functional>
 #include <iostream>
+#include <thread>
 
 #include "gtest/gtest.h"
 #include "opencensus/tags/context_util.h"
@@ -87,6 +88,18 @@ TEST(ContextTest, WrapDoesNotLeak) {
   span.End();
 }
 
+TEST(ContextTest, ThreadDoesNotLeak) {
+  auto span = opencensus::trace::Span::StartSpan("MySpan");
+  std::thread t([span]() {
+    // Leak-sanitizer (part of ASAN) throws an error if this leaks.
+    opencensus::tags::WithTagMap wt(ExampleTagMap());
+    opencensus::trace::WithSpan ws(span);
+  });
+  t.join();
+  ExpectEmptyContext();
+  span.End();
+}
+
 TEST(ContextTest, WrappedFnIsCopiable) {
   std::function<void()> fn1, fn2;
   {
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/context/internal/with_context.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/internal/with_context.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/context/internal/with_context.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/internal/with_context.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/context/internal/with_context_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/internal/with_context_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/context/internal/with_context_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/internal/with_context_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/context/with_context.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/with_context.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/context/with_context.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/context/with_context.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/copts.bzl b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/copts.bzl
similarity index 80%
rename from cpp/third_party/opencensus/0.4.0/opencensus/copts.bzl
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/copts.bzl
index aa4fa30..1947e1d 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/copts.bzl
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/copts.bzl
@@ -32,15 +32,16 @@ load(
 )
 
 WERROR = ["-Werror=return-type", "-Werror=switch"]
+WARN_FLAGS = ["-Wno-sign-compare"]
 
 DEFAULT_COPTS = select({
-    "//opencensus:llvm_compiler": ABSL_LLVM_FLAGS + WERROR,
+    "//opencensus:llvm_compiler": ABSL_LLVM_FLAGS + WERROR + WARN_FLAGS,
     "//opencensus:windows": ABSL_MSVC_FLAGS,
-    "//conditions:default": ABSL_GCC_FLAGS + WERROR,
+    "//conditions:default": ABSL_GCC_FLAGS + WERROR + WARN_FLAGS,
 })
 
 TEST_COPTS = DEFAULT_COPTS + select({
-    "//opencensus:llvm_compiler": ABSL_LLVM_TEST_FLAGS + WERROR,
+    "//opencensus:llvm_compiler": ABSL_LLVM_TEST_FLAGS + WERROR + WARN_FLAGS,
     "//opencensus:windows": ABSL_MSVC_TEST_FLAGS,
-    "//conditions:default": ABSL_GCC_TEST_FLAGS + WERROR,
+    "//conditions:default": ABSL_GCC_TEST_FLAGS + WERROR + WARN_FLAGS,
 })
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/curl.bzl b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/curl.bzl
similarity index 99%
rename from cpp/third_party/opencensus/0.4.0/opencensus/curl.bzl
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/curl.bzl
index c3b412d..b83d054 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/curl.bzl
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/curl.bzl
@@ -181,7 +181,6 @@ BASE_CURL_COPTS = [
 LINUX_CURL_COPTS = [
     "-DHAVE_LINUX_TCP_H=1",
     "-DHAVE_MSG_NOSIGNAL=1",
-    "-DHAVE_STROPTS_H=1",
 ]
 
 CURL_COPTS = select({
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/doc/benchmarks.md b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/doc/benchmarks.md
new file mode 100644
index 0000000..719e2b4
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/doc/benchmarks.md
@@ -0,0 +1,59 @@
+# Benchmarks
+
+## Running
+
+Benchmarks are implemented as binary rules in bazel, and can be either built and
+then run from the binary location in `bazel-bin` or run with `bazel run`, e.g.
+```shell
+bazel run -c opt opencensus/stats:stats_manager_benchmark [-- BENCHMARK_FLAGS]
+```
+Benchmarks use the [Google benchmark](https://github.com/google/benchmark)
+library. This accepts several helpful flags, including
+ - --benchmark_filter=REGEX: Run only benchmarks whose names match REGEX.
+ - --benchmark_repetitions=N: Repeat each benchmark and calculate
+   mean/median/stddev.
+ - --benchmark_report_aggregates_only={true|false}: In conjunction with
+   benchmark_repetitions, report only summary statistics and not single-run
+   timings.
+
+Don't forget to use `-c opt` to get an optimized build.
+
+## Profiling
+
+Benchmarks can be profiled using the
+[gperftools](https://github.com/gperftools/gperftools) library. To install on
+Debian / Ubuntu:
+
+```shell
+sudo apt install google-perftools libgoogle-perftools-dev
+```
+
+When running the benchmark, set:
+ - `LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libprofiler.so.0` to enable the
+   profiler.
+ - `CPUPROFILE=path_to_output_file`
+ - Optional: `CPUPROFILE_FREQUENCY=4000` to increase resolution.
+ - Optional: for visibility into inlined functions, build with `-g1` or above.
+
+Analyze the profile with `google-pprof`, which needs a path to the binary for
+symbolization.
+
+Example:
+
+```shell
+bazel build -c opt --copt=-g1 opencensus/stats:stats_manager_benchmark
+LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libprofiler.so.0 \
+  CPUPROFILE=/tmp/prof \
+  CPUPROFILE_FREQUENCY=4000 \
+  ./bazel-bin/opencensus/stats/stats_manager_benchmark
+google-pprof --web bazel-bin/opencensus/stats/stats_manager_benchmark /tmp/prof
+```
+
+`google-pprof` supports many analysis types - see its
+[documentation](https://gperftools.github.io/gperftools/cpuprofile.html) for
+options.
+
+Note that `CPUPROFILE_FREQUENCY` defaults to 100 samples per second.
+The maximum value `libprofiler` will accept is 4000.
+Most Linux kernels are built with `CONFIG_HZ=250`, so a single-threaded
+benchmark will produce at most 250 samples per second.
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/doc/context.md b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/doc/context.md
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/doc/context.md
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/doc/context.md
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/doc/conventions.md b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/doc/conventions.md
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/doc/conventions.md
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/doc/conventions.md
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/doc/fuzzing.md b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/doc/fuzzing.md
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/doc/fuzzing.md
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/doc/fuzzing.md
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/CMakeLists.txt b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/CMakeLists.txt
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/CMakeLists.txt
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/CMakeLists.txt
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/CMakeLists.txt b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/CMakeLists.txt
similarity index 89%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/CMakeLists.txt
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/CMakeLists.txt
index 2980daa..2dab970 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/CMakeLists.txt
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/CMakeLists.txt
@@ -12,8 +12,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# add_subdirectory(prometheus)
-
-# add_subdirectory(stackdriver) TODO
-
 add_subdirectory(stdout)
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/stdout/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/stdout/BUILD
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/stdout/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/stdout/BUILD
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/CMakeLists.txt b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/stdout/CMakeLists.txt
similarity index 66%
copy from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/CMakeLists.txt
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/stdout/CMakeLists.txt
index aab0ca4..5278e65 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/CMakeLists.txt
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/stdout/CMakeLists.txt
@@ -12,8 +12,16 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# add_subdirectory(stackdriver) TODO
+opencensus_lib(
+  exporters_stats_stdout
+  PUBLIC
+  SRCS
+  internal/stdout_exporter.cc
+  DEPS
+  stats
+  absl::memory
+  absl::strings
+  absl::time)
 
-add_subdirectory(stdout)
-
-# add_subdirectory(zipkin) TODO
+opencensus_test(exporters_stats_stdout_test internal/stdout_exporter_test.cc
+                exporters_stats_stdout stats stats_test_utils absl::time)
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/stdout/internal/stdout_exporter.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/stdout/internal/stdout_exporter.cc
similarity index 84%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/stdout/internal/stdout_exporter.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/stdout/internal/stdout_exporter.cc
index 927827c..c9ff78d 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/stdout/internal/stdout_exporter.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/stdout/internal/stdout_exporter.cc
@@ -61,7 +61,8 @@ class Handler : public opencensus::stats::StatsExporter::Handler {
   template <typename DataValueT>
   void ExportViewDataImpl(
       const opencensus::stats::ViewDescriptor& descriptor,
-      absl::Time start_time, absl::Time end_time,
+      const ::opencensus::stats::ViewData::DataMap<absl::Time>& start_times,
+      absl::Time end_time,
       const opencensus::stats::ViewData::DataMap<DataValueT>& data);
 
   std::ostream* stream_;
@@ -74,15 +75,15 @@ void Handler::ExportViewData(
     const auto& view_data = datum.second;
     switch (view_data.type()) {
       case opencensus::stats::ViewData::Type::kDouble:
-        ExportViewDataImpl(datum.first, view_data.start_time(),
+        ExportViewDataImpl(datum.first, view_data.start_times(),
                            view_data.end_time(), view_data.double_data());
         break;
       case opencensus::stats::ViewData::Type::kInt64:
-        ExportViewDataImpl(datum.first, view_data.start_time(),
+        ExportViewDataImpl(datum.first, view_data.start_times(),
                            view_data.end_time(), view_data.int_data());
         break;
       case opencensus::stats::ViewData::Type::kDistribution:
-        ExportViewDataImpl(datum.first, view_data.start_time(),
+        ExportViewDataImpl(datum.first, view_data.start_times(),
                            view_data.end_time(), view_data.distribution_data());
         break;
     }
@@ -92,20 +93,23 @@ void Handler::ExportViewData(
 
 template <typename DataValueT>
 void Handler::ExportViewDataImpl(
-    const opencensus::stats::ViewDescriptor& descriptor, absl::Time start_time,
+    const opencensus::stats::ViewDescriptor& descriptor,
+    const ::opencensus::stats::ViewData::DataMap<absl::Time>& start_times,
     absl::Time end_time,
     const opencensus::stats::ViewData::DataMap<DataValueT>& data) {
   if (data.empty()) {
-    *stream_ << absl::StrCat("No data for view \"", descriptor.name(),
-                             "\" from ", absl::FormatTime(start_time), ".\n\n");
+    *stream_ << absl::StrCat("No data for view \"", descriptor.name(), "\".\n");
     return;
   }
   // Build a string so we can write it in one shot to minimize crosstalk if
   // multiple threads write to stream_ simultaneously.
-  std::string output = absl::StrCat("Data for view \"", descriptor.name(),
-                                    "\" from ", absl::FormatTime(start_time),
-                                    " to ", absl::FormatTime(end_time), ":\n");
+  std::string output =
+      absl::StrCat("Data for view \"", descriptor.name(), "\":\n");
+
   for (const auto& row : data) {
+    auto start_time = start_times.at(row.first);
+    absl::StrAppend(&output, "Row data from ", absl::FormatTime(start_time),
+                    " to ", absl::FormatTime(end_time), ":\n");
     absl::StrAppend(&output, "  ");
     for (int i = 0; i < descriptor.columns().size(); ++i) {
       absl::StrAppend(&output, descriptor.columns()[i].name(), "=",
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/stdout/internal/stdout_exporter_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/stdout/internal/stdout_exporter_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/stdout/internal/stdout_exporter_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/stdout/internal/stdout_exporter_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/stdout/stdout_exporter.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/stdout/stdout_exporter.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/stats/stdout/stdout_exporter.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/stats/stdout/stdout_exporter.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/CMakeLists.txt b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/CMakeLists.txt
similarity index 100%
copy from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/CMakeLists.txt
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/CMakeLists.txt
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/BUILD
similarity index 60%
copy from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/BUILD
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/BUILD
index aa45c01..837f64a 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/BUILD
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/BUILD
@@ -1,4 +1,4 @@
-# Copyright 2018, OpenCensus Authors
+# Copyright 2019, OpenCensus Authors
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-load("//opencensus:copts.bzl", "DEFAULT_COPTS")
+load("//opencensus:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
 
 licenses(["notice"])  # Apache License 2.0
 
@@ -22,22 +22,35 @@ package(default_visibility = ["//visibility:private"])
 # ========================================================================= #
 
 cc_library(
-    name = "stackdriver_exporter",
-    srcs = ["internal/stackdriver_exporter.cc"],
-    hdrs = ["stackdriver_exporter.h"],
+    name = "ocagent_exporter",
+    srcs = ["internal/ocagent_exporter.cc"],
+    hdrs = ["ocagent_exporter.h"],
     copts = DEFAULT_COPTS,
     visibility = ["//visibility:public"],
     deps = [
         "//opencensus/common:version",
+        "//opencensus/common/internal:hostname",
+        "//opencensus/common/internal:timestamp",
         "//opencensus/common/internal/grpc:status",
         "//opencensus/common/internal/grpc:with_user_agent",
         "//opencensus/trace",
         "@com_github_grpc_grpc//:grpc++",
-        "@com_google_absl//absl/base:core_headers",
         "@com_google_absl//absl/memory",
         "@com_google_absl//absl/strings",
         "@com_google_absl//absl/time",
-        "@com_google_googleapis//google/devtools/cloudtrace/v2:trace_cc_grpc",
-        "@com_google_googleapis//google/devtools/cloudtrace/v2:trace_cc_proto",
+        "@opencensus_proto//opencensus/proto/agent/trace/v1:trace_service_grpc_cc",
+        "@opencensus_proto//opencensus/proto/agent/trace/v1:trace_service_proto_cc",
+    ],
+)
+
+cc_test(
+    name = "ocagent_exporter_test",
+    srcs = ["internal/ocagent_exporter_test.cc"],
+    copts = TEST_COPTS,
+    deps = [
+        ":ocagent_exporter",
+        "//opencensus/trace",
+        "@com_google_absl//absl/time",
+        "@com_google_googletest//:gtest_main",
     ],
 )
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/README.md b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/README.md
new file mode 100644
index 0000000..e5a44fc
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/README.md
@@ -0,0 +1,75 @@
+# OpenCensus OcAgent Tracing Exporter
+
+The *OpenCensus OcAgent Tracing Exporter* is a tracing exporter that exports
+tracing to [OcAgent](https://opencensus.io/service/components/agent/).
+
+## Quickstart
+
+### Prerequisites
+
+Install OcAgent as the [doc](https://opencensus.io/service/components/agent/install). You can deploy an agent in the same Pod with service. Or deploy it on a remote machine.
+
+Make sure the `opencensus` receiver so configured. Example `config.yaml` file:
+
+```yaml
+receivers:
+  opencensus:
+    address: "127.0.0.1:55678"
+
+exporters:
+  zipkin:
+    endpoint: "http://127.0.0.1:9411/api/v2/spans"
+```
+
+Start the agent:
+
+```shell
+ocagent_linux -c config.yaml
+```
+
+### Register the exporter
+
+Include:
+
+```c++
+#include "opencensus/exporters/trace/ocagent/ocagent_exporter.h"
+```
+
+Add a BUILD dependency on:
+
+```
+"@io_opencensus_cpp//exporters/trace/ocagent:ocagent_exporter",
+```
+
+In your application's initialization code, register the exporter:
+
+```c++
+opencensus::exporters::trace::OcAgentOptions opts;
+opts.address = "localhost:55678";
+OcAgentExporter::Register(std::move(opts));
+```
+
+### Adding Spans to a Trace
+
+A trace consists of a tree of spans. You should build an `::opencensus::trace::StartSpanOptions` and then start an span.
+
+```c++
+::opencensus::trace::AlwaysSampler sampler;
+::opencensus::trace::StartSpanOptions opts = {&sampler};
+
+auto span1 = ::opencensus::trace::Span::StartSpan("Span1", nullptr, opts);
+```
+
+Set some fields of the span.
+
+```c++
+span1.AddAnnotation("Annotation1", {{"TestBool", true}});
+```
+
+When the Span is finish, call the `End()` function and after that the span will be exported.
+
+```c++
+span1.End();
+```
+
+For more usage details, you can find out in the test file `ocagent_exporter_test.cc`.
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/internal/ocagent_exporter.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/internal/ocagent_exporter.cc
new file mode 100644
index 0000000..227419f
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/internal/ocagent_exporter.cc
@@ -0,0 +1,359 @@
+// Copyright 2019, OpenCensus Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "opencensus/exporters/trace/ocagent/ocagent_exporter.h"
+
+#include <grpcpp/grpcpp.h>
+#include <unistd.h>
+
+#include <cstdint>
+#include <iostream>
+
+#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
+#include "absl/time/clock.h"
+#include "opencensus/common/internal/grpc/status.h"
+#include "opencensus/common/internal/grpc/with_user_agent.h"
+#include "opencensus/common/internal/hostname.h"
+#include "opencensus/common/internal/timestamp.h"
+#include "opencensus/common/version.h"
+#include "opencensus/trace/exporter/span_data.h"
+#include "opencensus/trace/exporter/span_exporter.h"
+
+namespace opencensus {
+namespace exporters {
+namespace trace {
+namespace {
+
+constexpr size_t kAttributeStringLen = 256;
+constexpr size_t kAnnotationStringLen = 256;
+constexpr size_t kDisplayNameStringLen = 128;
+
+void SetTruncatableString(
+    absl::string_view str, size_t max_len,
+    ::opencensus::proto::trace::v1::TruncatableString *t_str) {
+  if (str.size() > max_len) {
+    t_str->set_value(std::string(str.substr(0, max_len)));
+    t_str->set_truncated_byte_count(str.size() - max_len);
+  } else {
+    t_str->set_value(std::string(str));
+    t_str->set_truncated_byte_count(0);
+  }
+}
+
+::opencensus::proto::trace::v1::Span_Link_Type ConvertLinkType(
+    ::opencensus::trace::exporter::Link::Type type) {
+  switch (type) {
+    case ::opencensus::trace::exporter::Link::Type::kChildLinkedSpan:
+      return ::opencensus::proto::trace::v1::Span_Link_Type_CHILD_LINKED_SPAN;
+    case ::opencensus::trace::exporter::Link::Type::kParentLinkedSpan:
+      return ::opencensus::proto::trace::v1::Span_Link_Type_PARENT_LINKED_SPAN;
+  }
+  return ::opencensus::proto::trace::v1::Span_Link_Type_TYPE_UNSPECIFIED;
+}
+
+::opencensus::proto::trace::v1::Span_TimeEvent_MessageEvent_Type
+ConvertMessageType(::opencensus::trace::exporter::MessageEvent::Type type) {
+  using Type = ::opencensus::trace::exporter::MessageEvent::Type;
+  switch (type) {
+    case Type::SENT:
+      return ::opencensus::proto::trace::v1::
+          Span_TimeEvent_MessageEvent_Type_SENT;
+    case Type::RECEIVED:
+      return ::opencensus::proto::trace::v1::
+          Span_TimeEvent_MessageEvent_Type_RECEIVED;
+  }
+  return ::opencensus::proto::trace::v1::
+      Span_TimeEvent_MessageEvent_Type_TYPE_UNSPECIFIED;
+}
+
+using AttributeMap =
+    ::google::protobuf::Map<std::string,
+                            ::opencensus::proto::trace::v1::AttributeValue>;
+
+void PopulateAttributes(
+    const std::unordered_map<
+        std::string, ::opencensus::trace::exporter::AttributeValue> &attributes,
+    AttributeMap *attribute_map) {
+  for (const auto &attr : attributes) {
+    using Type = ::opencensus::trace::exporter::AttributeValue::Type;
+    switch (attr.second.type()) {
+      case Type::kString:
+        SetTruncatableString(
+            attr.second.string_value(), kAttributeStringLen,
+            (*attribute_map)[attr.first].mutable_string_value());
+        break;
+      case Type::kBool:
+        (*attribute_map)[attr.first].set_bool_value(attr.second.bool_value());
+        break;
+      case Type::kInt:
+        (*attribute_map)[attr.first].set_int_value(attr.second.int_value());
+        break;
+    }
+  }
+}
+
+void ConvertAttributes(const ::opencensus::trace::exporter::SpanData &span,
+                       ::opencensus::proto::trace::v1::Span *proto_span) {
+  PopulateAttributes(span.attributes(),
+                     proto_span->mutable_attributes()->mutable_attribute_map());
+  proto_span->mutable_attributes()->set_dropped_attributes_count(
+      span.num_attributes_dropped());
+}
+
+void ConvertTimeEvents(const ::opencensus::trace::exporter::SpanData &span,
+                       ::opencensus::proto::trace::v1::Span *proto_span) {
+  for (const auto &annotation : span.annotations().events()) {
+    auto event = proto_span->mutable_time_events()->add_time_event();
+    opencensus::common::SetTimestamp(annotation.timestamp(),
+                                     event->mutable_time());
+
+    // Populate annotation.
+    SetTruncatableString(annotation.event().description(), kAnnotationStringLen,
+                         event->mutable_annotation()->mutable_description());
+    PopulateAttributes(annotation.event().attributes(),
+                       event->mutable_annotation()
+                           ->mutable_attributes()
+                           ->mutable_attribute_map());
+  }
+
+  for (const auto &message : span.message_events().events()) {
+    auto event = proto_span->mutable_time_events()->add_time_event();
+    opencensus::common::SetTimestamp(message.timestamp(),
+                                     event->mutable_time());
+
+    // Populate message event.
+    event->mutable_message_event()->set_type(
+        ConvertMessageType(message.event().type()));
+    event->mutable_message_event()->set_id(message.event().id());
+    event->mutable_message_event()->set_uncompressed_size(
+        message.event().uncompressed_size());
+    event->mutable_message_event()->set_compressed_size(
+        message.event().compressed_size());
+  }
+
+  proto_span->mutable_time_events()->set_dropped_annotations_count(
+      span.annotations().dropped_events_count());
+  proto_span->mutable_time_events()->set_dropped_message_events_count(
+      span.message_events().dropped_events_count());
+}
+
+void ConvertLinks(const ::opencensus::trace::exporter::SpanData &span,
+                  ::opencensus::proto::trace::v1::Span *proto_span) {
+  proto_span->mutable_links()->set_dropped_links_count(
+      span.num_links_dropped());
+  for (const auto &span_link : span.links()) {
+    auto link = proto_span->mutable_links()->add_link();
+    link->set_trace_id(span_link.trace_id().ToHex());
+    link->set_span_id(span_link.span_id().ToHex());
+    link->set_type(ConvertLinkType(span_link.type()));
+    PopulateAttributes(
+        span_link.attributes(),
+        proto_span->mutable_attributes()->mutable_attribute_map());
+  }
+}
+
+class Handler : public ::opencensus::trace::exporter::SpanExporter::Handler {
+ public:
+  Handler(OcAgentOptions &&opts);
+
+  void Export(const std::vector<::opencensus::trace::exporter::SpanData> &spans)
+      override;
+
+ private:
+  const OcAgentOptions opts_;
+  ::opencensus::proto::agent::common::v1::Node nodeInfo_;
+  void ConnectAgent();
+  void InitNode();
+  void ExportRpcRequest(
+      const ::opencensus::proto::agent::trace::v1::ExportTraceServiceRequest &);
+};
+
+void ConvertSpans(
+    const std::vector<::opencensus::trace::exporter::SpanData> &spans,
+    ::opencensus::proto::agent::trace::v1::ExportTraceServiceRequest *request) {
+  for (const auto &from_span : spans) {
+    auto to_span = request->add_spans();
+
+    // 1. trace_id
+    to_span->set_trace_id(from_span.context().trace_id().Value(),
+                          ::opencensus::trace::TraceId::kSize);
+    // 2. span_id
+    to_span->set_span_id(from_span.context().span_id().Value(),
+                         ::opencensus::trace::SpanId::kSize);
+    // 3. parent_span_id
+    if (from_span.parent_span_id().IsValid()) {
+      to_span->set_parent_span_id(from_span.parent_span_id().Value(),
+                                  ::opencensus::trace::SpanId::kSize);
+    }
+    // 4. name
+    SetTruncatableString(from_span.name(), kDisplayNameStringLen,
+                         to_span->mutable_name());
+    // 5. The start time of the span.
+    opencensus::common::SetTimestamp(from_span.start_time(),
+                                     to_span->mutable_start_time());
+    // 6. The end time of the span.
+    opencensus::common::SetTimestamp(from_span.end_time(),
+                                     to_span->mutable_end_time());
+
+    // 7. Export Attributes
+    ConvertAttributes(from_span, to_span);
+
+    // 8. stack_trace (unsupported)
+
+    // 9. Export Time Events.
+    ConvertTimeEvents(from_span, to_span);
+
+    // 10. Export Links.
+    ConvertLinks(from_span, to_span);
+
+    // 11. The status of the span.
+    to_span->mutable_status()->set_code(
+        static_cast<int32_t>(from_span.status().CanonicalCode()));
+    to_span->mutable_status()->set_message(from_span.status().error_message());
+
+    // 12. True if the parent is on a different process.
+    to_span->mutable_same_process_as_parent_span()->set_value(
+        !from_span.has_remote_parent());
+
+    // 13. child_span_count (optional)
+
+    // 14. span kind
+
+    // 15. tracestate
+
+    // 16. resource
+    // (TODO) Add FULL support.
+  }
+}
+
+Handler::Handler(OcAgentOptions &&opts) : opts_(std::move(opts)) {
+  InitNode();
+  ConnectAgent();
+}
+
+void Handler::Export(
+    const std::vector<::opencensus::trace::exporter::SpanData> &spans) {
+  ::opencensus::proto::agent::trace::v1::ExportTraceServiceRequest request;
+  ConvertSpans(spans, &request);
+  *request.mutable_node() = nodeInfo_;
+  ExportRpcRequest(request);
+}
+
+void Handler::ExportRpcRequest(
+    const ::opencensus::proto::agent::trace::v1::ExportTraceServiceRequest
+        &request) {
+  // TODO: Re-work this to have a single long-running streaming RPC.
+  grpc::ClientContext context;
+  context.set_deadline(absl::ToChronoTime(absl::Now() + opts_.rpc_deadline));
+
+  auto stream = opts_.trace_service_stub->Export(&context);
+  if (stream == nullptr) {
+    std::cerr << "OcAgent trace exporter: Export() got a NULL stream.\n";
+    return;
+  }
+
+  if (!stream->Write(request)) {
+    std::cerr << "OcAgent trace exporter: Export() stream broken.\n";
+  }
+
+  stream->WritesDone();
+  grpc::Status status = stream->Finish();
+  if (!status.ok()) {
+    std::cerr << "OcAgent trace exporter: Export() failed: "
+              << opencensus::common::ToString(status) << "\n";
+  }
+}
+
+void Handler::InitNode() {
+  auto identifier = nodeInfo_.mutable_identifier();
+
+  identifier->set_host_name(::opencensus::common::Hostname());
+  identifier->set_pid(getpid());
+  opencensus::common::SetTimestamp(absl::Now(),
+                                   identifier->mutable_start_timestamp());
+
+  auto library_info = nodeInfo_.mutable_library_info();
+  library_info->set_language(
+      ::opencensus::proto::agent::common::v1::LibraryInfo_Language_CPP);
+  library_info->set_exporter_version(OPENCENSUS_VERSION);
+  library_info->set_core_library_version(OPENCENSUS_VERSION);
+
+  auto service_info = nodeInfo_.mutable_service_info();
+  if (!opts_.service_name.empty()) {
+    service_info->set_name(opts_.service_name);
+  }
+}
+
+void Handler::ConnectAgent() {
+  ::opencensus::proto::agent::trace::v1::ExportTraceServiceRequest request;
+  *request.mutable_node() = nodeInfo_;
+  ExportRpcRequest(request);
+
+#if 0
+  // Config is unimplemented as of opencensus-service v0.1.9:
+  //
+  // https://github.com/census-instrumentation/opencensus-service/blob/0747a8305a08390e9eb7f8b6e2baa5143fc18c1d/receiver/opencensusreceiver/octrace/opencensus.go#L85
+  //
+  // Resurrect this code when the service implements the handler.
+
+  ::opencensus::proto::agent::trace::v1::CurrentLibraryConfig cur_lib_cfg;
+  *cur_lib_cfg.mutable_node() = nodeInfo_;
+
+  // Config
+  auto config = cur_lib_cfg.mutable_config();
+  auto sampler = config->mutable_constant_sampler();
+  sampler->set_decision(::opencensus::proto::trace::v1::
+                            ConstantSampler_ConstantDecision_ALWAYS_ON);
+
+  grpc::ClientContext context;
+  context.set_deadline(absl::ToChronoTime(absl::Now() + opts_.rpc_deadline));
+
+  auto stream = opts_.trace_service_stub->Config(&context);
+  if (stream == nullptr) {
+    std::cerr << "OcAgent trace exporter: Config() got a NULL stream.\n";
+    return;
+  }
+
+  if (!stream->Write(cur_lib_cfg)) {
+    std::cerr << "OcAgent trace exporter: Config() stream broken.\n";
+  }
+
+  stream->WritesDone();
+  grpc::Status status = stream->Finish();
+  if (!status.ok()) {
+    std::cerr << "OcAgent trace exporter: Config() failed: "
+              << opencensus::common::ToString(status) << "\n";
+  }
+#endif
+}
+
+}  // namespace
+
+// static
+void OcAgentExporter::Register(OcAgentOptions &&opts) {
+  if (opts.trace_service_stub == nullptr) {
+    auto channel = grpc::CreateCustomChannel(
+        opts.address, grpc::InsecureChannelCredentials(),
+        ::opencensus::common::WithUserAgent());
+    opts.trace_service_stub =
+        ::opencensus::proto::agent::trace::v1::TraceService::NewStub(channel);
+  }
+  ::opencensus::trace::exporter::SpanExporter::RegisterHandler(
+      absl::make_unique<Handler>(std::move(opts)));
+}
+
+}  // namespace trace
+}  // namespace exporters
+}  // namespace opencensus
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/internal/zipkin_exporter_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/internal/ocagent_exporter_test.cc
similarity index 70%
copy from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/internal/zipkin_exporter_test.cc
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/internal/ocagent_exporter_test.cc
index 3b78585..2ec9205 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/internal/zipkin_exporter_test.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/internal/ocagent_exporter_test.cc
@@ -1,4 +1,4 @@
-// Copyright 2018, OpenCensus Authors
+// Copyright 2019, OpenCensus Authors
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "opencensus/exporters/trace/zipkin/zipkin_exporter.h"
+#include "opencensus/exporters/trace/ocagent/ocagent_exporter.h"
 
 #include "absl/time/clock.h"
 #include "gtest/gtest.h"
@@ -24,28 +24,27 @@ namespace opencensus {
 namespace exporters {
 namespace trace {
 
-class ZipkinExporterTestPeer : public ::testing::Test {
+class OcAgentExporterTestPeer : public ::testing::Test {
  public:
-  ZipkinExporterTestPeer() {
-    // Register zipkin exporter
-    ZipkinExporterOptions options("http://127.0.0.1:9411/api/v2/spans");
-    options.af_type = ZipkinExporterOptions::AddressFamily::kIpv4;
-    options.service_name = "TestService";
-    ZipkinExporter::Register(options);
+  OcAgentExporterTestPeer() {
+    // Register ocagent exporter
+    OcAgentOptions opts;
+    opts.address = "localhost:55678";
+    OcAgentExporter::Register(std::move(opts));
   }
 };
 
-TEST_F(ZipkinExporterTestPeer, ExportTrace) {
+TEST_F(OcAgentExporterTestPeer, ExportTrace) {
   ::opencensus::trace::AlwaysSampler sampler;
   ::opencensus::trace::StartSpanOptions opts = {&sampler};
 
   auto span1 = ::opencensus::trace::Span::StartSpan("Span1", nullptr, opts);
-  absl::SleepFor(absl::Milliseconds(100));
   span1.AddAnnotation("Annotation1", {{"TestBool", true}});
+
   auto span2 = ::opencensus::trace::Span::StartSpan("Span2", &span1, opts);
-  absl::SleepFor(absl::Milliseconds(100));
   span2.AddAnnotation("Annotation2",
                       {{"TestString", "Test"}, {"TestInt", 123}});
+
   auto span3 = ::opencensus::trace::Span::StartSpan("Span3", &span2, opts);
   span3.AddAttributes({{"key1", "value1"},
                        {"int_key", 123},
@@ -54,14 +53,17 @@ TEST_F(ZipkinExporterTestPeer, ExportTrace) {
   span3.AddAnnotation("Annotation3", {{"TestString", "Test"}});
   span3.AddSentMessageEvent(2, 3, 4);
   span3.AddReceivedMessageEvent(3, 4, 5);
-  absl::SleepFor(absl::Milliseconds(100));
+
+  auto span4 = ::opencensus::trace::Span::StartSpan("Span4", nullptr, opts);
+  span2.AddChildLink(span4.context(), ::opencensus::trace::AttributesRef(
+                                          {{"reason", "span4 is a child"}}));
+
+  span4.End();
   span3.End();
-  absl::SleepFor(absl::Milliseconds(100));
   span2.End();
-  absl::SleepFor(absl::Milliseconds(100));
   span1.End();
 
-  // Wait long enough for spans to be exporter to zipkin server.
+  // Wait long enough for spans to be exporter to ocagent server.
   absl::SleepFor(absl::Seconds(6));
 }
 
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/ocagent_exporter.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/ocagent_exporter.h
new file mode 100644
index 0000000..862c8bd
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/ocagent/ocagent_exporter.h
@@ -0,0 +1,60 @@
+// Copyright 2019, OpenCensus Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef OPENCENSUS_EXPORTERS_TRACE_OCAGENT_OCAGENT_EXPORTER_H_
+#define OPENCENSUS_EXPORTERS_TRACE_OCAGENT_OCAGENT_EXPORTER_H_
+
+#include <string>
+
+#include "absl/time/time.h"
+
+#include "opencensus/proto/agent/trace/v1/trace_service.grpc.pb.h"
+#include "opencensus/proto/agent/trace/v1/trace_service.pb.h"
+
+namespace opencensus {
+namespace exporters {
+namespace trace {
+
+struct OcAgentOptions {
+  // The OcAgent address to use.
+  std::string address;
+
+  // The RPC deadline to use when exporting to OcAgent.
+  absl::Duration rpc_deadline = absl::Seconds(5);
+
+  // (optional) If not empty, set the service name to this.
+  std::string service_name;
+
+  // (optional) By default, the exporter connects to OcAgent using address. If
+  // this stub is non-null, the exporter will use this stub to send
+  // gRPC calls instead and ignore the address. Useful for testing.
+  std::unique_ptr<
+      opencensus::proto::agent::trace::v1::TraceService::StubInterface>
+      trace_service_stub;
+};
+
+class OcAgentExporter {
+ public:
+  // Registers the exporter.
+  static void Register(OcAgentOptions &&opts);
+
+ private:
+  OcAgentExporter() = delete;
+};
+
+}  // namespace trace
+}  // namespace exporters
+}  // namespace opencensus
+
+#endif  // OPENCENSUS_EXPORTERS_TRACE_OCAGENT_OCAGENT_EXPORTER_H_
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stackdriver/BUILD
similarity index 86%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stackdriver/BUILD
index aa45c01..297fb7d 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/BUILD
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stackdriver/BUILD
@@ -29,6 +29,7 @@ cc_library(
     visibility = ["//visibility:public"],
     deps = [
         "//opencensus/common:version",
+        "//opencensus/common/internal:timestamp",
         "//opencensus/common/internal/grpc:status",
         "//opencensus/common/internal/grpc:with_user_agent",
         "//opencensus/trace",
@@ -37,7 +38,7 @@ cc_library(
         "@com_google_absl//absl/memory",
         "@com_google_absl//absl/strings",
         "@com_google_absl//absl/time",
-        "@com_google_googleapis//google/devtools/cloudtrace/v2:trace_cc_grpc",
-        "@com_google_googleapis//google/devtools/cloudtrace/v2:trace_cc_proto",
+        "@com_google_googleapis//google/devtools/cloudtrace/v2:cloudtrace_cc_grpc",
+        "@com_google_googleapis//google/devtools/cloudtrace/v2:cloudtrace_cc_proto",
     ],
 )
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/README.md b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stackdriver/README.md
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/README.md
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stackdriver/README.md
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/internal/stackdriver_exporter.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stackdriver/internal/stackdriver_exporter.cc
similarity index 91%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/internal/stackdriver_exporter.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stackdriver/internal/stackdriver_exporter.cc
index d3863a0..4aec503 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/internal/stackdriver_exporter.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stackdriver/internal/stackdriver_exporter.cc
@@ -25,6 +25,7 @@
 #include "google/devtools/cloudtrace/v2/tracing.grpc.pb.h"
 #include "opencensus/common/internal/grpc/status.h"
 #include "opencensus/common/internal/grpc/with_user_agent.h"
+#include "opencensus/common/internal/timestamp.h"
 #include "opencensus/common/version.h"
 #include "opencensus/trace/exporter/span_data.h"
 #include "opencensus/trace/exporter/span_exporter.h"
@@ -42,26 +43,6 @@ constexpr char kGoogleStackdriverTraceAddress[] = "cloudtrace.googleapis.com";
 constexpr char kAgentKey[] = "g.co/agent";
 constexpr char kAgentValue[] = "opencensus-cpp [" OPENCENSUS_VERSION "]";
 
-bool Validate(const google::protobuf::Timestamp& t) {
-  const auto sec = t.seconds();
-  const auto ns = t.nanos();
-  // sec must be [0001-01-01T00:00:00Z, 9999-12-31T23:59:59.999999999Z]
-  if (sec < -62135596800 || sec > 253402300799) {
-    return false;
-  }
-  if (ns < 0 || ns > 999999999) {
-    return false;
-  }
-  return true;
-}
-
-bool EncodeTimestampProto(absl::Time t, google::protobuf::Timestamp* proto) {
-  const int64_t s = absl::ToUnixSeconds(t);
-  proto->set_seconds(s);
-  proto->set_nanos((t - absl::FromUnixSeconds(s)) / absl::Nanoseconds(1));
-  return Validate(*proto);
-}
-
 void SetTruncatableString(
     absl::string_view str, size_t max_len,
     ::google::devtools::cloudtrace::v2::TruncatableString* t_str) {
@@ -140,9 +121,8 @@ void ConvertTimeEvents(const ::opencensus::trace::exporter::SpanData& span,
                        ::google::devtools::cloudtrace::v2::Span* proto_span) {
   for (const auto& annotation : span.annotations().events()) {
     auto event = proto_span->mutable_time_events()->add_time_event();
-
-    // Encode Timestamp
-    EncodeTimestampProto(annotation.timestamp(), event->mutable_time());
+    opencensus::common::SetTimestamp(annotation.timestamp(),
+                                     event->mutable_time());
 
     // Populate annotation.
     SetTruncatableString(annotation.event().description(), kAnnotationStringLen,
@@ -155,9 +135,8 @@ void ConvertTimeEvents(const ::opencensus::trace::exporter::SpanData& span,
 
   for (const auto& message : span.message_events().events()) {
     auto event = proto_span->mutable_time_events()->add_time_event();
-
-    // Encode Timestamp
-    EncodeTimestampProto(message.timestamp(), event->mutable_time());
+    opencensus::common::SetTimestamp(message.timestamp(),
+                                     event->mutable_time());
 
     // Populate message event.
     event->mutable_message_event()->set_type(
@@ -206,10 +185,12 @@ void ConvertSpans(
     to_span->set_parent_span_id(from_span.parent_span_id().ToHex());
 
     // The start time of the span.
-    EncodeTimestampProto(from_span.start_time(), to_span->mutable_start_time());
+    opencensus::common::SetTimestamp(from_span.start_time(),
+                                     to_span->mutable_start_time());
 
     // The end time of the span.
-    EncodeTimestampProto(from_span.end_time(), to_span->mutable_end_time());
+    opencensus::common::SetTimestamp(from_span.end_time(),
+                                     to_span->mutable_end_time());
 
     // Export Attributes
     ConvertAttributes(from_span, to_span);
@@ -256,11 +237,13 @@ void Handler::Export(
   ::google::protobuf::Empty response;
   grpc::ClientContext context;
   context.set_deadline(absl::ToChronoTime(absl::Now() + opts_.rpc_deadline));
+  opts_.prepare_client_context(&context);
   grpc::Status status =
       opts_.trace_service_stub->BatchWriteSpans(&context, request, &response);
   if (!status.ok()) {
-    std::cerr << "BatchWriteSpans failed: "
-              << opencensus::common::ToString(status) << "\n";
+    std::cerr << "BatchWriteSpans failed (" << spans.size() << " spans, "
+              << request.ByteSizeLong()
+              << " bytes): " << opencensus::common::ToString(status) << "\n";
   }
 }
 
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/stackdriver_exporter.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stackdriver/stackdriver_exporter.h
similarity index 82%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/stackdriver_exporter.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stackdriver/stackdriver_exporter.h
index c58848f..7a871b6 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stackdriver/stackdriver_exporter.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stackdriver/stackdriver_exporter.h
@@ -15,6 +15,7 @@
 #ifndef OPENCENSUS_EXPORTERS_TRACE_STACKDRIVER_STACKDRIVER_EXPORTER_H_
 #define OPENCENSUS_EXPORTERS_TRACE_STACKDRIVER_STACKDRIVER_EXPORTER_H_
 
+#include <functional>
 #include <memory>
 #include <string>
 
@@ -32,13 +33,20 @@ struct StackdriverOptions {
   std::string project_id;
 
   // The RPC deadline to use when exporting to Stackdriver.
-  absl::Duration rpc_deadline = absl::Seconds(5);
+  absl::Duration rpc_deadline = absl::Seconds(10);
 
   // (optional) By default, the exporter connects to Stackdriver using gRPC. If
   // this stub is non-null, the exporter will use this stub to send gRPC calls
   // instead. Useful for testing.
-  std::unique_ptr<google::devtools::cloudtrace::v2::TraceService::Stub>
+  std::unique_ptr<google::devtools::cloudtrace::v2::TraceService::StubInterface>
       trace_service_stub;
+
+  // (optional) A function which can be used to modify the grpc::ClientContext
+  // before making API requests. For example, to add custom credentials.
+  // This function will be called by the exporter before every BatchWriteSpans
+  // RPC. This function will not be called in parallel.
+  std::function<void(grpc::ClientContext*)> prepare_client_context =
+      [](grpc::ClientContext*) {};
 };
 
 class StackdriverExporter {
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stdout/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stdout/BUILD
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stdout/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stdout/BUILD
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/CMakeLists.txt b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stdout/CMakeLists.txt
similarity index 68%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/CMakeLists.txt
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stdout/CMakeLists.txt
index aab0ca4..c7c580f 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/CMakeLists.txt
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stdout/CMakeLists.txt
@@ -12,8 +12,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# add_subdirectory(stackdriver) TODO
+opencensus_lib(
+  exporters_trace_stdout
+  PUBLIC
+  SRCS
+  internal/stdout_exporter.cc
+  DEPS
+  trace
+  absl::base
+  absl::memory)
 
-add_subdirectory(stdout)
-
-# add_subdirectory(zipkin) TODO
+opencensus_test(exporters_trace_stdout_test internal/stdout_exporter_test.cc
+                exporters_trace_stdout trace absl::time)
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stdout/internal/stdout_exporter.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stdout/internal/stdout_exporter.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stdout/internal/stdout_exporter.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stdout/internal/stdout_exporter.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stdout/internal/stdout_exporter_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stdout/internal/stdout_exporter_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stdout/internal/stdout_exporter_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stdout/internal/stdout_exporter_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stdout/stdout_exporter.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stdout/stdout_exporter.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/stdout/stdout_exporter.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/stdout/stdout_exporter.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/BUILD
similarity index 96%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/BUILD
index 3ce606b..c92c2ae 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/BUILD
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/BUILD
@@ -34,7 +34,6 @@ cc_library(
         "//opencensus/trace",
         "@com_github_curl//:curl",
         "@com_github_tencent_rapidjson//:rapidjson",
-        "@com_google_absl//absl/base:core_headers",
         "@com_google_absl//absl/memory",
         "@com_google_absl//absl/strings",
         "@com_google_absl//absl/time",
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/README.md b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/README.md
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/README.md
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/README.md
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/internal/zipkin_exporter.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/internal/zipkin_exporter.cc
similarity index 99%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/internal/zipkin_exporter.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/internal/zipkin_exporter.cc
index 3e59e73..e84b4ec 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/internal/zipkin_exporter.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/internal/zipkin_exporter.cc
@@ -102,15 +102,15 @@ void SerializeJson(const ::opencensus::trace::exporter::SpanData& span,
   writer->Key("id");
   writer->String(span.context().span_id().ToHex());
 
-  // Write endpoint.  OpenCensus does not support this by default.
+  // Write localEndpoint. OpenCensus does not support this by default.
   writer->Key("localEndpoint");
   writer->StartObject();
   writer->Key("serviceName");
   writer->String(service.service_name);
-  if (service.af_type == ZipkinExporterOptions::AddressFamily::kIpv6) {
-    writer->Key("ipv6");
-  } else {
+  if (service.af_type == ZipkinExporterOptions::AddressFamily::kIpv4) {
     writer->Key("ipv4");
+  } else {
+    writer->Key("ipv6");
   }
   writer->String(service.ip_address);
   writer->EndObject();
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/internal/zipkin_exporter_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/internal/zipkin_exporter_test.cc
similarity index 97%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/internal/zipkin_exporter_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/internal/zipkin_exporter_test.cc
index 3b78585..03b2afc 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/internal/zipkin_exporter_test.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/internal/zipkin_exporter_test.cc
@@ -29,7 +29,6 @@ class ZipkinExporterTestPeer : public ::testing::Test {
   ZipkinExporterTestPeer() {
     // Register zipkin exporter
     ZipkinExporterOptions options("http://127.0.0.1:9411/api/v2/spans");
-    options.af_type = ZipkinExporterOptions::AddressFamily::kIpv4;
     options.service_name = "TestService";
     ZipkinExporter::Register(options);
   }
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/zipkin_exporter.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/zipkin_exporter.h
similarity index 98%
rename from cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/zipkin_exporter.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/zipkin_exporter.h
index 0168d84..544b978 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/exporters/trace/zipkin/zipkin_exporter.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/exporters/trace/zipkin/zipkin_exporter.h
@@ -46,7 +46,7 @@ struct ZipkinExporterOptions {
   std::string service_name;
   // Address family to be reported to zipkin collector.
   enum class AddressFamily : uint8_t { kIpv4, kIpv6 };
-  AddressFamily af_type;
+  AddressFamily af_type = AddressFamily::kIpv4;
 
   struct Service {
     Service() : af_type(AddressFamily::kIpv4) {}
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/BUILD
similarity index 98%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/BUILD
index 5e8e6b0..b6f0fd0 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/BUILD
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/BUILD
@@ -252,7 +252,6 @@ cc_binary(
     testonly = 1,
     srcs = ["internal/stats_manager_benchmark.cc"],
     copts = TEST_COPTS,
-    linkopts = ["-pthread"],  # Required for absl/synchronization bits.
     linkstatic = 1,
     deps = [
         ":core",
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/CMakeLists.txt b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/CMakeLists.txt
new file mode 100644
index 0000000..9b0d7af
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/CMakeLists.txt
@@ -0,0 +1,115 @@
+# Copyright 2018, OpenCensus Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+opencensus_lib(stats PUBLIC DEPS stats_core stats_recording)
+
+opencensus_lib(
+  stats_test_utils
+  PUBLIC
+  SRCS
+  testing/test_utils.cc
+  DEPS
+  stats_core
+  absl::memory
+  absl::time)
+
+opencensus_lib(
+  stats_core
+  SRCS
+  internal/aggregation.cc
+  internal/aggregation_window.cc
+  internal/bucket_boundaries.cc
+  internal/delta_producer.cc
+  internal/distribution.cc
+  internal/measure.cc
+  internal/measure_data.cc
+  internal/measure_descriptor.cc
+  internal/measure_registry.cc
+  internal/measure_registry_impl.cc
+  internal/set_aggregation_window.cc
+  internal/stats_exporter.cc
+  internal/stats_manager.cc
+  internal/view.cc
+  internal/view_data.cc
+  internal/view_data_impl.cc
+  internal/view_descriptor.cc
+  DEPS
+  absl::base
+  common_stats_object
+  common_string_vector_hash
+  tags
+  absl::memory
+  absl::strings
+  absl::synchronization
+  absl::time
+  absl::optional
+  absl::span)
+
+# Define NOMINMAX to fix build errors when compiling with MSVC.
+target_compile_definitions(opencensus_stats_core
+                           PUBLIC $<$<CXX_COMPILER_ID:MSVC>:NOMINMAX>)
+
+opencensus_lib(
+  stats_recording
+  SRCS
+  internal/recording.cc
+  DEPS
+  stats_core
+  tags
+  tags_context_util
+  absl::strings
+  absl::time)
+
+# ----------------------------------------------------------------------
+# Tests
+# ----------------------------------------------------------------------
+
+opencensus_test(stats_debug_string_test internal/debug_string_test.cc
+                stats_core absl::time)
+
+opencensus_test(stats_distribution_test internal/distribution_test.cc
+                stats_core stats_test_utils)
+
+opencensus_test(stats_bucket_boundaries_test internal/bucket_boundaries_test.cc
+                stats_core)
+
+opencensus_test(stats_measure_data_test internal/measure_data_test.cc
+                stats_core stats_test_utils absl::span)
+
+opencensus_test(stats_measure_registry_test internal/measure_registry_test.cc
+                stats_core absl::strings)
+
+opencensus_test(stats_stats_exporter_test internal/stats_exporter_test.cc
+                stats_core stats_recording absl::memory absl::time)
+
+opencensus_test(
+  stats_stats_manager_test
+  internal/stats_manager_test.cc
+  stats_core
+  stats_recording
+  stats_test_utils
+  tags
+  tags_with_tag_map)
+
+opencensus_test(stats_view_data_impl_test internal/view_data_impl_test.cc
+                stats_core absl::time)
+
+opencensus_benchmark(
+  stats_stats_manager_benchmark
+  internal/stats_manager_benchmark.cc
+  stats_core
+  stats_recording
+  absl::memory
+  absl::strings
+  absl::time)
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/README.md b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/README.md
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/README.md
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/README.md
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/aggregation.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/aggregation.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/aggregation.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/aggregation.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/bucket_boundaries.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/bucket_boundaries.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/bucket_boundaries.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/bucket_boundaries.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/distribution.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/distribution.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/distribution.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/distribution.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/examples/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/examples/BUILD
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/examples/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/examples/BUILD
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/examples/exporter_example.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/examples/exporter_example.cc
similarity index 94%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/examples/exporter_example.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/examples/exporter_example.cc
index 233bfd0..b77e71e 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/examples/exporter_example.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/examples/exporter_example.cc
@@ -60,10 +60,12 @@ class ExampleExporter : public opencensus::stats::StatsExporter::Handler {
         return;
       }
       std::string output;
-      absl::StrAppend(&output, "\nData for view \"", descriptor.name(),
-                      "\" from ", absl::FormatTime(view_data.start_time()),
-                      " to ", absl::FormatTime(view_data.end_time()), ":\n");
+      absl::StrAppend(&output, "\nData for view \"", descriptor.name(), "\n");
       for (const auto& row : view_data.double_data()) {
+        auto start_time = view_data.start_times().at(row.first);
+        absl::StrAppend(&output, "\nRow data from ",
+                        absl::FormatTime(start_time), " to ",
+                        absl::FormatTime(view_data.end_time()), ":\n");
         for (int i = 0; i < descriptor.columns().size(); ++i) {
           absl::StrAppend(&output, descriptor.columns()[i].name(), ":",
                           row.first[i], ", ");
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/examples/view_and_recording_example.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/examples/view_and_recording_example.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/examples/view_and_recording_example.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/examples/view_and_recording_example.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/aggregation.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/aggregation.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/aggregation.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/aggregation.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/aggregation_window.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/aggregation_window.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/aggregation_window.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/aggregation_window.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/aggregation_window.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/aggregation_window.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/aggregation_window.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/aggregation_window.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/bucket_boundaries.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/bucket_boundaries.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/bucket_boundaries.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/bucket_boundaries.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/bucket_boundaries_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/bucket_boundaries_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/bucket_boundaries_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/bucket_boundaries_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/debug_string_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/debug_string_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/debug_string_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/debug_string_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/delta_producer.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/delta_producer.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/delta_producer.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/delta_producer.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/delta_producer.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/delta_producer.h
similarity index 87%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/delta_producer.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/delta_producer.h
index 2cff522..bec5605 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/delta_producer.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/delta_producer.h
@@ -79,10 +79,10 @@ class DeltaProducer final {
   void AddBoundaries(uint64_t index, const BucketBoundaries& boundaries);
 
   void Record(std::initializer_list<Measurement> measurements,
-              opencensus::tags::TagMap tags) LOCKS_EXCLUDED(delta_mu_);
+              opencensus::tags::TagMap tags) ABSL_LOCKS_EXCLUDED(delta_mu_);
 
   // Flushes the active delta and blocks until it is harvested.
-  void Flush() LOCKS_EXCLUDED(delta_mu_, harvester_mu_);
+  void Flush() ABSL_LOCKS_EXCLUDED(delta_mu_, harvester_mu_);
 
  private:
   DeltaProducer();
@@ -92,9 +92,9 @@ class DeltaProducer final {
   // ConsumeLastDelta so that Record() is blocked for as little time as
   // possible. SwapDeltas should never be called without then calling
   // ConsumeLastDelta--otherwise the delta will be lost.
-  void SwapDeltas() EXCLUSIVE_LOCKS_REQUIRED(delta_mu_, harvester_mu_);
-  void ConsumeLastDelta() EXCLUSIVE_LOCKS_REQUIRED(harvester_mu_)
-      LOCKS_EXCLUDED(delta_mu_);
+  void SwapDeltas() ABSL_EXCLUSIVE_LOCKS_REQUIRED(delta_mu_, harvester_mu_);
+  void ConsumeLastDelta() ABSL_EXCLUSIVE_LOCKS_REQUIRED(harvester_mu_)
+      ABSL_LOCKS_EXCLUDED(delta_mu_);
 
   // Loops flushing the active delta (calling SwapDeltas and ConsumeLastDelta())
   // every harvest_interval_.
@@ -112,16 +112,16 @@ class DeltaProducer final {
   // The BucketBoundaries of each registered view with Distribution aggregation,
   // by measure. Array indices in the outer array correspond to measure indices.
   std::vector<std::vector<BucketBoundaries>> registered_boundaries_
-      GUARDED_BY(delta_mu_);
-  Delta active_delta_ GUARDED_BY(delta_mu_);
+      ABSL_GUARDED_BY(delta_mu_);
+  Delta active_delta_ ABSL_GUARDED_BY(delta_mu_);
 
   // Guards the last_delta_; acquired by the main thread when triggering a
   // flush.
-  mutable absl::Mutex harvester_mu_ ACQUIRED_AFTER(delta_mu_);
+  mutable absl::Mutex harvester_mu_ ABSL_ACQUIRED_AFTER(delta_mu_);
   // TODO: consider making this a lockless queue to avoid blocking the main
   // thread when calling a flush during harvesting.
-  Delta last_delta_ GUARDED_BY(harvester_mu_);
-  std::thread harvester_thread_ GUARDED_BY(harvester_mu_);
+  Delta last_delta_ ABSL_GUARDED_BY(harvester_mu_);
+  std::thread harvester_thread_ ABSL_GUARDED_BY(harvester_mu_);
 };
 
 }  // namespace stats
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/distribution.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/distribution.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/distribution.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/distribution.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/distribution_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/distribution_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/distribution_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/distribution_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_data.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_data.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_data.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_data.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_data.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_data.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_data.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_data.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_data_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_data_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_data_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_data_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_descriptor.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_descriptor.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_descriptor.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_descriptor.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_registry.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_registry.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_registry.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_registry.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_registry_impl.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_registry_impl.cc
similarity index 96%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_registry_impl.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_registry_impl.cc
index 304a14d..999796d 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_registry_impl.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_registry_impl.cc
@@ -16,6 +16,7 @@
 
 #include <iostream>
 
+#include "absl/memory/memory.h"
 #include "opencensus/stats/internal/delta_producer.h"
 #include "opencensus/stats/internal/stats_manager.h"
 #include "opencensus/stats/measure_descriptor.h"
@@ -83,7 +84,8 @@ uint64_t MeasureRegistryImpl::RegisterImpl(MeasureDescriptor descriptor) {
   const uint64_t id =
       CreateMeasureId(registered_descriptors_.size(), true, descriptor.type());
   id_map_.emplace_hint(it, descriptor.name(), id);
-  registered_descriptors_.push_back(std::move(descriptor));
+  registered_descriptors_.push_back(
+      absl::make_unique<MeasureDescriptor>(std::move(descriptor)));
   return id;
 }
 
@@ -96,7 +98,7 @@ const MeasureDescriptor& MeasureRegistryImpl::GetDescriptorByName(
         MeasureDescriptor("", "", "", MeasureDescriptor::Type::kDouble);
     return default_descriptor;
   } else {
-    return registered_descriptors_[IdToIndex(it->second)];
+    return *registered_descriptors_[IdToIndex(it->second)];
   }
 }
 
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_registry_impl.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_registry_impl.h
similarity index 80%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_registry_impl.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_registry_impl.h
index 1420eb5..509f3aa 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_registry_impl.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_registry_impl.h
@@ -16,6 +16,7 @@
 #define OPENCENSUS_STATS_INTERNAL_MEASURE_REGISTRY_IMPL_H_
 
 #include <cstdint>
+#include <memory>
 #include <string>
 #include <unordered_map>
 #include <vector>
@@ -38,23 +39,23 @@ class MeasureRegistryImpl {
   template <typename MeasureT>
   Measure<MeasureT> Register(absl::string_view name,
                              absl::string_view description,
-                             absl::string_view units) LOCKS_EXCLUDED(mu_);
+                             absl::string_view units) ABSL_LOCKS_EXCLUDED(mu_);
 
   const MeasureDescriptor& GetDescriptorByName(absl::string_view name) const
-      LOCKS_EXCLUDED(mu_);
+      ABSL_LOCKS_EXCLUDED(mu_);
 
   MeasureDouble GetMeasureDoubleByName(absl::string_view name) const
-      LOCKS_EXCLUDED(mu_);
+      ABSL_LOCKS_EXCLUDED(mu_);
   MeasureInt64 GetMeasureInt64ByName(absl::string_view name) const
-      LOCKS_EXCLUDED(mu_);
+      ABSL_LOCKS_EXCLUDED(mu_);
 
   // The following methods are for internal use by the library, and not exposed
   // in the public MeasureRegistry.
-  uint64_t GetIdByName(absl::string_view name) const LOCKS_EXCLUDED(mu_);
+  uint64_t GetIdByName(absl::string_view name) const ABSL_LOCKS_EXCLUDED(mu_);
 
   template <typename MeasureT>
   const MeasureDescriptor& GetDescriptor(Measure<MeasureT> measure) const
-      LOCKS_EXCLUDED(mu_);
+      ABSL_LOCKS_EXCLUDED(mu_);
 
   // Measure ids contain a sequential index, a validity bit, and a
   // type bit; these functions access the individual parts.
@@ -68,17 +69,20 @@ class MeasureRegistryImpl {
  private:
   MeasureRegistryImpl() = default;
 
-  uint64_t RegisterImpl(MeasureDescriptor descriptor) LOCKS_EXCLUDED(mu_);
+  uint64_t RegisterImpl(MeasureDescriptor descriptor) ABSL_LOCKS_EXCLUDED(mu_);
 
   static uint64_t CreateMeasureId(uint64_t index, bool is_valid,
                                   MeasureDescriptor::Type type);
 
   mutable absl::Mutex mu_;
-  // The registered MeasureDescriptors. Measure id are indexes into this
-  // vector plus some flags in the high bits.
-  std::vector<MeasureDescriptor> registered_descriptors_ GUARDED_BY(mu_);
+  // The registered MeasureDescriptors. Measure ids are indexes into this
+  // vector plus some flags in the high bits. Heap allocated so that the
+  // descriptors themselves don't move around when the vector storage moves due
+  // to resize.
+  std::vector<std::unique_ptr<MeasureDescriptor>> registered_descriptors_
+      ABSL_GUARDED_BY(mu_);
   // A map from measure names to IDs.
-  std::unordered_map<std::string, uint64_t> id_map_ GUARDED_BY(mu_);
+  std::unordered_map<std::string, uint64_t> id_map_ ABSL_GUARDED_BY(mu_);
 };
 
 template <>
@@ -100,7 +104,7 @@ const MeasureDescriptor& MeasureRegistryImpl::GetDescriptor(
         MeasureDescriptor("", "", "", MeasureDescriptor::Type::kDouble);
     return default_descriptor;
   }
-  return registered_descriptors_[IdToIndex(measure.id_)];
+  return *registered_descriptors_[IdToIndex(measure.id_)];
 }
 
 // static
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_registry_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_registry_test.cc
similarity index 91%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_registry_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_registry_test.cc
index 36b2e45..b6b89dc 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/measure_registry_test.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/measure_registry_test.cc
@@ -147,6 +147,20 @@ TEST(MeasureRegistryTest, GetMeasureByNameWithWrongTypeFails) {
   EXPECT_NE(measure_int.GetDescriptor(), measure_int_mistyped.GetDescriptor());
 }
 
+TEST(MeasureRegistryTest, GrowDescriptorVector) {
+  const std::string name = MakeUniqueName();
+  ASSERT_TRUE(MeasureDouble::Register(name, "desc", "units").IsValid());
+  const MeasureDescriptor& md = MeasureRegistry::GetDescriptorByName(name);
+
+  // Add descriptors until the vector of descriptors grows, moves, and
+  // invalidates md above.
+  for (int i = 0; i < 1000; ++i) {
+    EXPECT_EQ(MeasureDescriptor::Type::kDouble, md.type());
+    ASSERT_TRUE(
+        MeasureDouble::Register(MakeUniqueName(), "desc", "units").IsValid());
+  }
+}
+
 }  // namespace
 }  // namespace stats
 }  // namespace opencensus
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/recording.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/recording.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/recording.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/recording.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/set_aggregation_window.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/set_aggregation_window.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/set_aggregation_window.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/set_aggregation_window.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/set_aggregation_window.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/set_aggregation_window.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/set_aggregation_window.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/set_aggregation_window.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_exporter.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_exporter.cc
similarity index 84%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_exporter.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_exporter.cc
index d6a74af..7de96d6 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_exporter.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_exporter.cc
@@ -37,6 +37,16 @@ StatsExporterImpl* StatsExporterImpl::Get() {
   return global_stats_exporter_impl;
 }
 
+void StatsExporterImpl::SetInterval(absl::Duration interval) {
+  absl::MutexLock l(&mu_);
+  export_interval_ = interval;
+}
+
+absl::Time StatsExporterImpl::GetNextExportTime() const {
+  absl::MutexLock l(&mu_);
+  return absl::Now() + export_interval_;
+}
+
 void StatsExporterImpl::AddView(const ViewDescriptor& view) {
   absl::MutexLock l(&mu_);
   views_[view.name()] = absl::make_unique<opencensus::stats::View>(view);
@@ -84,37 +94,50 @@ void StatsExporterImpl::ClearHandlersForTesting() {
   handlers_.clear();
 }
 
-void StatsExporterImpl::StartExportThread() EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+void StatsExporterImpl::StartExportThread() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
   t_ = std::thread(&StatsExporterImpl::RunWorkerLoop, this);
   thread_started_ = true;
 }
 
 void StatsExporterImpl::RunWorkerLoop() {
-  absl::Time next_export_time = absl::Now() + export_interval_;
+  absl::Time next_export_time = GetNextExportTime();
   while (true) {
     // SleepFor() returns immediately when given a negative duration.
     absl::SleepFor(next_export_time - absl::Now());
     // In case the last export took longer than the export interval, we
     // calculate the next time from now.
-    next_export_time = absl::Now() + export_interval_;
+    next_export_time = GetNextExportTime();
     Export();
   }
 }
 
+// StatsExporter
+// -------------
+
+// static
+void StatsExporter::SetInterval(absl::Duration interval) {
+  StatsExporterImpl::Get()->SetInterval(interval);
+}
+
+// static
 void StatsExporter::RemoveView(absl::string_view name) {
   StatsExporterImpl::Get()->RemoveView(name);
 }
 
+// static
 void StatsExporter::RegisterPushHandler(std::unique_ptr<Handler> handler) {
   StatsExporterImpl::Get()->RegisterPushHandler(std::move(handler));
 }
 
+// static
 std::vector<std::pair<ViewDescriptor, ViewData>> StatsExporter::GetViewData() {
   return StatsExporterImpl::Get()->GetViewData();
 }
 
+// static
 void StatsExporter::ExportForTesting() { StatsExporterImpl::Get()->Export(); }
 
+// static
 void StatsExporter::ClearHandlersForTesting() {
   StatsExporterImpl::Get()->ClearHandlersForTesting();
 }
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_exporter_impl.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_exporter_impl.h
similarity index 80%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_exporter_impl.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_exporter_impl.h
index a8a046a..abbd13e 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_exporter_impl.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_exporter_impl.h
@@ -33,9 +33,9 @@ namespace stats {
 class StatsExporterImpl {
  public:
   static StatsExporterImpl* Get();
-
+  void SetInterval(absl::Duration interval);
+  absl::Time GetNextExportTime() const;
   void AddView(const ViewDescriptor& view);
-
   void RemoveView(absl::string_view name);
 
   // Adds a handler, which cannot be subsequently removed (except by
@@ -44,29 +44,25 @@ class StatsExporterImpl {
   void RegisterPushHandler(std::unique_ptr<StatsExporter::Handler> handler);
 
   std::vector<std::pair<ViewDescriptor, ViewData>> GetViewData();
-
   void Export();
-
   void ClearHandlersForTesting();
 
  private:
-  StatsExporterImpl() {}
+  StatsExporterImpl() = default;
 
-  void StartExportThread() EXCLUSIVE_LOCKS_REQUIRED(mu_);
+  void StartExportThread() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
 
   // Loops forever, calling Export() every export_interval_.
   void RunWorkerLoop();
 
-  const absl::Duration export_interval_ = absl::Seconds(10);
-
   mutable absl::Mutex mu_;
-
+  absl::Duration export_interval_ ABSL_GUARDED_BY(mu_) = absl::Seconds(10);
   std::vector<std::unique_ptr<StatsExporter::Handler>> handlers_
-      GUARDED_BY(mu_);
-  std::unordered_map<std::string, std::unique_ptr<View>> views_ GUARDED_BY(mu_);
-
-  bool thread_started_ GUARDED_BY(mu_) = false;
-  std::thread t_ GUARDED_BY(mu_);
+      ABSL_GUARDED_BY(mu_);
+  std::unordered_map<std::string, std::unique_ptr<View>> views_
+      ABSL_GUARDED_BY(mu_);
+  bool thread_started_ ABSL_GUARDED_BY(mu_) = false;
+  std::thread t_ ABSL_GUARDED_BY(mu_);
 };
 
 }  // namespace stats
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_exporter_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_exporter_test.cc
similarity index 80%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_exporter_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_exporter_test.cc
index f362bb6..30d06a1 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_exporter_test.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_exporter_test.cc
@@ -31,29 +31,38 @@
 namespace opencensus {
 namespace stats {
 
+struct ExportedData {
+  std::vector<std::pair<ViewDescriptor, ViewData>> Get() const {
+    absl::MutexLock l(&mu);
+    return data;
+  }
+
+  mutable absl::Mutex mu;
+  std::vector<std::pair<ViewDescriptor, ViewData>> data ABSL_GUARDED_BY(mu);
+};
+
 // A mock exporter that assigns exported data to the provided pointer.
 class MockExporter : public StatsExporter::Handler {
  public:
-  static void Register(
-      std::vector<std::pair<ViewDescriptor, ViewData>>* output) {
+  static void Register(ExportedData* output) {
     opencensus::stats::StatsExporter::RegisterPushHandler(
         absl::make_unique<MockExporter>(output));
   }
 
-  MockExporter(std::vector<std::pair<ViewDescriptor, ViewData>>* output)
-      : output_(output) {}
+  MockExporter(ExportedData* output) : output_(output) {}
 
   void ExportViewData(
       const std::vector<std::pair<ViewDescriptor, ViewData>>& data) override {
+    absl::MutexLock l(&output_->mu);
     // Looping because ViewData is (intentionally) copy-constructable but not
     // copy_assignable.
     for (const auto& datum : data) {
-      output_->emplace_back(datum.first, datum.second);
+      output_->data.emplace_back(datum.first, datum.second);
     }
   }
 
  private:
-  std::vector<std::pair<ViewDescriptor, ViewData>>* output_;
+  ExportedData* output_;
 };
 
 constexpr char kMeasureId[] = "test_measure_id";
@@ -65,6 +74,8 @@ MeasureDouble TestMeasure() {
 
 class StatsExporterTest : public ::testing::Test {
  protected:
+  static void SetUpTestSuite() { StatsExporter::SetInterval(absl::Seconds(5)); }
+
   void SetUp() {
     // Access the measure to ensure it has been registered.
     TestMeasure();
@@ -94,7 +105,7 @@ class StatsExporterTest : public ::testing::Test {
 };
 
 TEST_F(StatsExporterTest, AddView) {
-  std::vector<std::pair<ViewDescriptor, ViewData>> exported_data;
+  ExportedData exported_data;
   MockExporter::Register(&exported_data);
   descriptor1_.RegisterForExport();
   descriptor2_.RegisterForExport();
@@ -102,13 +113,13 @@ TEST_F(StatsExporterTest, AddView) {
               ::testing::UnorderedElementsAre(::testing::Key(descriptor1_),
                                               ::testing::Key(descriptor2_)));
   Export();
-  EXPECT_THAT(exported_data,
+  EXPECT_THAT(exported_data.Get(),
               ::testing::UnorderedElementsAre(::testing::Key(descriptor1_),
                                               ::testing::Key(descriptor2_)));
 }
 
 TEST_F(StatsExporterTest, UpdateView) {
-  std::vector<std::pair<ViewDescriptor, ViewData>> exported_data;
+  ExportedData exported_data;
   MockExporter::Register(&exported_data);
   descriptor1_.RegisterForExport();
   descriptor2_.RegisterForExport();
@@ -118,13 +129,13 @@ TEST_F(StatsExporterTest, UpdateView) {
       ::testing::UnorderedElementsAre(::testing::Key(descriptor1_edited_),
                                       ::testing::Key(descriptor2_)));
   Export();
-  EXPECT_THAT(exported_data, ::testing::UnorderedElementsAre(
-                                 ::testing::Key(descriptor1_edited_),
-                                 ::testing::Key(descriptor2_)));
+  EXPECT_THAT(exported_data.Get(), ::testing::UnorderedElementsAre(
+                                       ::testing::Key(descriptor1_edited_),
+                                       ::testing::Key(descriptor2_)));
 }
 
 TEST_F(StatsExporterTest, RemoveView) {
-  std::vector<std::pair<ViewDescriptor, ViewData>> exported_data;
+  ExportedData exported_data;
   MockExporter::Register(&exported_data);
   descriptor1_.RegisterForExport();
   descriptor2_.RegisterForExport();
@@ -132,25 +143,25 @@ TEST_F(StatsExporterTest, RemoveView) {
   EXPECT_THAT(StatsExporter::GetViewData(),
               ::testing::UnorderedElementsAre(::testing::Key(descriptor2_)));
   Export();
-  EXPECT_THAT(exported_data,
+  EXPECT_THAT(exported_data.Get(),
               ::testing::UnorderedElementsAre(::testing::Key(descriptor2_)));
 }
 
 TEST_F(StatsExporterTest, MultipleExporters) {
-  std::vector<std::pair<ViewDescriptor, ViewData>> exported_data_1;
+  ExportedData exported_data_1;
   MockExporter::Register(&exported_data_1);
-  std::vector<std::pair<ViewDescriptor, ViewData>> exported_data_2;
+  ExportedData exported_data_2;
   MockExporter::Register(&exported_data_2);
   descriptor1_.RegisterForExport();
   Export();
-  EXPECT_THAT(exported_data_1,
+  EXPECT_THAT(exported_data_1.Get(),
               ::testing::UnorderedElementsAre(::testing::Key(descriptor1_)));
-  EXPECT_THAT(exported_data_2,
+  EXPECT_THAT(exported_data_2.Get(),
               ::testing::UnorderedElementsAre(::testing::Key(descriptor1_)));
 }
 
 TEST_F(StatsExporterTest, IntervalViewRejected) {
-  std::vector<std::pair<ViewDescriptor, ViewData>> exported_data;
+  ExportedData exported_data;
   MockExporter::Register(&exported_data);
   ViewDescriptor interval_descriptor = ViewDescriptor().set_name("interval");
   SetAggregationWindow(AggregationWindow::Interval(absl::Hours(1)),
@@ -158,15 +169,15 @@ TEST_F(StatsExporterTest, IntervalViewRejected) {
   interval_descriptor.RegisterForExport();
   EXPECT_TRUE(StatsExporter::GetViewData().empty());
   Export();
-  EXPECT_TRUE(exported_data.empty());
+  EXPECT_TRUE(exported_data.Get().empty());
 }
 
 TEST_F(StatsExporterTest, TimedExport) {
-  std::vector<std::pair<ViewDescriptor, ViewData>> exported_data;
+  ExportedData exported_data;
   MockExporter::Register(&exported_data);
   descriptor1_.RegisterForExport();
-  absl::SleepFor(absl::Seconds(11));
-  EXPECT_THAT(exported_data,
+  absl::SleepFor(absl::Seconds(6));
+  EXPECT_THAT(exported_data.Get(),
               ::testing::UnorderedElementsAre(::testing::Key(descriptor1_)));
 }
 
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_manager.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_manager.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_manager.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_manager.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_manager.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_manager.h
similarity index 89%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_manager.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_manager.h
index d0d43ec..7ee3da0 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_manager.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_manager.h
@@ -62,7 +62,7 @@ class StatsManager final {
                           const MeasureData& data, absl::Time now);
 
     // Retrieves a copy of the data.
-    std::unique_ptr<ViewDataImpl> GetData() LOCKS_EXCLUDED(*mu_);
+    std::unique_ptr<ViewDataImpl> GetData() ABSL_LOCKS_EXCLUDED(*mu_);
 
     const ViewDescriptor& view_descriptor() const { return descriptor_; }
 
@@ -72,33 +72,33 @@ class StatsManager final {
     absl::Mutex* const mu_;  // Not owned.
     // The number of View objects backed by this ViewInformation, for
     // reference-counted GC.
-    int num_consumers_ GUARDED_BY(*mu_) = 1;
+    int num_consumers_ ABSL_GUARDED_BY(*mu_) = 1;
 
     // Possible types of stored data.
     enum class DataType { kDouble, kUint64, kDistribution, kInterval };
     static DataType DataTypeForDescriptor(const ViewDescriptor& descriptor);
 
-    ViewDataImpl data_ GUARDED_BY(*mu_);
+    ViewDataImpl data_ ABSL_GUARDED_BY(*mu_);
   };
 
  public:
   static StatsManager* Get();
 
   // Merges all data from 'delta' at the present time.
-  void MergeDelta(const Delta& delta) LOCKS_EXCLUDED(mu_);
+  void MergeDelta(const Delta& delta) ABSL_LOCKS_EXCLUDED(mu_);
 
   // Adds a measure--this is necessary for views to be added under that measure.
   template <typename MeasureT>
-  void AddMeasure(Measure<MeasureT> measure) LOCKS_EXCLUDED(mu_);
+  void AddMeasure(Measure<MeasureT> measure) ABSL_LOCKS_EXCLUDED(mu_);
 
   // Returns a handle that can be used to retrieve data for 'descriptor' (which
   // may point to a new or re-used ViewInformation).
   ViewInformation* AddConsumer(const ViewDescriptor& descriptor)
-      LOCKS_EXCLUDED(mu_);
+      ABSL_LOCKS_EXCLUDED(mu_);
 
   // Removes a consumer from the ViewInformation 'handle', and deletes it if
   // that was the last consumer.
-  void RemoveConsumer(ViewInformation* handle) LOCKS_EXCLUDED(mu_);
+  void RemoveConsumer(ViewInformation* handle) ABSL_LOCKS_EXCLUDED(mu_);
 
  private:
   // MeasureInformation stores all ViewInformation objects for a given measure.
@@ -118,7 +118,7 @@ class StatsManager final {
     absl::Mutex* const mu_;  // Not owned.
     // View objects hold a pointer to ViewInformation directly, so we do not
     // need fast lookup--lookup is only needed for view removal.
-    std::vector<std::unique_ptr<ViewInformation>> views_ GUARDED_BY(*mu_);
+    std::vector<std::unique_ptr<ViewInformation>> views_ ABSL_GUARDED_BY(*mu_);
   };
 
   // TODO: PERF: Global synchronization is only needed for adding or
@@ -127,7 +127,7 @@ class StatsManager final {
   mutable absl::Mutex mu_;
 
   // All registered measures.
-  std::vector<MeasureInformation> measures_ GUARDED_BY(mu_);
+  std::vector<MeasureInformation> measures_ ABSL_GUARDED_BY(mu_);
 };
 
 extern template void StatsManager::AddMeasure(MeasureDouble measure);
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_manager_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_manager_benchmark.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_manager_benchmark.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_manager_benchmark.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_manager_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_manager_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/stats_manager_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/stats_manager_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data.cc
similarity index 89%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data.cc
index b11de4d..82570b0 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data.cc
@@ -18,6 +18,7 @@
 
 #include "absl/base/macros.h"
 #include "absl/memory/memory.h"
+#include "absl/time/clock.h"
 #include "opencensus/stats/internal/view_data_impl.h"
 
 namespace opencensus {
@@ -80,13 +81,19 @@ const ViewData::DataMap<Distribution>& ViewData::distribution_data() const {
 }
 
 absl::Time ViewData::start_time() const { return impl_->start_time(); }
-absl::Time ViewData::end_time() const { return impl_->end_time(); }
+
+const ViewData::DataMap<absl::Time>& ViewData::start_times() const {
+  return impl_->start_times();
+}
+
+absl::Time ViewData::end_time() const { return end_time_; }
 
 ViewData::ViewData(const ViewData& other)
-    : impl_(absl::make_unique<ViewDataImpl>(*other.impl_)) {}
+    : impl_(absl::make_unique<ViewDataImpl>(*other.impl_)),
+      end_time_(absl::Now()) {}
 
 ViewData::ViewData(std::unique_ptr<ViewDataImpl> data)
-    : impl_(std::move(data)) {
+    : impl_(std::move(data)), end_time_(absl::Now()) {
   ABSL_ASSERT(impl_->type() != ViewDataImpl::Type::kStatsObject);
 }
 
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data_impl.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data_impl.cc
similarity index 76%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data_impl.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data_impl.cc
index a4991fd..51a7635 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data_impl.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data_impl.cc
@@ -40,11 +40,17 @@ ViewDataImpl::Type ViewDataImpl::TypeForDescriptor(
               return ViewDataImpl::Type::kDouble;
             case MeasureDescriptor::Type::kInt64:
               return ViewDataImpl::Type::kInt64;
+            default:
+              ABSL_ASSERT(false && "Unknown measure_descriptor type.");
+              return ViewDataImpl::Type::kDouble;
           }
         case Aggregation::Type::kCount:
           return ViewDataImpl::Type::kInt64;
         case Aggregation::Type::kDistribution:
           return ViewDataImpl::Type::kDistribution;
+        default:
+          ABSL_ASSERT(false && "Unknown aggregation type.");
+          return ViewDataImpl::Type::kDouble;
       }
     case AggregationWindow::Type::kInterval:
       return ViewDataImpl::Type::kStatsObject;
@@ -58,6 +64,8 @@ ViewDataImpl::ViewDataImpl(absl::Time start_time,
     : aggregation_(descriptor.aggregation()),
       aggregation_window_(descriptor.aggregation_window_),
       type_(TypeForDescriptor(descriptor)),
+      start_times_(),
+      expiry_duration_(descriptor.expiry_duration_),
       start_time_(start_time) {
   switch (type_) {
     case Type::kDouble: {
@@ -85,10 +93,18 @@ ViewDataImpl::ViewDataImpl(const ViewDataImpl& other, absl::Time now)
       type_(other.aggregation().type() == Aggregation::Type::kDistribution
                 ? Type::kDistribution
                 : Type::kDouble),
+      start_times_(),
       start_time_(std::max(other.start_time(),
-                           now - other.aggregation_window().duration())),
-      end_time_(now) {
+                           now - other.aggregation_window().duration())) {
+  // Intentionally reset the source with a new start time.
+  for (const auto& it : other.start_times_) {
+    auto new_start_time =
+        std::max(it.second, now - other.aggregation_window().duration());
+    start_times_[it.first] = new_start_time;
+  }
+
   ABSL_ASSERT(aggregation_window_.type() == AggregationWindow::Type::kInterval);
+
   switch (aggregation_.type()) {
     case Aggregation::Type::kSum:
     case Aggregation::Type::kCount: {
@@ -151,8 +167,8 @@ ViewDataImpl::ViewDataImpl(const ViewDataImpl& other)
     : aggregation_(other.aggregation_),
       aggregation_window_(other.aggregation_window_),
       type_(other.type()),
-      start_time_(other.start_time_),
-      end_time_(other.end_time_) {
+      start_times_(other.start_times_),
+      start_time_(other.start_time_) {
   switch (type_) {
     case Type::kDouble: {
       new (&double_data_) DataMap<double>(other.double_data_);
@@ -178,7 +194,10 @@ ViewDataImpl::ViewDataImpl(const ViewDataImpl& other)
 
 void ViewDataImpl::Merge(const std::vector<std::string>& tag_values,
                          const MeasureData& data, absl::Time now) {
-  end_time_ = std::max(end_time_, now);
+  // A value is set here. Set a start time if it is unset.
+  SetStartTimeIfUnset(tag_values, now);
+  SetUpdateTime(tag_values, now);
+  PurgeExpired(now);
   switch (type_) {
     case Type::kDouble: {
       if (aggregation_.type() == Aggregation::Type::kSum) {
@@ -253,8 +272,8 @@ ViewDataImpl::ViewDataImpl(ViewDataImpl* source, absl::Time now)
     : aggregation_(source->aggregation_),
       aggregation_window_(source->aggregation_window_),
       type_(source->type_),
-      start_time_(source->start_time_),
-      end_time_(now) {
+      start_times_(source->start_times_),
+      start_time_(source->start_time_) {
   switch (type_) {
     case Type::kDouble: {
       new (&double_data_) DataMap<double>();
@@ -278,8 +297,67 @@ ViewDataImpl::ViewDataImpl(ViewDataImpl* source, absl::Time now)
       break;
     }
   }
+  // Intentionally reset the source with new start times.
   source->start_time_ = now;
-  source->end_time_ = now;
+
+  for (const auto& it : source->start_times_) {
+    source->start_times_[it.first] = now;
+  }
+}
+
+void ViewDataImpl::SetUpdateTime(const std::vector<std::string>& tag_values,
+                                 absl::Time now) {
+  if (expiry_duration_ == absl::ZeroDuration()) {
+    // No need to track last update time if expiry duration is not set.
+    return;
+  }
+
+  auto update_time_map_iter = update_time_entries_.find(tag_values);
+  if (update_time_map_iter == update_time_entries_.end()) {
+    // The timeseries is not tracked, add it to the update time list and map.
+    update_times_.emplace_front(now, tag_values);
+    update_time_entries_[tag_values] = update_times_.begin();
+  } else {
+    // The timeseries is tracked, update its updated time and move it to the
+    // front of the list.
+    auto update_time_list_iter = update_time_map_iter->second;
+    update_time_list_iter->first = now;
+    update_times_.splice(update_times_.begin(), update_times_,
+                         update_time_list_iter);
+  }
+}
+
+void ViewDataImpl::PurgeExpired(absl::Time now) {
+  if (expiry_duration_ == absl::ZeroDuration() || update_times_.empty()) {
+    // No need to remove expired entries since either expiry is not set or there
+    // is no data entry yet.
+    return;
+  }
+  // Remove data that has not been updated for expiry.
+  while (now - update_times_.back().first > expiry_duration_) {
+    const auto& tags = update_times_.back().second;
+    update_time_entries_.erase(tags);
+    start_times_.erase(tags);
+    switch (type_) {
+      case Type::kDouble: {
+        double_data_.erase(tags);
+        break;
+      }
+      case Type::kInt64: {
+        int_data_.erase(tags);
+        break;
+      }
+      case Type::kDistribution: {
+        distribution_data_.erase(tags);
+        break;
+      }
+      case Type::kStatsObject: {
+        interval_data_.erase(tags);
+        break;
+      }
+    }
+    update_times_.pop_back();
+  }
 }
 
 }  // namespace stats
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data_impl.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data_impl.h
similarity index 77%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data_impl.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data_impl.h
index 2dd334f..535a6c3 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data_impl.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data_impl.h
@@ -103,8 +103,13 @@ class ViewDataImpl {
     return interval_data_;
   }
 
+  // Returns a start time for each timeseries/tag map.
+  const DataMap<absl::Time>& start_times() const { return start_times_; }
+
+  // DEPRECATED: Legacy start_time_ for the entire view.
+  // This should be deleted if custom exporters are updated to
+  // use start_times_ and stop depending on this field.
   absl::Time start_time() const { return start_time_; }
-  absl::Time end_time() const { return end_time_; }
 
   // Merges bulk data for the given tag values at 'now'. tag_values must be
   // ordered according to the order of keys in the ViewDescriptor.
@@ -121,6 +126,22 @@ class ViewDataImpl {
 
   Type TypeForDescriptor(const ViewDescriptor& descriptor);
 
+  void SetStartTimeIfUnset(const std::vector<std::string>& tag_values,
+                           absl::Time now) {
+    // If the time is not set.
+    if (start_times_.find(tag_values) == start_times_.end()) {
+      start_times_[tag_values] = now;
+    }
+  }
+
+  // If expiry duration is set, keep track of the last update time of each view
+  // data.
+  void SetUpdateTime(const std::vector<std::string>& tag_values,
+                     absl::Time now);
+
+  // Purge view data that has not been updated for expiry duration.
+  void PurgeExpired(absl::Time now);
+
   const Aggregation aggregation_;
   const AggregationWindow aggregation_window_;
   const Type type_;
@@ -130,8 +151,24 @@ class ViewDataImpl {
     DataMap<Distribution> distribution_data_;
     DataMap<IntervalStatsObject> interval_data_;
   };
+
+  // A start time for each timeseries/tag map.
+  DataMap<absl::Time> start_times_;
+
+  using UpdateTimeList =
+      std::list<std::pair<absl::Time, std::vector<std::string>>>;
+
+  // A list of last update time for each timeseries.
+  UpdateTimeList update_times_;
+  // A map from view data tags to the last update time list iterator.
+  DataMap<UpdateTimeList::iterator> update_time_entries_;
+
+  const absl::Duration expiry_duration_;
+
+  // DEPRECATED: Legacy start_time_ for the entire view.
+  // This should be deleted if custom exporters are updated to
+  // use start_times_ and stop depending on this field
   absl::Time start_time_;
-  absl::Time end_time_;
 };
 
 }  // namespace stats
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data_impl_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data_impl_test.cc
similarity index 83%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data_impl_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data_impl_test.cc
index f7f2c18..bc6f317 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data_impl_test.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data_impl_test.cc
@@ -55,7 +55,8 @@ TEST(ViewDataImplTest, Sum) {
   EXPECT_EQ(Aggregation::Sum(), data.aggregation());
   EXPECT_EQ(AggregationWindow::Cumulative(), data.aggregation_window());
   EXPECT_EQ(start_time, data.start_time());
-  EXPECT_EQ(end_time, data.end_time());
+  EXPECT_EQ(start_time, data.start_times().at(tags1));
+  EXPECT_EQ(end_time, data.start_times().at(tags2));
   EXPECT_THAT(data.double_data(),
               ::testing::UnorderedElementsAre(::testing::Pair(tags1, 3),
                                               ::testing::Pair(tags2, 5)));
@@ -77,7 +78,8 @@ TEST(ViewDataImplTest, Count) {
   EXPECT_EQ(Aggregation::Count(), data.aggregation());
   EXPECT_EQ(AggregationWindow::Cumulative(), data.aggregation_window());
   EXPECT_EQ(start_time, data.start_time());
-  EXPECT_EQ(end_time, data.end_time());
+  EXPECT_EQ(start_time, data.start_times().at(tags1));
+  EXPECT_EQ(end_time, data.start_times().at(tags2));
   EXPECT_THAT(data.int_data(),
               ::testing::UnorderedElementsAre(::testing::Pair(tags1, 2),
                                               ::testing::Pair(tags2, 1)));
@@ -100,7 +102,8 @@ TEST(ViewDataImplTest, Distribution) {
   EXPECT_EQ(Aggregation::Distribution(buckets), data.aggregation());
   EXPECT_EQ(AggregationWindow::Cumulative(), data.aggregation_window());
   EXPECT_EQ(start_time, data.start_time());
-  EXPECT_EQ(end_time, data.end_time());
+  EXPECT_EQ(start_time, data.start_times().at(tags1));
+  EXPECT_EQ(end_time, data.start_times().at(tags2));
   EXPECT_EQ(data.distribution_data().size(), 2);
   EXPECT_THAT(data.distribution_data().find(tags1)->second.bucket_counts(),
               ::testing::ElementsAre(2, 0));
@@ -127,7 +130,8 @@ TEST(ViewDataImplTest, LastValueDouble) {
   EXPECT_EQ(Aggregation::LastValue(), data.aggregation());
   EXPECT_EQ(AggregationWindow::Cumulative(), data.aggregation_window());
   EXPECT_EQ(start_time, data.start_time());
-  EXPECT_EQ(end_time, data.end_time());
+  EXPECT_EQ(start_time, data.start_times().at(tags1));
+  EXPECT_EQ(end_time, data.start_times().at(tags2));
   EXPECT_THAT(data.double_data(),
               ::testing::UnorderedElementsAre(::testing::Pair(tags1, 5.0),
                                               ::testing::Pair(tags2, 15.0)));
@@ -152,7 +156,8 @@ TEST(ViewDataImplTest, LastValueInt64) {
   EXPECT_EQ(Aggregation::LastValue(), data.aggregation());
   EXPECT_EQ(AggregationWindow::Cumulative(), data.aggregation_window());
   EXPECT_EQ(start_time, data.start_time());
-  EXPECT_EQ(end_time, data.end_time());
+  EXPECT_EQ(start_time, data.start_times().at(tags1));
+  EXPECT_EQ(end_time, data.start_times().at(tags2));
   EXPECT_THAT(data.int_data(),
               ::testing::UnorderedElementsAre(::testing::Pair(tags1, 5),
                                               ::testing::Pair(tags2, 15)));
@@ -179,15 +184,16 @@ TEST(ViewDataImplTest, StatsObjectToCount) {
   EXPECT_EQ(AggregationWindow::Interval(interval),
             export_data1.aggregation_window());
   EXPECT_EQ(start_time, export_data1.start_time());
-  EXPECT_EQ(time, export_data1.end_time());
+  EXPECT_EQ(start_time, export_data1.start_times().at(tags1));
+  EXPECT_EQ(start_time, export_data1.start_times().at(tags2));
   EXPECT_THAT(export_data1.double_data(),
               ::testing::UnorderedElementsAre(::testing::Pair(tags1, 3),
                                               ::testing::Pair(tags2, 1)));
 
-  time += interval;
-  const ViewDataImpl export_data2(data, time);
-  EXPECT_EQ(time - interval, export_data2.start_time());
-  EXPECT_EQ(time, export_data2.end_time());
+  const ViewDataImpl export_data2(data, time + interval);
+  EXPECT_EQ(time, export_data2.start_time());
+  EXPECT_EQ(start_time, export_data1.start_times().at(tags1));
+  EXPECT_EQ(start_time, export_data1.start_times().at(tags2));
   EXPECT_THAT(export_data2.double_data(),
               ::testing::UnorderedElementsAre(::testing::Pair(tags1, 1),
                                               ::testing::Pair(tags2, 0)));
@@ -214,15 +220,16 @@ TEST(ViewDataImplTest, StatsObjectToSum) {
   EXPECT_EQ(AggregationWindow::Interval(interval),
             export_data1.aggregation_window());
   EXPECT_EQ(start_time, export_data1.start_time());
-  EXPECT_EQ(time, export_data1.end_time());
+  EXPECT_EQ(start_time, export_data1.start_times().at(tags1));
+  EXPECT_EQ(start_time, export_data1.start_times().at(tags2));
   EXPECT_THAT(export_data1.double_data(),
               ::testing::UnorderedElementsAre(::testing::Pair(tags1, 6),
                                               ::testing::Pair(tags2, 2)));
 
-  time += interval;
-  const ViewDataImpl export_data2(data, time);
-  EXPECT_EQ(time - interval, export_data2.start_time());
-  EXPECT_EQ(time, export_data2.end_time());
+  const ViewDataImpl export_data2(data, time + interval);
+  EXPECT_EQ(time, export_data2.start_time());
+  EXPECT_EQ(start_time, export_data1.start_times().at(tags1));
+  EXPECT_EQ(start_time, export_data1.start_times().at(tags2));
   EXPECT_THAT(export_data2.double_data(),
               ::testing::UnorderedElementsAre(::testing::Pair(tags1, 2),
                                               ::testing::Pair(tags2, 0)));
@@ -251,7 +258,8 @@ TEST(ViewDataImplTest, StatsObjectToDistribution) {
   EXPECT_EQ(AggregationWindow::Interval(interval),
             export_data1.aggregation_window());
   EXPECT_EQ(start_time, export_data1.start_time());
-  EXPECT_EQ(time, export_data1.end_time());
+  EXPECT_EQ(start_time, export_data1.start_times().at(tags1));
+  EXPECT_EQ(start_time, export_data1.start_times().at(tags2));
   EXPECT_EQ(2, export_data1.distribution_data().size());
   const Distribution& distribution_1_1 =
       export_data1.distribution_data().find(tags1)->second;
@@ -270,10 +278,10 @@ TEST(ViewDataImplTest, StatsObjectToDistribution) {
   EXPECT_EQ(0, distribution_2_1.max());
   EXPECT_THAT(distribution_2_1.bucket_counts(), ::testing::ElementsAre(1, 0));
 
-  time += interval;
-  const ViewDataImpl export_data2(data, time);
-  EXPECT_EQ(time - interval, export_data2.start_time());
-  EXPECT_EQ(time, export_data2.end_time());
+  const ViewDataImpl export_data2(data, time + interval);
+  EXPECT_EQ(time, export_data2.start_time());
+  EXPECT_EQ(time, export_data2.start_times().at(tags1));
+  EXPECT_EQ(time, export_data2.start_times().at(tags2));
   EXPECT_EQ(2, export_data2.distribution_data().size());
   const Distribution& distribution_1_2 =
       export_data2.distribution_data().find(tags1)->second;
@@ -293,6 +301,28 @@ TEST(ViewDataImplTest, StatsObjectToDistribution) {
   EXPECT_THAT(distribution_2_2.bucket_counts(), ::testing::ElementsAre(0, 0));
 }
 
+TEST(ViewDataImplTest, ViewDataExpiry) {
+  const absl::Time start_time = absl::UnixEpoch();
+  const auto descriptor = ViewDescriptor()
+                              .set_aggregation(Aggregation::Sum())
+                              .set_expiry_duration(absl::Seconds(1));
+  ViewDataImpl data(start_time, descriptor);
+  const std::vector<std::string> tags1({"value1", "value2a"});
+  const std::vector<std::string> tags2({"value1", "value2b"});
+
+  AddToViewDataImpl(1, tags1, start_time, {}, &data);
+  AddToViewDataImpl(1, tags2, start_time, {}, &data);
+
+  EXPECT_THAT(data.double_data(),
+              ::testing::UnorderedElementsAre(::testing::Pair(tags1, 1),
+                                              ::testing::Pair(tags2, 1)));
+
+  AddToViewDataImpl(1, tags1, start_time + absl::Seconds(2), {}, &data);
+
+  EXPECT_THAT(data.double_data(),
+              ::testing::UnorderedElementsAre(::testing::Pair(tags1, 2)));
+}
+
 }  // namespace
 }  // namespace stats
 }  // namespace opencensus
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_data_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_data_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_descriptor.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_descriptor.cc
similarity index 91%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_descriptor.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_descriptor.cc
index 43fcf4f..8bfa574 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/internal/view_descriptor.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/internal/view_descriptor.cc
@@ -74,6 +74,12 @@ ViewDescriptor& ViewDescriptor::set_description(absl::string_view description) {
   return *this;
 }
 
+ViewDescriptor& ViewDescriptor::set_expiry_duration(
+    absl::Duration expiry_duration) {
+  expiry_duration_ = expiry_duration;
+  return *this;
+}
+
 void ViewDescriptor::RegisterForExport() const {
   if (aggregation_window_.type() == AggregationWindow::Type::kCumulative) {
     StatsExporterImpl::Get()->AddView(*this);
@@ -93,14 +99,16 @@ std::string ViewDescriptor::DebugString() const {
                     [](std::string* out, opencensus::tags::TagKey key) {
                       return out->append(key.name());
                     }),
-      "\n  description: \"", description_, "\"");
+      "\n  description: \"", description_, "\"",
+      "\n  expiry duration: ", absl::FormatDuration(expiry_duration_));
 }
 
 bool ViewDescriptor::operator==(const ViewDescriptor& other) const {
   return name_ == other.name_ && measure_id_ == other.measure_id_ &&
          aggregation_ == other.aggregation_ &&
          aggregation_window_ == other.aggregation_window_ &&
-         columns_ == other.columns_ && description_ == other.description_;
+         columns_ == other.columns_ && description_ == other.description_ &&
+         expiry_duration_ == other.expiry_duration_;
 }
 
 }  // namespace stats
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/measure.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/measure.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/measure.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/measure.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/measure_descriptor.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/measure_descriptor.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/measure_descriptor.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/measure_descriptor.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/measure_registry.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/measure_registry.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/measure_registry.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/measure_registry.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/recording.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/recording.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/recording.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/recording.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/stats.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/stats.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/stats.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/stats.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/stats_exporter.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/stats_exporter.h
similarity index 90%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/stats_exporter.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/stats_exporter.h
index 80f8528..6756858 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/stats_exporter.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/stats_exporter.h
@@ -35,6 +35,13 @@ namespace stats {
 // StatsExporter is thread-safe.
 class StatsExporter final {
  public:
+  // Sets the interval between exports. Takes effect after the current export
+  // finishes.
+  //
+  // Warning: this API may be removed in future, in favor of configuring this
+  // per-exporter.
+  static void SetInterval(absl::Duration interval);
+
   // Removes the view with 'name' from the registry, if one is registered.
   static void RemoveView(absl::string_view name);
 
@@ -59,10 +66,12 @@ class StatsExporter final {
   static std::vector<std::pair<ViewDescriptor, ViewData>> GetViewData();
 
  private:
+  StatsExporter() = delete;
   friend class StatsExporterTest;
 
   // Forces immediate export of data.
   static void ExportForTesting();
+
   static void ClearHandlersForTesting();
 };
 
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/tag_key.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/tag_key.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/tag_key.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/tag_key.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/tag_set.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/tag_set.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/tag_set.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/tag_set.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/testing/test_utils.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/testing/test_utils.cc
similarity index 76%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/testing/test_utils.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/testing/test_utils.cc
index e0004e4..4b9c8a9 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/testing/test_utils.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/testing/test_utils.cc
@@ -33,13 +33,28 @@ namespace testing {
 ViewData TestUtils::MakeViewData(
     const ViewDescriptor& descriptor,
     std::initializer_list<std::pair<std::vector<std::string>, double>> values) {
+  std::vector<TestViewValue> view_values;
+  for (const auto& value : values) {
+    TestViewValue view_value;
+    view_value.tag_values = value.first;
+    view_value.value = value.second;
+    view_value.start_time = absl::UnixEpoch();
+    view_values.push_back(view_value);
+  }
+  return TestUtils::MakeViewDataWithStartTimes(descriptor, view_values);
+}
+
+// static
+ViewData TestUtils::MakeViewDataWithStartTimes(
+    const ViewDescriptor& descriptor,
+    const std::vector<TestViewValue>& view_values) {
   auto impl = absl::make_unique<ViewDataImpl>(absl::UnixEpoch(), descriptor);
   std::vector<BucketBoundaries> boundaries = {
       descriptor.aggregation().bucket_boundaries()};
-  for (const auto& value : values) {
+  for (const auto& view_value : view_values) {
     MeasureData measure_data = MeasureData(boundaries);
-    measure_data.Add(value.second);
-    impl->Merge(value.first, measure_data, absl::UnixEpoch());
+    measure_data.Add(view_value.value);
+    impl->Merge(view_value.tag_values, measure_data, view_value.start_time);
   }
   if (impl->type() == ViewDataImpl::Type::kStatsObject) {
     return ViewData(absl::make_unique<ViewDataImpl>(*impl, absl::UnixEpoch()));
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/testing/test_utils.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/testing/test_utils.h
similarity index 78%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/testing/test_utils.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/testing/test_utils.h
index 8a8d47c..01e803b 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/testing/test_utils.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/testing/test_utils.h
@@ -29,13 +29,26 @@ namespace opencensus {
 namespace stats {
 namespace testing {
 
+// Struct to be used as parameters to MakeViewData functions.
+struct TestViewValue {
+  std::vector<std::string> tag_values;
+  double value;
+  absl::Time start_time;
+};
+
 class TestUtils final {
  public:
+  // Makes a ViewData, using absl::UnixEpoch() as the start time.
   static ViewData MakeViewData(
       const ViewDescriptor& descriptor,
       std::initializer_list<std::pair<std::vector<std::string>, double>>
           values);
 
+  // Makes a ViewData, using the specified start times for each timeseries.
+  static ViewData MakeViewDataWithStartTimes(
+      const ViewDescriptor& descriptor,
+      const std::vector<TestViewValue>& view_values);
+
   static Distribution MakeDistribution(const BucketBoundaries* buckets);
 
   static void AddToDistribution(Distribution* distribution, double value);
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/view.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/view.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/view.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/view.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/view_data.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/view_data.h
similarity index 88%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/view_data.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/view_data.h
index 5a620e8..247930b 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/view_data.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/view_data.h
@@ -69,7 +69,15 @@ class ViewData {
   const DataMap<int64_t>& int_data() const;
   const DataMap<Distribution>& distribution_data() const;
 
+  // DEPRECATED: Returns a start time for the view data.
   absl::Time start_time() const;
+
+  // A map from tag values (corresponding to the keys in the ViewDescriptor, in
+  // that order) to the start time for those tags.
+  // The start time stored represents the first time a point was seen with
+  // that combination of tag values.
+  const DataMap<absl::Time>& start_times() const;
+
   absl::Time end_time() const;
 
   ViewData(const ViewData& other);
@@ -80,6 +88,7 @@ class ViewData {
   explicit ViewData(std::unique_ptr<ViewDataImpl> data);
 
   const std::unique_ptr<ViewDataImpl> impl_;
+  const absl::Time end_time_;
 };
 
 }  // namespace stats
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/stats/view_descriptor.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/view_descriptor.h
similarity index 93%
rename from cpp/third_party/opencensus/0.4.0/opencensus/stats/view_descriptor.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/view_descriptor.h
index 58b952b..b3e664a 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/stats/view_descriptor.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/stats/view_descriptor.h
@@ -82,6 +82,11 @@ class ViewDescriptor final {
   ViewDescriptor& set_description(absl::string_view description);
   const std::string& description() const { return description_; }
 
+  // Sets the desired lifetime of the view's data. If the view data is not
+  // updated at any point during this duration, it will be removed from the set
+  // of data recorded by the view when periodic aggregation happens.
+  ViewDescriptor& set_expiry_duration(absl::Duration expiry_duration);
+
   //////////////////////////////////////////////////////////////////////////////
   // View registration
 
@@ -113,6 +118,7 @@ class ViewDescriptor final {
   AggregationWindow aggregation_window_;
   std::vector<opencensus::tags::TagKey> columns_;
   std::string description_;
+  absl::Duration expiry_duration_;
 };
 
 }  // namespace stats
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/BUILD
similarity index 69%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/BUILD
index f385140..8506029 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/tags/BUILD
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/BUILD
@@ -15,6 +15,7 @@
 # limitations under the License.
 
 load("//opencensus:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
+load("//bazel:cc_fuzz_target.bzl", "cc_fuzz_target")
 
 licenses(["notice"])  # Apache License 2.0
 
@@ -34,8 +35,9 @@ cc_library(
     copts = DEFAULT_COPTS,
     visibility = ["//visibility:public"],
     deps = [
-        "//opencensus/common/internal:hash_mix",
         "@com_google_absl//absl/base:core_headers",
+        "@com_google_absl//absl/hash",
+        "@com_google_absl//absl/memory",
         "@com_google_absl//absl/strings",
         "@com_google_absl//absl/synchronization",
     ],
@@ -53,6 +55,19 @@ cc_library(
     ],
 )
 
+cc_library(
+    name = "grpc_tags_bin",
+    srcs = ["internal/grpc_tags_bin.cc"],
+    hdrs = ["propagation/grpc_tags_bin.h"],
+    copts = DEFAULT_COPTS,
+    visibility = ["//visibility:public"],
+    deps = [
+        ":tags",
+        "//opencensus/common/internal:varint",
+        "@com_google_absl//absl/strings",
+    ],
+)
+
 cc_library(
     name = "with_tag_map",
     srcs = ["internal/with_tag_map.cc"],
@@ -81,12 +96,26 @@ cc_test(
     ],
 )
 
+cc_test(
+    name = "grpc_tags_bin_test",
+    srcs = ["internal/grpc_tags_bin_test.cc"],
+    copts = TEST_COPTS,
+    deps = [
+        ":grpc_tags_bin",
+        ":tags",
+        "@com_google_absl//absl/strings",
+        "@com_google_googletest//:gtest_main",
+    ],
+)
+
 cc_test(
     name = "tag_key_test",
     srcs = ["internal/tag_key_test.cc"],
     copts = TEST_COPTS,
     deps = [
         ":tags",
+        "@com_google_absl//absl/hash",
+        "@com_google_absl//absl/strings",
         "@com_google_googletest//:gtest_main",
     ],
 )
@@ -116,6 +145,20 @@ cc_test(
 # Benchmarks
 # ========================================================================= #
 
+cc_binary(
+    name = "grpc_tags_bin_benchmark",
+    testonly = 1,
+    srcs = ["internal/grpc_tags_bin_benchmark.cc"],
+    copts = TEST_COPTS,
+    linkstatic = 1,
+    deps = [
+        ":grpc_tags_bin",
+        ":tags",
+        "@com_github_google_benchmark//:benchmark",
+        "@com_google_absl//absl/strings",
+    ],
+)
+
 cc_binary(
     name = "tag_map_benchmark",
     testonly = 1,
@@ -134,7 +177,6 @@ cc_binary(
     testonly = 1,
     srcs = ["internal/with_tag_map_benchmark.cc"],
     copts = TEST_COPTS,
-    linkopts = ["-pthread"],  # Required for absl/synchronization bits.
     linkstatic = 1,
     deps = [
         ":tags",
@@ -142,3 +184,16 @@ cc_binary(
         "@com_github_google_benchmark//:benchmark",
     ],
 )
+
+# Fuzzers
+# ========================================================================= #
+
+cc_fuzz_target(
+    name = "grpc_tags_bin_fuzzer",
+    srcs = ["internal/grpc_tags_bin_fuzzer.cc"],
+    corpus = glob(["internal/grpc_tags_bin_corpus/*"]),
+    deps = [
+        ":grpc_tags_bin",
+        "@com_google_absl//absl/strings",
+    ],
+)
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/CMakeLists.txt b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/CMakeLists.txt
new file mode 100644
index 0000000..7219a2a
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/CMakeLists.txt
@@ -0,0 +1,77 @@
+# Copyright 2018, OpenCensus Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+opencensus_lib(
+  tags
+  PUBLIC
+  SRCS
+  internal/tag_key.cc
+  internal/tag_map.cc
+  DEPS
+  absl::strings
+  absl::base
+  absl::hash
+  absl::synchronization)
+
+opencensus_lib(
+  tags_context_util
+  PUBLIC
+  SRCS
+  internal/context_util.cc
+  DEPS
+  tags
+  context)
+
+opencensus_lib(
+  tags_grpc_tags_bin
+  PUBLIC
+  SRCS
+  internal/grpc_tags_bin.cc
+  DEPS
+  tags
+  common_varint
+  absl::strings)
+
+opencensus_lib(
+  tags_with_tag_map
+  PUBLIC
+  SRCS
+  internal/with_tag_map.cc
+  DEPS
+  tags
+  context
+  absl::strings)
+
+opencensus_test(tags_context_util_test internal/context_util_test.cc tags
+                tags_context_util tags_with_tag_map context)
+
+opencensus_test(tags_grpc_tags_bin_test internal/grpc_tags_bin_test.cc tags
+                tags_grpc_tags_bin)
+
+opencensus_test(tags_tag_key_test internal/tag_key_test.cc tags)
+
+opencensus_test(tags_tag_map_test internal/tag_map_test.cc tags)
+
+opencensus_test(tags_with_tag_map_test internal/with_tag_map_test.cc tags
+                tags_with_tag_map context)
+
+opencensus_benchmark(
+  tags_grpc_tags_bin_benchmark internal/grpc_tags_bin_benchmark.cc tags
+  tags_grpc_tags_bin absl::strings)
+
+opencensus_benchmark(tags_tag_map_benchmark internal/tag_map_benchmark.cc tags
+                     absl::strings)
+
+opencensus_fuzzer(tags_grpc_tags_bin_fuzzer internal/grpc_tags_bin_fuzzer.cc
+                  tags_grpc_tags_bin absl::strings)
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/README.md b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/README.md
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/README.md
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/README.md
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/context_util.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/context_util.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/context_util.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/context_util.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/context_util.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/context_util.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/context_util.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/context_util.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/context_util_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/context_util_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/context_util_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/context_util_test.cc
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin.cc
new file mode 100644
index 0000000..9bd5359
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin.cc
@@ -0,0 +1,129 @@
+// Copyright 2019, OpenCensus Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "opencensus/tags/propagation/grpc_tags_bin.h"
+
+#include <cstdint>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "absl/strings/string_view.h"
+#include "opencensus/common/internal/varint.h"
+#include "opencensus/tags/tag_key.h"
+#include "opencensus/tags/tag_map.h"
+
+using opencensus::common::AppendVarint32;
+using opencensus::common::ParseVarint32;
+
+namespace opencensus {
+namespace tags {
+namespace propagation {
+namespace {
+
+constexpr char kVersionId = '\0';
+constexpr char kTagFieldId = '\0';
+constexpr int kMaxLen = 8192;
+
+}  // namespace
+
+bool FromGrpcTagsBinHeader(absl::string_view header, TagMap* out) {
+  std::unordered_map<std::string, absl::string_view> keys_vals;
+  if (header.length() < 1) {
+    return false;  // Too short.
+  }
+  if (header.length() > kMaxLen) {
+    return false;  // Too long.
+  }
+  if (header[0] != kVersionId) {
+    return false;  // Wrong version.
+  }
+  header = header.substr(1);
+  while (header.length() > 0) {
+    // Parse tag field id.
+    if (header[0] != kTagFieldId) {
+      return false;  // Wrong field id.
+    }
+    header = header.substr(1);
+
+    // Parse key.
+    absl::string_view key;
+    {
+      uint32_t key_len;
+      if (!ParseVarint32(&header, &key_len)) {
+        return false;  // Invalid key_len.
+      }
+      if (key_len > header.length()) {
+        return false;  // Key len longer than remaining buffer.
+      }
+      key = header.substr(0, key_len);
+      header = header.substr(key_len);
+    }
+
+    // Parse val.
+    absl::string_view val;
+    {
+      uint32_t val_len;
+      if (!ParseVarint32(&header, &val_len)) {
+        return false;  // Invalid val_len.
+      }
+      if (val_len > header.length()) {
+        return false;  // Val len longer than remaining buffer.
+      }
+      val = header.substr(0, val_len);
+      header = header.substr(val_len);
+    }
+
+    // Drop empty keys.
+    if (!key.empty()) {
+      // For duplicate keys, last wins.
+      keys_vals[std::string(key)] = val;
+    }
+  }
+
+  // Convert to tagmap.
+  std::vector<std::pair<opencensus::tags::TagKey, std::string>> tags;
+  tags.reserve(keys_vals.size());
+  for (const auto& kv : keys_vals) {
+    tags.emplace_back(TagKey::Register(kv.first), std::string(kv.second));
+  }
+  *out = TagMap(std::move(tags));
+  return true;
+}
+
+std::string ToGrpcTagsBinHeader(const TagMap& tags) {
+  std::string out;
+  out.push_back(kVersionId);
+  for (const auto& key_val : tags.tags()) {
+    const auto& key = key_val.first;
+    const auto& val = key_val.second;
+    out.push_back(kTagFieldId);
+    AppendVarint32(key.name().length(), &out);
+    out.append(key.name());
+    AppendVarint32(val.length(), &out);
+    // Encoded value must be UTF-8.
+    out.append(val);
+    if (out.size() > kMaxLen) {
+      break;
+    }
+  }
+  if (out.size() > kMaxLen) {
+    return "";
+  }
+  return out;
+}
+
+}  // namespace propagation
+}  // namespace tags
+}  // namespace opencensus
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_map_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_benchmark.cc
similarity index 52%
copy from cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_map_benchmark.cc
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_benchmark.cc
index fcd247f..56f14a5 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_map_benchmark.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_benchmark.cc
@@ -1,4 +1,4 @@
-// Copyright 2018, OpenCensus Authors
+// Copyright 2019, OpenCensus Authors
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -12,36 +12,42 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "opencensus/tags/tag_map.h"
-
-#include <utility>
-#include <vector>
-
-#include "absl/strings/str_cat.h"
+#include "absl/strings/string_view.h"
 #include "benchmark/benchmark.h"
+#include "opencensus/tags/propagation/grpc_tags_bin.h"
 #include "opencensus/tags/tag_key.h"
+#include "opencensus/tags/tag_map.h"
 
 namespace opencensus {
 namespace tags {
+namespace propagation {
 namespace {
 
-void BM_MakeTagMap(benchmark::State& state) {
-  // Create a vector with N tags.
-  const int n = state.range(0);
-  std::vector<std::pair<TagKey, std::string>> tags;
-  tags.reserve(n);
-  for (int i = 0; i < n; ++i) {
-    tags.emplace_back(TagKey::Register(absl::StrCat("key", i)),
-                      absl::StrCat("val", i));
+void BM_FromGrpcTagsBinHeader(benchmark::State& state) {
+  constexpr char tagsbin[] = {
+      0,                 // Version
+      0,                 // Tag field
+      3, 'k', 'e', 'y',  // k1
+      3, 'v', 'a', 'l',  // v1
+  };
+  const absl::string_view hdr(tagsbin, sizeof(tagsbin));
+  TagMap m({});
+  for (auto _ : state) {
+    FromGrpcTagsBinHeader(hdr, &m);
   }
-  // Benchmark TagMap initialization.
+}
+BENCHMARK(BM_FromGrpcTagsBinHeader);
+
+void BM_ToGrpcTagsBinHeader(benchmark::State& state) {
+  TagMap m({{TagKey::Register("key"), "val"}});
   for (auto _ : state) {
-    TagMap tm(tags);
+    ToGrpcTagsBinHeader(m);
   }
 }
-BENCHMARK(BM_MakeTagMap)->RangeMultiplier(2)->Range(1, 32);
+BENCHMARK(BM_ToGrpcTagsBinHeader);
 
 }  // namespace
+}  // namespace propagation
 }  // namespace tags
 }  // namespace opencensus
 
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_corpus/kv b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_corpus/kv
new file mode 100644
index 0000000..85055cc
Binary files /dev/null and b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_corpus/kv differ
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_fuzzer.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_fuzzer.cc
similarity index 61%
copy from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_fuzzer.cc
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_fuzzer.cc
index 942b2d5..c118421 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_fuzzer.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_fuzzer.cc
@@ -13,18 +13,11 @@
 // limitations under the License.
 
 #include "absl/strings/string_view.h"
-#include "opencensus/trace/propagation/trace_context.h"
-#include "opencensus/trace/span_context.h"
-
-using ::opencensus::trace::SpanContext;
-using ::opencensus::trace::propagation::FromTraceParentHeader;
-using ::opencensus::trace::propagation::ToTraceParentHeader;
+#include "opencensus/tags/propagation/grpc_tags_bin.h"
 
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
-  absl::string_view header(reinterpret_cast<const char *>(Data), Size);
-  SpanContext ctx = FromTraceParentHeader(header);
-  if (ctx.IsValid()) {
-    ToTraceParentHeader(ctx);
-  }
+  absl::string_view input(reinterpret_cast<const char *>(Data), Size);
+  opencensus::tags::TagMap m({});
+  opencensus::tags::propagation::FromGrpcTagsBinHeader(input, &m);
   return 0;
 }
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_test.cc
new file mode 100644
index 0000000..7584855
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/grpc_tags_bin_test.cc
@@ -0,0 +1,169 @@
+// Copyright 2019, OpenCensus Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "opencensus/tags/propagation/grpc_tags_bin.h"
+
+#include "absl/strings/str_cat.h"
+#include "absl/strings/string_view.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include "opencensus/tags/tag_key.h"
+#include "opencensus/tags/tag_map.h"
+
+namespace opencensus {
+namespace tags {
+namespace propagation {
+namespace {
+
+TEST(GrpcTagsBinTest, DeserializeEmptyString) {
+  TagMap m({});
+  EXPECT_FALSE(FromGrpcTagsBinHeader("", &m));
+}
+
+TEST(GrpcTagsBinTest, DeserializeEmptyMap) {
+  constexpr char tagsbin[] = {0};  // Just the version byte.
+  TagMap m({});
+  ASSERT_TRUE(
+      FromGrpcTagsBinHeader(absl::string_view(tagsbin, sizeof(tagsbin)), &m));
+  EXPECT_EQ(0, m.tags().size());
+}
+
+TEST(GrpcTagsBinTest, Deserialize) {
+  constexpr char tagsbin[] = {
+      0,                 // Version
+      0,                 // Tag field
+      3, 'k', 'e', 'y',  // k1
+      3, 'v', 'a', 'l',  // v1
+  };
+  TagMap m({});
+  ASSERT_TRUE(
+      FromGrpcTagsBinHeader(absl::string_view(tagsbin, sizeof(tagsbin)), &m));
+  ASSERT_EQ(1, m.tags().size());
+  EXPECT_EQ("key", m.tags()[0].first.name());
+  EXPECT_EQ("val", m.tags()[0].second);
+}
+
+TEST(GrpcTagsBinTest, DeserializeDupeKey) {
+  constexpr char tagsbin[] = {
+      0,                 // Version
+      0,                 // Tag field
+      3, 'k', 'e', 'y',  // k1
+      2, 'v', '1',       // v1
+      0,                 // Tag field
+      3, 'k', 'e', 'y',  // k1
+      2, 'v', '2',       // v2
+  };
+  TagMap m({});
+  ASSERT_TRUE(
+      FromGrpcTagsBinHeader(absl::string_view(tagsbin, sizeof(tagsbin)), &m));
+  ASSERT_EQ(1, m.tags().size());
+  EXPECT_EQ("key", m.tags()[0].first.name());
+  EXPECT_EQ("v2", m.tags()[0].second);
+}
+
+TEST(GrpcTagsBinTest, DeserializeEmptyKey) {
+  constexpr char tagsbin[] = {
+      0,                 // Version
+      0,                 // Tag field
+      3, 'k', 'e', 'y',  // k1
+      2, 'v', '1',       // v1
+      0,                 // Tag field
+      0,                 // k2
+      2, 'v', '2',       // v2
+  };
+  TagMap m({});
+  ASSERT_TRUE(
+      FromGrpcTagsBinHeader(absl::string_view(tagsbin, sizeof(tagsbin)), &m));
+  ASSERT_EQ(1, m.tags().size()) << "Empty key is dropped.";
+  EXPECT_EQ("key", m.tags()[0].first.name());
+  EXPECT_EQ("v1", m.tags()[0].second);
+}
+
+TEST(GrpcTagsBinTest, DeserializeEmptyValue) {
+  constexpr char tagsbin[] = {
+      0,                 // Version
+      0,                 // Tag field
+      3, 'k', 'e', 'y',  // k1
+      0,                 // v1
+  };
+  TagMap m({});
+  ASSERT_TRUE(
+      FromGrpcTagsBinHeader(absl::string_view(tagsbin, sizeof(tagsbin)), &m));
+  ASSERT_EQ(1, m.tags().size());
+  EXPECT_EQ("key", m.tags()[0].first.name());
+  EXPECT_TRUE(m.tags()[0].second.empty());
+}
+
+TEST(GrpcTagsBinTest, DeserializeTooShort) {
+  constexpr char tagsbin[] = {
+      0,  // Version
+      0,  // Tag field
+      3, 'k', 'e',
+  };
+  TagMap m({});
+  EXPECT_FALSE(
+      FromGrpcTagsBinHeader(absl::string_view(tagsbin, sizeof(tagsbin)), &m));
+}
+
+TEST(GrpcTagsBinTest, SerializeEmpty) {
+  TagMap m({});
+  constexpr char expected[] = {0};  // Just the version byte.
+  EXPECT_EQ(absl::string_view(expected, sizeof(expected)),
+            ToGrpcTagsBinHeader(m));
+}
+
+TEST(GrpcTagsBinTest, Serialize) {
+  static const auto k1 = TagKey::Register("k1");
+  static const auto k2 = TagKey::Register("key2");
+  TagMap m({{k1, "v"}, {k2, "val"}});
+  constexpr char expected[] = {
+      0,                      // Version
+      0,                      // Tag field
+      2, 'k', '1',            // k1
+      1, 'v',                 // v1
+      0,                      // Tag field
+      4, 'k', 'e', 'y', '2',  // k2
+      3, 'v', 'a', 'l',       // v2
+  };
+  EXPECT_EQ(absl::string_view(expected, sizeof(expected)),
+            ToGrpcTagsBinHeader(m));
+}
+
+TEST(GrpcTagsBinTest, SerializeLong) {
+  TagMap m1({{TagKey::Register(std::string(300, 'A')), std::string(400, 'B')}});
+  const std::string s = ToGrpcTagsBinHeader(m1);
+  TagMap m2({});
+  EXPECT_TRUE(FromGrpcTagsBinHeader(s, &m2));
+  EXPECT_THAT(m1.tags(), ::testing::ContainerEq(m2.tags()));
+}
+
+TEST(GrpcTagsBinTest, SerializeTooLong) {
+  std::vector<std::pair<opencensus::tags::TagKey, std::string>> tags;
+  constexpr int kValLen = 20;
+  int out_len = 1;
+  int key_n = 0;
+  while (out_len < 8192) {
+    const std::string k = absl::StrCat("key_", key_n++);
+    tags.emplace_back(TagKey::Register(k), std::string(kValLen, 'A'));
+    out_len += 1 + 1 + k.size() + 1 + kValLen;
+  }
+  TagMap m(std::move(tags));
+  EXPECT_EQ("", ToGrpcTagsBinHeader(m))
+      << "Serialization failed due to value being too long.";
+}
+
+}  // namespace
+}  // namespace propagation
+}  // namespace tags
+}  // namespace opencensus
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_key.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/tag_key.cc
similarity index 75%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_key.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/tag_key.cc
index 9d0687d..f2d84d6 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_key.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/tag_key.cc
@@ -15,12 +15,14 @@
 #include "opencensus/tags/tag_key.h"
 
 #include <cstdint>
+#include <memory>
 #include <string>
 #include <unordered_map>
 #include <utility>
 #include <vector>
 
 #include "absl/base/thread_annotations.h"
+#include "absl/memory/memory.h"
 #include "absl/strings/string_view.h"
 #include "absl/synchronization/mutex.h"
 
@@ -34,20 +36,23 @@ class TagKeyRegistry {
     return global_tag_key_registry;
   }
 
-  TagKey Register(absl::string_view name) LOCKS_EXCLUDED(mu_);
+  TagKey Register(absl::string_view name) ABSL_LOCKS_EXCLUDED(mu_);
 
-  const std::string& TagKeyName(TagKey key) const LOCKS_EXCLUDED(mu_) {
+  const std::string& TagKeyName(TagKey key) const ABSL_LOCKS_EXCLUDED(mu_) {
     absl::ReaderMutexLock l(&mu_);
-    return registered_tag_keys_[key.id_];
+    return *registered_tag_keys_[key.id_];
   }
 
  private:
   mutable absl::Mutex mu_;
-  // The registered tag keys. Tag key ids are indices into this vector.
-  std::vector<std::string> registered_tag_keys_ GUARDED_BY(mu_);
+  // The registered tag keys. Tag key ids are indices into this vector.  Strings
+  // are allocated individually so that they don't move around when the vector
+  // storage moves due to resize.
+  std::vector<std::unique_ptr<std::string>> registered_tag_keys_
+      ABSL_GUARDED_BY(mu_);
   // A map from names to IDs.
   // TODO: change to string_view when a suitable hash is available.
-  std::unordered_map<std::string, uint64_t> id_map_ GUARDED_BY(mu_);
+  std::unordered_map<std::string, uint64_t> id_map_ ABSL_GUARDED_BY(mu_);
 };
 
 TagKey TagKeyRegistry::Register(absl::string_view name) {
@@ -56,7 +61,7 @@ TagKey TagKeyRegistry::Register(absl::string_view name) {
   const auto it = id_map_.find(string_name);
   if (it == id_map_.end()) {
     const uint64_t id = registered_tag_keys_.size();
-    registered_tag_keys_.emplace_back(name);
+    registered_tag_keys_.emplace_back(absl::make_unique<std::string>(name));
     id_map_.emplace_hint(it, string_name, id);
     return TagKey(id);
   }
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_key_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/tag_key_test.cc
similarity index 66%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_key_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/tag_key_test.cc
index 2134883..49709a6 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_key_test.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/tag_key_test.cc
@@ -14,6 +14,8 @@
 
 #include "opencensus/tags/tag_key.h"
 
+#include "absl/hash/hash.h"
+#include "absl/strings/str_cat.h"
 #include "gtest/gtest.h"
 
 namespace opencensus {
@@ -29,14 +31,26 @@ TEST(TagKeyTest, DuplicateRegistrationsEqual) {
   TagKey k1 = TagKey::Register("key");
   TagKey k2 = TagKey::Register("key");
   EXPECT_EQ(k1, k2);
-  EXPECT_EQ(k1.hash(), k2.hash());
+  EXPECT_EQ(absl::Hash<TagKey>()(k1), absl::Hash<TagKey>()(k2));
 }
 
 TEST(TagKeyTest, Inequality) {
   TagKey k1 = TagKey::Register("k1");
   TagKey k2 = TagKey::Register("k2");
   EXPECT_NE(k1, k2);
-  EXPECT_NE(k1.hash(), k2.hash());
+  EXPECT_NE(absl::Hash<TagKey>()(k1), absl::Hash<TagKey>()(k2));
+}
+
+// Test that the reference returned by TagKey::name() isn't invalidated when the
+// registry's underlying storage grows and moves.
+TEST(TagKeyTest, GrowRegistry) {
+  TagKey k = TagKey::Register("my_key");
+  const std::string& s = k.name();
+  ASSERT_EQ("my_key", s);
+  for (int i = 0; i < 1000; ++i) {
+    TagKey::Register(absl::StrCat("key_", i));
+    EXPECT_EQ("my_key", s) << "iteration " << i;
+  }
 }
 
 }  // namespace
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_map.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/tag_map.cc
similarity index 90%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_map.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/tag_map.cc
index 93bcc84..d33d9f6 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_map.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/tag_map.cc
@@ -21,10 +21,10 @@
 #include <utility>
 #include <vector>
 
+#include "absl/hash/hash.h"
 #include "absl/strings/str_cat.h"
 #include "absl/strings/str_join.h"
 #include "absl/strings/string_view.h"
-#include "opencensus/common/internal/hash_mix.h"
 #include "opencensus/tags/tag_key.h"
 
 namespace opencensus {
@@ -57,13 +57,7 @@ void TagMap::Initialize() {
          "Duplicate keys are not allowed in TagMap.");
 #endif
 
-  std::hash<std::string> hasher;
-  common::HashMix mixer;
-  for (const auto& tag : tags_) {
-    mixer.Mix(tag.first.hash());
-    mixer.Mix(hasher(tag.second));
-  }
-  hash_ = mixer.get();
+  hash_ = absl::Hash<std::vector<std::pair<TagKey, std::string>>>()(tags_);
 }
 
 std::size_t TagMap::Hash::operator()(const TagMap& tags) const {
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_map_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/tag_map_benchmark.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_map_benchmark.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/tag_map_benchmark.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_map_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/tag_map_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/tag_map_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/tag_map_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/with_tag_map.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/with_tag_map.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/with_tag_map.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/with_tag_map.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/with_tag_map_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/with_tag_map_benchmark.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/with_tag_map_benchmark.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/with_tag_map_benchmark.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/with_tag_map_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/with_tag_map_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/internal/with_tag_map_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/internal/with_tag_map_test.cc
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/propagation/grpc_tags_bin.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/propagation/grpc_tags_bin.h
new file mode 100644
index 0000000..c66c8a6
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/propagation/grpc_tags_bin.h
@@ -0,0 +1,42 @@
+// Copyright 2019, OpenCensus Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef OPENCENSUS_TAGS_PROPAGATION_GRPC_TAGS_BIN_H_
+#define OPENCENSUS_TAGS_PROPAGATION_GRPC_TAGS_BIN_H_
+
+#include <string>
+
+#include "absl/strings/string_view.h"
+#include "opencensus/tags/tag_map.h"
+
+namespace opencensus {
+namespace tags {
+namespace propagation {
+
+// Parses the value of the binary grpc-tags-bin header, populating a
+// TagMap. Returns false if parsing fails.
+//
+// See also:
+// https://github.com/census-instrumentation/opencensus-specs/blob/master/encodings/BinaryEncoding.md
+bool FromGrpcTagsBinHeader(absl::string_view header, TagMap* out);
+
+// Returns a value for the grpc-tags-bin header, or the empty string if
+// serialization failed.
+std::string ToGrpcTagsBinHeader(const TagMap& tags);
+
+}  // namespace propagation
+}  // namespace tags
+}  // namespace opencensus
+
+#endif  // OPENCENSUS_TAGS_PROPAGATION_GRPC_TAGS_BIN_H_
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/tag_key.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/tag_key.h
similarity index 84%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/tag_key.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/tag_key.h
index 2b44297..f939eac 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/tags/tag_key.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/tag_key.h
@@ -19,6 +19,8 @@
 #include <cstdint>
 #include <string>
 
+#include "absl/base/macros.h"
+#include "absl/hash/hash.h"
 #include "absl/strings/string_view.h"
 
 namespace opencensus {
@@ -40,8 +42,16 @@ class TagKey final {
   bool operator<(TagKey other) const { return id_ < other.id_; }
 
   // Returns a suitable hash of the TagKey. The implementation may change.
+  ABSL_DEPRECATED(
+      "Use absl::Hash<TagKey>()(...) instead. "
+      "This method will be removed on or after 2020-02-06")
   std::size_t hash() const { return id_; }
 
+  template <typename H>
+  friend H AbslHashValue(H state, const TagKey& k) {
+    return H::combine(std::move(state), k.id_);
+  }
+
  private:
   friend class TagKeyRegistry;
   explicit TagKey(uint64_t id) : id_(id) {}
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/tag_map.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/tag_map.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/tag_map.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/tag_map.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/tags/with_tag_map.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/with_tag_map.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/tags/with_tag_map.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/tags/with_tag_map.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/BUILD
similarity index 91%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/BUILD
index 1b88863..5215dfc 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/BUILD
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/BUILD
@@ -87,6 +87,23 @@ cc_library(
     ],
 )
 
+cc_library(
+    name = "b3",
+    srcs = [
+        "internal/b3.cc",
+    ],
+    hdrs = [
+        "propagation/b3.h",
+    ],
+    copts = DEFAULT_COPTS,
+    visibility = ["//visibility:public"],
+    deps = [
+        ":span_context",
+        "@com_google_absl//absl/base:endian",
+        "@com_google_absl//absl/strings",
+    ],
+)
+
 cc_library(
     name = "cloud_trace_context",
     srcs = [
@@ -217,6 +234,17 @@ cc_test(
     ],
 )
 
+cc_test(
+    name = "b3_test",
+    srcs = ["internal/b3_test.cc"],
+    copts = TEST_COPTS,
+    deps = [
+        ":b3",
+        ":span_context",
+        "@com_google_googletest//:gtest_main",
+    ],
+)
+
 cc_test(
     name = "cloud_trace_context_test",
     srcs = ["internal/cloud_trace_context_test.cc"],
@@ -427,6 +455,18 @@ cc_binary(
     ],
 )
 
+cc_binary(
+    name = "b3_benchmark",
+    testonly = 1,
+    srcs = ["internal/b3_benchmark.cc"],
+    copts = TEST_COPTS,
+    linkstatic = 1,
+    deps = [
+        ":b3",
+        "@com_github_google_benchmark//:benchmark",
+    ],
+)
+
 cc_binary(
     name = "cloud_trace_context_benchmark",
     testonly = 1,
@@ -451,6 +491,19 @@ cc_binary(
     ],
 )
 
+cc_binary(
+    name = "sampler_benchmark",
+    testonly = 1,
+    srcs = ["internal/sampler_benchmark.cc"],
+    copts = TEST_COPTS,
+    linkstatic = 1,
+    deps = [
+        ":span_context",
+        ":trace",
+        "@com_github_google_benchmark//:benchmark",
+    ],
+)
+
 cc_binary(
     name = "span_benchmark",
     testonly = 1,
@@ -504,6 +557,16 @@ cc_binary(
 # Fuzzers
 # ========================================================================= #
 
+cc_fuzz_target(
+    name = "b3_fuzzer",
+    srcs = ["internal/b3_fuzzer.cc"],
+    corpus = glob(["internal/b3_corpus/*"]),
+    deps = [
+        ":b3",
+        "@com_google_absl//absl/strings",
+    ],
+)
+
 cc_fuzz_target(
     name = "cloud_trace_context_fuzzer",
     srcs = ["internal/cloud_trace_context_fuzzer.cc"],
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/CMakeLists.txt b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/CMakeLists.txt
new file mode 100644
index 0000000..2c4e656
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/CMakeLists.txt
@@ -0,0 +1,229 @@
+# Copyright 2018, OpenCensus Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+opencensus_lib(
+  trace
+  PUBLIC
+  SRCS
+  internal/annotation.cc
+  internal/attribute_list.cc
+  internal/attribute_value.cc
+  internal/attribute_value_ref.cc
+  internal/context_util.cc
+  internal/link.cc
+  internal/local_span_store.cc
+  internal/local_span_store_impl.cc
+  internal/message_event.cc
+  internal/running_span_store.cc
+  internal/running_span_store_impl.cc
+  internal/sampler.cc
+  internal/span.cc
+  internal/span_data.cc
+  internal/span_exporter.cc
+  internal/span_exporter_impl.cc
+  internal/span_impl.cc
+  internal/status.cc
+  internal/trace_config.cc
+  internal/trace_config_impl.cc
+  internal/with_span.cc
+  DEPS
+  common_random
+  trace_cloud_trace_context
+  trace_span_context
+  trace_trace_context
+  absl::strings
+  absl::base
+  absl::memory
+  absl::synchronization
+  absl::time
+  absl::span)
+
+# Define NOMINMAX to fix build errors when compiling with MSVC.
+target_compile_definitions(opencensus_trace
+                           PUBLIC $<$<CXX_COMPILER_ID:MSVC>:NOMINMAX>)
+
+opencensus_lib(
+  trace_b3
+  PUBLIC
+  SRCS
+  internal/b3.cc
+  DEPS
+  trace_span_context
+  absl::base
+  absl::strings)
+
+opencensus_lib(
+  trace_cloud_trace_context
+  PUBLIC
+  SRCS
+  internal/cloud_trace_context.cc
+  DEPS
+  trace_span_context
+  absl::base
+  absl::strings)
+
+opencensus_lib(
+  trace_context_util
+  PUBLIC
+  SRCS
+  internal/context_util.cc
+  DEPS
+  trace
+  context)
+
+opencensus_lib(
+  trace_grpc_trace_bin
+  PUBLIC
+  SRCS
+  internal/grpc_trace_bin.cc
+  DEPS
+  trace_span_context
+  absl::base
+  absl::strings)
+
+opencensus_lib(
+  trace_span_context
+  PUBLIC
+  SRCS
+  internal/span_context.cc
+  internal/span_id.cc
+  internal/trace_id.cc
+  internal/trace_options.cc
+  DEPS
+  absl::strings)
+
+opencensus_lib(
+  trace_trace_context
+  PUBLIC
+  SRCS
+  internal/trace_context.cc
+  DEPS
+  trace_span_context
+  absl::base
+  absl::strings)
+
+opencensus_lib(
+  trace_with_span
+  PUBLIC
+  SRCS
+  internal/with_span.cc
+  DEPS
+  trace
+  context)
+
+# ----------------------------------------------------------------------
+# Tests
+# ----------------------------------------------------------------------
+
+opencensus_test(trace_annotation_test internal/annotation_test.cc trace)
+
+opencensus_test(trace_attribute_value_ref_test
+                internal/attribute_value_ref_test.cc trace)
+
+opencensus_test(trace_attribute_value_test internal/attribute_value_test.cc
+                trace)
+
+opencensus_test(trace_b3_test internal/b3_test.cc trace_b3)
+
+opencensus_test(trace_cloud_trace_context_test
+                internal/cloud_trace_context_test.cc trace_cloud_trace_context)
+
+opencensus_test(trace_context_util_test internal/context_util_test.cc trace
+                trace_context_util trace_with_span context)
+
+opencensus_test(trace_grpc_trace_bin_test internal/grpc_trace_bin_test.cc
+                trace_grpc_trace_bin)
+
+opencensus_test(trace_link_test internal/link_test.cc trace)
+
+opencensus_test(trace_local_span_store_test internal/local_span_store_test.cc
+                trace absl::memory absl::synchronization)
+
+opencensus_test(
+  trace_running_span_store_test internal/running_span_store_test.cc trace
+  absl::base absl::memory absl::synchronization)
+
+opencensus_test(trace_sampler_test internal/sampler_test.cc trace absl::strings
+                absl::synchronization absl::time)
+
+opencensus_test(trace_span_test internal/span_test.cc trace absl::strings)
+
+opencensus_test(trace_span_id_test internal/span_id_test.cc trace)
+
+opencensus_test(trace_span_options_test internal/span_options_test.cc trace
+                absl::strings absl::synchronization)
+
+opencensus_test(trace_span_context_test internal/span_context_test.cc
+                trace_span_context absl::strings absl::span)
+
+opencensus_test(
+  trace_span_exporter_test
+  internal/span_exporter_test.cc
+  trace
+  absl::memory
+  absl::strings
+  absl::synchronization
+  absl::time)
+
+opencensus_test(trace_status_test internal/status_test.cc trace absl::strings)
+
+opencensus_test(trace_trace_config_test internal/trace_config_test.cc trace
+                absl::time)
+
+opencensus_test(trace_trace_options_test internal/trace_options_test.cc trace)
+
+opencensus_test(trace_trace_context_test internal/trace_context_test.cc
+                trace_trace_context)
+
+opencensus_test(trace_with_span_test internal/with_span_test.cc trace
+                trace_with_span context)
+
+opencensus_benchmark(trace_attribute_value_ref_benchmark
+                     internal/attribute_value_ref_benchmark.cc trace)
+
+opencensus_benchmark(trace_b3_benchmark internal/b3_benchmark.cc trace_b3)
+
+opencensus_benchmark(
+  trace_cloud_trace_context_benchmark internal/cloud_trace_context_benchmark.cc
+  trace_cloud_trace_context)
+
+opencensus_benchmark(trace_grpc_trace_bin_benchmark
+                     internal/grpc_trace_bin_benchmark.cc trace_grpc_trace_bin)
+
+opencensus_benchmark(trace_sampler_benchmark internal/sampler_benchmark.cc
+                     trace_span_context trace)
+
+opencensus_benchmark(trace_span_benchmark internal/span_benchmark.cc
+                     trace_span_context trace)
+
+opencensus_benchmark(trace_span_id_benchmark internal/span_id_benchmark.cc
+                     trace_span_context)
+
+opencensus_benchmark(trace_context_benchmark
+                     internal/trace_context_benchmark.cc trace_trace_context)
+
+opencensus_benchmark(trace_with_span_benchmark internal/with_span_benchmark.cc
+                     trace trace_with_span)
+
+opencensus_fuzzer(trace_b3_fuzzer internal/b3_fuzzer.cc trace_b3 absl::strings)
+
+opencensus_fuzzer(
+  trace_cloud_trace_context_fuzzer internal/cloud_trace_context_fuzzer.cc
+  trace_cloud_trace_context absl::strings)
+
+opencensus_fuzzer(trace_grpc_trace_bin_fuzzer internal/grpc_trace_bin_fuzzer.cc
+                  trace_grpc_trace_bin absl::strings)
+
+opencensus_fuzzer(trace_trace_context_fuzzer internal/trace_context_fuzzer.cc
+                  trace_trace_context absl::strings)
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/README.md b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/README.md
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/README.md
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/README.md
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/attribute_value_ref.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/attribute_value_ref.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/attribute_value_ref.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/attribute_value_ref.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/context_util.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/context_util.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/context_util.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/context_util.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/examples/BUILD b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/examples/BUILD
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/examples/BUILD
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/examples/BUILD
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/examples/span_example.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/examples/span_example.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/examples/span_example.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/examples/span_example.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/annotation.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/annotation.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/annotation.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/annotation.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/attribute_value.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/attribute_value.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/attribute_value.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/attribute_value.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/link.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/link.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/link.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/link.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/message_event.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/message_event.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/message_event.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/message_event.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/span_data.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/span_data.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/span_data.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/span_data.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/span_exporter.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/span_exporter.h
similarity index 71%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/span_exporter.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/span_exporter.h
index c0e796c..e515810 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/span_exporter.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/span_exporter.h
@@ -18,6 +18,7 @@
 #include <memory>
 #include <vector>
 
+#include "absl/time/time.h"
 #include "opencensus/trace/exporter/span_data.h"
 
 namespace opencensus {
@@ -27,6 +28,22 @@ namespace exporter {
 // SpanExporter allows Exporters to register. Thread-safe.
 class SpanExporter final {
  public:
+  // Sets the batch size when exporting traces. Takes effect after the next
+  // batch starts. This is not a strict limit, the generated batch may be
+  // slightly larger. If the interval expires before the batch fills up, the
+  // batch will be smaller.
+  //
+  // Warning: this API may be removed in future, in favor of configuring this
+  // per-exporter.
+  static void SetBatchSize(int size);
+
+  // Sets the interval between exporting batches of traces. Takes effect after
+  // the next batch starts.
+  //
+  // Warning: this API may be removed in future, in favor of configuring this
+  // per-exporter.
+  static void SetInterval(absl::Duration interval);
+
   // Handlers allow different tracing services to export recorded data for
   // sampled spans in their own format. Every exporter must provide a static
   // Register() method that takes any arguments needed by the exporter (e.g. a
@@ -41,6 +58,7 @@ class SpanExporter final {
   static void RegisterHandler(std::unique_ptr<Handler> handler);
 
  private:
+  SpanExporter() = delete;
   friend class SpanExporterTestPeer;
 
   // Forces an export, only for testing purposes.
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/status.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/status.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/exporter/status.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/exporter/status.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/annotation.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/annotation.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/annotation.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/annotation.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/annotation_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/annotation_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/annotation_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/annotation_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_list.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_list.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_list.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_list.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_list.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_list.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_list.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_list.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_value.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_value.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_value.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_value.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_value_ref.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_value_ref.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_value_ref.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_value_ref.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_value_ref_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_value_ref_benchmark.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_value_ref_benchmark.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_value_ref_benchmark.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_value_ref_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_value_ref_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_value_ref_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_value_ref_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_value_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_value_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/attribute_value_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/attribute_value_test.cc
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3.cc
new file mode 100644
index 0000000..169774d
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3.cc
@@ -0,0 +1,113 @@
+// Copyright 2019, OpenCensus Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "opencensus/trace/propagation/b3.h"
+
+#include <cstdint>
+#include <cstring>
+#include <string>
+
+#include "absl/strings/ascii.h"
+#include "absl/strings/escaping.h"
+#include "opencensus/trace/span_context.h"
+#include "opencensus/trace/span_id.h"
+#include "opencensus/trace/trace_id.h"
+#include "opencensus/trace/trace_options.h"
+
+namespace opencensus {
+namespace trace {
+namespace propagation {
+
+namespace {
+
+// Returns true if the string only contains valid hex digits.
+bool IsHexDigits(absl::string_view s) {
+  for (int i = 0; i < s.length(); ++i) {
+    if (!absl::ascii_isxdigit(s[i])) return false;
+  }
+  return true;
+}
+
+}  // namespace
+
+SpanContext FromB3Headers(absl::string_view b3_trace_id,
+                          absl::string_view b3_span_id,
+                          absl::string_view b3_sampled,
+                          absl::string_view b3_flags) {
+  static SpanContext invalid;
+  uint8_t sampled;
+
+  if (b3_sampled == "1") {
+    sampled = 1;
+  } else if (b3_sampled == "0" || b3_sampled.empty()) {
+    sampled = 0;
+  } else {
+    return invalid;
+  }
+
+  if (b3_flags == "1") {
+    sampled = 1;
+  } else if (!b3_flags.empty()) {
+    return invalid;
+  }
+
+  if (b3_trace_id.length() != 32 && b3_trace_id.length() != 16) return invalid;
+  if (b3_span_id.length() != 16) return invalid;
+
+  if (!IsHexDigits(b3_trace_id)) {
+    return invalid;
+  }
+  if (!IsHexDigits(b3_span_id)) {
+    return invalid;
+  }
+
+  std::string trace_id_binary = absl::HexStringToBytes(b3_trace_id);
+  std::string span_id_binary = absl::HexStringToBytes(b3_span_id);
+
+  uint8_t extended_trace_id[16];
+
+  // trace_id_ptr must point to a 128-bit trace_id.
+  const uint8_t* trace_id_ptr;
+  if (trace_id_binary.length() == 16) {
+    trace_id_ptr = reinterpret_cast<const uint8_t*>(trace_id_binary.data());
+  } else if (trace_id_binary.length() == 8) {
+    // Extend 64-bit trace_id to 128-bit using the buffer.
+    memset(extended_trace_id, 0, 8);
+    memcpy(extended_trace_id + 8, trace_id_binary.data(), 8);
+    trace_id_ptr = extended_trace_id;
+  } else {
+    return invalid;
+  }
+
+  return SpanContext(
+      TraceId(trace_id_ptr),
+      SpanId(reinterpret_cast<const uint8_t*>(span_id_binary.data())),
+      TraceOptions(&sampled));
+}
+
+std::string ToB3TraceIdHeader(const SpanContext& ctx) {
+  return ctx.trace_id().ToHex();
+}
+
+std::string ToB3SpanIdHeader(const SpanContext& ctx) {
+  return ctx.span_id().ToHex();
+}
+
+std::string ToB3SampledHeader(const SpanContext& ctx) {
+  return ctx.trace_options().IsSampled() ? "1" : "0";
+}
+
+}  // namespace propagation
+}  // namespace trace
+}  // namespace opencensus
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_benchmark.cc
similarity index 54%
copy from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_benchmark.cc
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_benchmark.cc
index 1f99cea..d4b7b6c 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_benchmark.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_benchmark.cc
@@ -1,4 +1,4 @@
-// Copyright 2018, OpenCensus Authors
+// Copyright 2019, OpenCensus Authors
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -12,32 +12,36 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "opencensus/trace/propagation/trace_context.h"
-
 #include "benchmark/benchmark.h"
+#include "opencensus/trace/propagation/b3.h"
 
 namespace opencensus {
 namespace trace {
 namespace propagation {
 namespace {
 
-constexpr char kHeader[] =
-    "00-404142434445464748494a4b4c4d4e4f-6162636465666768-01";
+void BM_FromB3Headers_128bitTraceId(benchmark::State& state) {
+  while (state.KeepRunning()) {
+    FromB3Headers("463ac35c9f6413ad48485a3953bb6124", "0020000000000001", "1",
+                  "");
+  }
+}
+BENCHMARK(BM_FromB3Headers_128bitTraceId);
 
-void BM_FromTraceParentHeader(benchmark::State& state) {
+void BM_FromB3Headers_64bitTraceId(benchmark::State& state) {
   while (state.KeepRunning()) {
-    FromTraceParentHeader(kHeader);
+    FromB3Headers("1234567812345678", "0020000000000001", "1", "");
   }
 }
-BENCHMARK(BM_FromTraceParentHeader);
+BENCHMARK(BM_FromB3Headers_64bitTraceId);
 
-void BM_ToTraceParentHeader(benchmark::State& state) {
-  auto ctx = FromTraceParentHeader(kHeader);
+void BM_FromB3Headers_InvalidTraceId(benchmark::State& state) {
   while (state.KeepRunning()) {
-    ToTraceParentHeader(ctx);
+    FromB3Headers("463ac35c9f6413ad48485a3953bb612X", "0020000000000001", "1",
+                  "");
   }
 }
-BENCHMARK(BM_ToTraceParentHeader);
+BENCHMARK(BM_FromB3Headers_InvalidTraceId);
 
 }  // namespace
 }  // namespace propagation
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_corpus/trace_id_64bit b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_corpus/trace_id_64bit
new file mode 100644
index 0000000..0cab58b
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_corpus/trace_id_64bit
@@ -0,0 +1 @@
+48485a3953bb6124
\ No newline at end of file
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context_fuzzer.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_fuzzer.cc
similarity index 50%
copy from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context_fuzzer.cc
copy to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_fuzzer.cc
index 396f2d7..515dc4f 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context_fuzzer.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_fuzzer.cc
@@ -13,18 +13,21 @@
 // limitations under the License.
 
 #include "absl/strings/string_view.h"
-#include "opencensus/trace/propagation/cloud_trace_context.h"
-#include "opencensus/trace/span_context.h"
+#include "opencensus/trace/propagation/b3.h"
 
-using ::opencensus::trace::SpanContext;
-using ::opencensus::trace::propagation::FromCloudTraceContextHeader;
-using ::opencensus::trace::propagation::ToCloudTraceContextHeader;
+using ::opencensus::trace::propagation::FromB3Headers;
+
+static constexpr char valid_trace_id[] = "463ac35c9f6413ad48485a3953bb612";
+static constexpr char valid_span_id[] = "0020000000000001";
+static constexpr char valid_sampled[] = "1";
+static constexpr char valid_flags[] = "";
 
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
-  absl::string_view header(reinterpret_cast<const char *>(Data), Size);
-  SpanContext ctx = FromCloudTraceContextHeader(header);
-  if (ctx.IsValid()) {
-    ToCloudTraceContextHeader(ctx);
-  }
+  absl::string_view input(reinterpret_cast<const char *>(Data), Size);
+  FromB3Headers(input, input, input, input);
+  FromB3Headers(input, valid_span_id, valid_sampled, valid_flags);
+  FromB3Headers(valid_trace_id, input, valid_sampled, valid_flags);
+  FromB3Headers(valid_trace_id, valid_span_id, input, valid_flags);
+  FromB3Headers(valid_trace_id, valid_span_id, valid_sampled, input);
   return 0;
 }
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_test.cc
new file mode 100644
index 0000000..6c3ae54
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/b3_test.cc
@@ -0,0 +1,118 @@
+// Copyright 2019, OpenCensus Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "opencensus/trace/propagation/b3.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include "opencensus/trace/span_context.h"
+#include "opencensus/trace/span_id.h"
+#include "opencensus/trace/trace_id.h"
+
+namespace opencensus {
+namespace trace {
+namespace propagation {
+namespace {
+
+MATCHER(IsValid, "is a valid SpanContext") { return arg.IsValid(); }
+MATCHER(IsInvalid, "is an invalid SpanContext") { return !arg.IsValid(); }
+
+TEST(B3Test, Trace128Span64Valid) {
+  SpanContext ctx = FromB3Headers("463ac35c9f6413ad48485a3953bb6124",
+                                  "0020000000000001", "1", "");
+  EXPECT_THAT(ctx, IsValid());
+  EXPECT_EQ("463ac35c9f6413ad48485a3953bb6124-0020000000000001-01",
+            ctx.ToString());
+  // Round-trip.
+  EXPECT_EQ("463ac35c9f6413ad48485a3953bb6124", ToB3TraceIdHeader(ctx));
+  EXPECT_EQ("0020000000000001", ToB3SpanIdHeader(ctx));
+  EXPECT_EQ("1", ToB3SampledHeader(ctx));
+}
+
+TEST(B3Test, Trace64Span64Valid) {
+  SpanContext ctx =
+      FromB3Headers("1234567812345678", "0020000000000001", "1", "");
+  EXPECT_THAT(ctx, IsValid());
+  EXPECT_EQ("00000000000000001234567812345678-0020000000000001-01",
+            ctx.ToString());
+  // Round-trip.
+  EXPECT_EQ("00000000000000001234567812345678", ToB3TraceIdHeader(ctx));
+  EXPECT_EQ("0020000000000001", ToB3SpanIdHeader(ctx));
+  EXPECT_EQ("1", ToB3SampledHeader(ctx));
+}
+
+TEST(B3Test, NotSampled) {
+  SpanContext ctx = FromB3Headers("463ac35c9f6413ad48485a3953bb6124",
+                                  "0020000000000001", "0", "");
+  EXPECT_THAT(ctx, IsValid());
+  EXPECT_EQ("463ac35c9f6413ad48485a3953bb6124-0020000000000001-00",
+            ctx.ToString());
+  // Round-trip.
+  EXPECT_EQ("463ac35c9f6413ad48485a3953bb6124", ToB3TraceIdHeader(ctx));
+  EXPECT_EQ("0020000000000001", ToB3SpanIdHeader(ctx));
+  EXPECT_EQ("0", ToB3SampledHeader(ctx));
+}
+
+TEST(B3Test, DebugOverridesNotSampled) {
+  SpanContext ctx = FromB3Headers("463ac35c9f6413ad48485a3953bb6124",
+                                  "0020000000000001", "0", "1");
+  EXPECT_THAT(ctx, IsValid());
+  EXPECT_EQ("463ac35c9f6413ad48485a3953bb6124-0020000000000001-01",
+            ctx.ToString());
+  // Round-trip.
+  EXPECT_EQ("463ac35c9f6413ad48485a3953bb6124", ToB3TraceIdHeader(ctx));
+  EXPECT_EQ("0020000000000001", ToB3SpanIdHeader(ctx));
+  EXPECT_EQ("1", ToB3SampledHeader(ctx));
+}
+
+TEST(B3Test, ExpectedFailures) {
+#define INVALID(a, b, c, d) EXPECT_THAT(FromB3Headers(a, b, c, d), IsInvalid())
+  INVALID("", "", "", "");
+  INVALID("463ac35c9f6413ad48485a3953bb612", "0020000000000001", "1", "")
+      << "trace_id too short for 128-bit";
+  INVALID("463ac35c9f6413ad48485a3953bb61245", "0020000000000001", "1", "")
+      << "trace_id too long for 128-bit";
+  INVALID("463ac35c9f6413ad48485a3953bb612X", "0020000000000001", "1", "")
+      << "trace_id not hex";
+
+  INVALID("48485a3953bb612", "0020000000000001", "1", "")
+      << "trace_id too short for 64-bit";
+  INVALID("48485a3953bb61245", "0020000000000001", "1", "")
+      << "trace_id too long for 64-bit";
+  INVALID("48485a3953bb612X", "0020000000000001", "1", "")
+      << "trace_id not hex";
+
+  INVALID("48485a3953bb6124", "002000000000000", "1", "")
+      << "span_id too short";
+  INVALID("48485a3953bb6124", "00200000000000013", "1", "")
+      << "span_id too long";
+  INVALID("48485a3953bb6124", "002000000000000X", "1", "") << "span_id not hex";
+
+  INVALID("48485a3953bb6124", "0020000000000001", "hello", "")
+      << "sampled set to bad value";
+
+  INVALID("48485a3953bb6124", "0020000000000001", "", "hello")
+      << "flags set to bad value";
+
+  INVALID("00000000000000000000000000000000", "0020000000000001", "1", "")
+      << "zero is an invalid trace_id";
+  INVALID("463ac35c9f6413ad48485a3953bb6124", "0000000000000000", "1", "")
+      << "zero is an invalid span_id";
+#undef INVALID
+}
+
+}  // namespace
+}  // namespace propagation
+}  // namespace trace
+}  // namespace opencensus
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/cloud_trace_context.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/cloud_trace_context.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/cloud_trace_context_benchmark.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context_benchmark.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/cloud_trace_context_benchmark.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context_corpus/span_id_overflow b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/cloud_trace_context_corpus/span_id_overflow
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context_corpus/span_id_overflow
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/cloud_trace_context_corpus/span_id_overflow
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context_corpus/valid b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/cloud_trace_context_corpus/valid
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context_corpus/valid
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/cloud_trace_context_corpus/valid
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context_fuzzer.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/cloud_trace_context_fuzzer.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context_fuzzer.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/cloud_trace_context_fuzzer.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/cloud_trace_context_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/cloud_trace_context_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/cloud_trace_context_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/context_util.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/context_util.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/context_util.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/context_util.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/context_util_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/context_util_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/context_util_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/context_util_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/event_with_time.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/event_with_time.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/event_with_time.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/event_with_time.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/grpc_trace_bin.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/grpc_trace_bin.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/grpc_trace_bin.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/grpc_trace_bin.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/grpc_trace_bin_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/grpc_trace_bin_benchmark.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/grpc_trace_bin_benchmark.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/grpc_trace_bin_benchmark.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/grpc_trace_bin_corpus/valid b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/grpc_trace_bin_corpus/valid
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/grpc_trace_bin_corpus/valid
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/grpc_trace_bin_corpus/valid
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/grpc_trace_bin_fuzzer.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/grpc_trace_bin_fuzzer.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/grpc_trace_bin_fuzzer.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/grpc_trace_bin_fuzzer.cc
index 9cae68e..0565381 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/grpc_trace_bin_fuzzer.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/grpc_trace_bin_fuzzer.cc
@@ -18,8 +18,8 @@
 
 using ::opencensus::trace::SpanContext;
 using ::opencensus::trace::propagation::FromGrpcTraceBinHeader;
-using ::opencensus::trace::propagation::ToGrpcTraceBinHeader;
 using ::opencensus::trace::propagation::kGrpcTraceBinHeaderLen;
+using ::opencensus::trace::propagation::ToGrpcTraceBinHeader;
 
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   absl::string_view header(reinterpret_cast<const char *>(Data), Size);
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/grpc_trace_bin_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/grpc_trace_bin_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/grpc_trace_bin_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/grpc_trace_bin_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/link.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/link.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/link.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/link.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/link_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/link_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/link_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/link_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/local_span_store.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/local_span_store.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/local_span_store.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/local_span_store.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/local_span_store.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/local_span_store.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/local_span_store.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/local_span_store.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/local_span_store_impl.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/local_span_store_impl.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/local_span_store_impl.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/local_span_store_impl.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/local_span_store_impl.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/local_span_store_impl.h
similarity index 82%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/local_span_store_impl.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/local_span_store_impl.h
index cb93b81..e2286f1 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/local_span_store_impl.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/local_span_store_impl.h
@@ -50,19 +50,20 @@ class LocalSpanStoreImpl {
   static LocalSpanStoreImpl* Get();
 
   // Adds a new running Span. Only Span::End should call this.
-  void AddSpan(const std::shared_ptr<SpanImpl>& span) LOCKS_EXCLUDED(mu_);
+  void AddSpan(const std::shared_ptr<SpanImpl>& span) ABSL_LOCKS_EXCLUDED(mu_);
 
   // Returns a summary of the data available in the LocalSpanStore.
-  LocalSpanStore::Summary GetSummary() const LOCKS_EXCLUDED(mu_);
+  LocalSpanStore::Summary GetSummary() const ABSL_LOCKS_EXCLUDED(mu_);
 
   // Returns the running spans that match the filter.
   std::vector<SpanData> GetLatencySampledSpans(
-      const LocalSpanStore::LatencyFilter& filter) const LOCKS_EXCLUDED(mu_);
+      const LocalSpanStore::LatencyFilter& filter) const
+      ABSL_LOCKS_EXCLUDED(mu_);
 
   std::vector<SpanData> GetErrorSampledSpans(
-      const LocalSpanStore::ErrorFilter& filter) const LOCKS_EXCLUDED(mu_);
+      const LocalSpanStore::ErrorFilter& filter) const ABSL_LOCKS_EXCLUDED(mu_);
 
-  std::vector<SpanData> GetSpans() const LOCKS_EXCLUDED(mu_);
+  std::vector<SpanData> GetSpans() const ABSL_LOCKS_EXCLUDED(mu_);
 
  private:
   friend class LocalSpanStoreImplTestPeer;
@@ -71,10 +72,10 @@ class LocalSpanStoreImpl {
   LocalSpanStoreImpl() {}
 
   // Clears all currently active spans from the store.
-  void ClearForTesting() LOCKS_EXCLUDED(mu_);
+  void ClearForTesting() ABSL_LOCKS_EXCLUDED(mu_);
 
   mutable absl::Mutex mu_;
-  std::deque<SpanData> spans_ GUARDED_BY(mu_);
+  std::deque<SpanData> spans_ ABSL_GUARDED_BY(mu_);
 };
 
 }  // namespace exporter
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/local_span_store_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/local_span_store_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/local_span_store_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/local_span_store_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/message_event.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/message_event.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/message_event.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/message_event.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/running_span_store.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/running_span_store.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/running_span_store.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/running_span_store.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/running_span_store.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/running_span_store.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/running_span_store.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/running_span_store.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/running_span_store_impl.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/running_span_store_impl.cc
similarity index 97%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/running_span_store_impl.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/running_span_store_impl.cc
index cdcc7f6..0ec2101 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/running_span_store_impl.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/running_span_store_impl.cc
@@ -67,7 +67,7 @@ RunningSpanStore::Summary RunningSpanStoreImpl::GetSummary() const {
   RunningSpanStore::Summary summary;
   absl::MutexLock l(&mu_);
   for (const auto& addr_span : spans_) {
-    const std::string& name = addr_span.second->name_constref();
+    const std::string name = addr_span.second->name();
     auto it = summary.per_span_name_summary.find(name);
     if (it != summary.per_span_name_summary.end()) {
       it->second.num_running_spans++;
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/running_span_store_impl.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/running_span_store_impl.h
similarity index 84%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/running_span_store_impl.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/running_span_store_impl.h
index 4d8fe2e..99b380e 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/running_span_store_impl.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/running_span_store_impl.h
@@ -38,18 +38,19 @@ class RunningSpanStoreImpl {
   static RunningSpanStoreImpl* Get();
 
   // Adds a new running Span.
-  void AddSpan(const std::shared_ptr<SpanImpl>& span) LOCKS_EXCLUDED(mu_);
+  void AddSpan(const std::shared_ptr<SpanImpl>& span) ABSL_LOCKS_EXCLUDED(mu_);
 
   // Removes a Span that's no longer running. Returns true on success, false if
   // that Span was not being tracked.
-  bool RemoveSpan(const std::shared_ptr<SpanImpl>& span) LOCKS_EXCLUDED(mu_);
+  bool RemoveSpan(const std::shared_ptr<SpanImpl>& span)
+      ABSL_LOCKS_EXCLUDED(mu_);
 
   // Returns a summary of the data available in the RunningSpanStore.
-  RunningSpanStore::Summary GetSummary() const LOCKS_EXCLUDED(mu_);
+  RunningSpanStore::Summary GetSummary() const ABSL_LOCKS_EXCLUDED(mu_);
 
   // Returns the running spans that match the filter.
   std::vector<SpanData> GetRunningSpans(
-      const RunningSpanStore::Filter& filter) const LOCKS_EXCLUDED(mu_);
+      const RunningSpanStore::Filter& filter) const ABSL_LOCKS_EXCLUDED(mu_);
 
  private:
   friend class RunningSpanStoreImplTestPeer;
@@ -57,13 +58,13 @@ class RunningSpanStoreImpl {
   RunningSpanStoreImpl() {}
 
   // Clears all currently active spans from the store.
-  void ClearForTesting() LOCKS_EXCLUDED(mu_);
+  void ClearForTesting() ABSL_LOCKS_EXCLUDED(mu_);
 
   mutable absl::Mutex mu_;
 
   // The key is the memory address of the underlying SpanImpl object.
   std::unordered_map<uintptr_t, std::shared_ptr<SpanImpl>> spans_
-      GUARDED_BY(mu_);
+      ABSL_GUARDED_BY(mu_);
 };
 
 }  // namespace exporter
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/running_span_store_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/running_span_store_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/running_span_store_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/running_span_store_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/sampler.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/sampler.cc
similarity index 93%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/sampler.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/sampler.cc
index 705e00f..d7589dc 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/sampler.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/sampler.cc
@@ -39,10 +39,10 @@ uint64_t CalculateThreshold(double probability) {
 }
 
 uint64_t CalculateThresholdFromBuffer(const TraceId& trace_id) {
-  uint8_t buf[TraceId::kSize];
-  trace_id.CopyTo(buf);
+  const uint8_t* buf = reinterpret_cast<const uint8_t*>(trace_id.Value());
   uint64_t res = 0;
   // We only use the first 8 bytes of TraceId.
+  static_assert(TraceId::kSize >= 8, "TraceID must be at least 8 bytes long.");
   for (int i = 0; i < 8; ++i) {
     res |= (static_cast<uint64_t>(buf[i]) << (i * 8));
   }
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/sampler_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/sampler_benchmark.cc
new file mode 100644
index 0000000..860bea8
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/sampler_benchmark.cc
@@ -0,0 +1,53 @@
+// Copyright 2019, OpenCensus Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <string>
+#include <vector>
+
+#include "benchmark/benchmark.h"
+#include "opencensus/trace/sampler.h"
+#include "opencensus/trace/span.h"
+#include "opencensus/trace/span_context.h"
+#include "opencensus/trace/span_id.h"
+#include "opencensus/trace/trace_id.h"
+
+namespace opencensus {
+namespace trace {
+namespace {
+
+void BM_ProbabilitySampler(benchmark::State& state) {
+  // Unused:
+  SpanContext parent_context;
+  bool has_remote_parent = true;
+  SpanId span_id;
+  std::string name = "MyName";
+  std::vector<Span*> parent_links;
+  // Used:
+  constexpr uint8_t trace_id_buf[TraceId::kSize] = {
+      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
+  TraceId trace_id(trace_id_buf);
+  static ProbabilitySampler sampler(.5);
+
+  while (state.KeepRunning()) {
+    sampler.ShouldSample(&parent_context, has_remote_parent, trace_id, span_id,
+                         name, parent_links);
+  }
+}
+BENCHMARK(BM_ProbabilitySampler);
+
+}  // namespace
+}  // namespace trace
+}  // namespace opencensus
+
+BENCHMARK_MAIN();
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/sampler_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/sampler_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/sampler_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/sampler_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_benchmark.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_benchmark.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_benchmark.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_context.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_context.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_context.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_context.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_context_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_context_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_context_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_context_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_data.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_data.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_data.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_data.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_exporter.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_exporter.cc
similarity index 81%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_exporter.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_exporter.cc
index 7bc3bdb..e2fa6c6 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_exporter.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_exporter.cc
@@ -17,12 +17,23 @@
 #include <memory>
 #include <utility>
 
+#include "absl/time/time.h"
 #include "opencensus/trace/internal/span_exporter_impl.h"
 
 namespace opencensus {
 namespace trace {
 namespace exporter {
 
+// static
+void SpanExporter::SetBatchSize(int size) {
+  SpanExporterImpl::Get()->SetBatchSize(size);
+}
+
+// static
+void SpanExporter::SetInterval(absl::Duration interval) {
+  SpanExporterImpl::Get()->SetInterval(interval);
+}
+
 // static
 void SpanExporter::RegisterHandler(std::unique_ptr<Handler> handler) {
   SpanExporterImpl::Get()->RegisterHandler(std::move(handler));
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_exporter_impl.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_exporter_impl.cc
similarity index 75%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_exporter_impl.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_exporter_impl.cc
index 19ae19f..238eac3 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_exporter_impl.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_exporter_impl.cc
@@ -14,6 +14,7 @@
 
 #include "opencensus/trace/internal/span_exporter_impl.h"
 
+#include <algorithm>
 #include <utility>
 
 #include "absl/synchronization/mutex.h"
@@ -24,17 +25,20 @@ namespace opencensus {
 namespace trace {
 namespace exporter {
 
-SpanExporterImpl* SpanExporterImpl::span_exporter_ = nullptr;
-
 SpanExporterImpl* SpanExporterImpl::Get() {
-  static SpanExporterImpl* global_span_exporter_impl = new SpanExporterImpl(
-      kDefaultBufferSize, absl::Milliseconds(kIntervalWaitTimeInMillis));
+  static SpanExporterImpl* global_span_exporter_impl = new SpanExporterImpl;
   return global_span_exporter_impl;
 }
 
-SpanExporterImpl::SpanExporterImpl(uint32_t buffer_size,
-                                   absl::Duration interval)
-    : buffer_size_(buffer_size), interval_(interval) {}
+void SpanExporterImpl::SetBatchSize(int size) {
+  absl::MutexLock l(&handler_mu_);
+  batch_size_ = std::max(1, size);
+}
+
+void SpanExporterImpl::SetInterval(absl::Duration interval) {
+  absl::MutexLock l(&handler_mu_);
+  interval_ = std::max(absl::Seconds(1), interval);
+}
 
 void SpanExporterImpl::RegisterHandler(
     std::unique_ptr<SpanExporter::Handler> handler) {
@@ -59,36 +63,43 @@ void SpanExporterImpl::StartExportThread() {
   collect_spans_ = true;
 }
 
-bool SpanExporterImpl::IsBufferFull() const {
+bool SpanExporterImpl::IsBatchFull() const {
   span_mu_.AssertHeld();
-  return spans_.size() >= buffer_size_;
+  return spans_.size() >= static_cast<size_t>(cached_batch_size_);
 }
 
 void SpanExporterImpl::RunWorkerLoop() {
-  std::vector<opencensus::trace::exporter::SpanData> span_data_;
-  std::vector<std::shared_ptr<opencensus::trace::SpanImpl>> batch_;
+  std::vector<opencensus::trace::exporter::SpanData> span_data;
+  std::vector<std::shared_ptr<opencensus::trace::SpanImpl>> batch;
   // Thread loops forever.
   // TODO: Add in shutdown mechanism.
-  absl::Time next_forced_export_time = absl::Now() + interval_;
   while (true) {
+    int size;
+    absl::Time next_forced_export_time;
+    {
+      // Start of loop, update batch size and interval.
+      absl::MutexLock l(&handler_mu_);
+      size = batch_size_;
+      next_forced_export_time = absl::Now() + interval_;
+    }
     {
       absl::MutexLock l(&span_mu_);
+      cached_batch_size_ = size;
       // Wait until batch is full or interval time has been exceeded.
       span_mu_.AwaitWithDeadline(
-          absl::Condition(this, &SpanExporterImpl::IsBufferFull),
+          absl::Condition(this, &SpanExporterImpl::IsBatchFull),
           next_forced_export_time);
-      next_forced_export_time = absl::Now() + interval_;
       if (spans_.empty()) {
         continue;
       }
-      std::swap(batch_, spans_);
+      std::swap(batch, spans_);
     }
-    for (const auto& span : batch_) {
-      span_data_.emplace_back(span->ToSpanData());
+    for (const auto& span : batch) {
+      span_data.emplace_back(span->ToSpanData());
     }
-    batch_.clear();
-    Export(span_data_);
-    span_data_.clear();
+    batch.clear();
+    Export(span_data);
+    span_data.clear();
   }
 }
 
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_exporter_impl.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_exporter_impl.h
similarity index 79%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_exporter_impl.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_exporter_impl.h
index 71c0575..d664061 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_exporter_impl.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_exporter_impl.h
@@ -44,6 +44,9 @@ class SpanExporterImpl {
   // Returns the global instance of SpanExporterImpl.
   static SpanExporterImpl* Get();
 
+  void SetBatchSize(int size);
+  void SetInterval(absl::Duration interval);
+
   // A shared_ptr to the span is added to a list. The actual conversion to
   // SpanData will take place at a later time via the background thread. This
   // is intended to be called at the Span::End().
@@ -53,11 +56,8 @@ class SpanExporterImpl {
   // initialization.
   void RegisterHandler(std::unique_ptr<SpanExporter::Handler> handler);
 
-  static constexpr uint32_t kDefaultBufferSize = 64;
-  static constexpr uint32_t kIntervalWaitTimeInMillis = 5000;
-
  private:
-  SpanExporterImpl(uint32_t buffer_size, absl::Duration interval);
+  SpanExporterImpl() = default;
   SpanExporterImpl(const SpanExporterImpl&) = delete;
   SpanExporterImpl(SpanExporterImpl&&) = delete;
   SpanExporterImpl& operator=(const SpanExporterImpl&) = delete;
@@ -65,7 +65,7 @@ class SpanExporterImpl {
   friend class Span;
   friend class SpanExporter;  // For ExportForTesting() only.
 
-  void StartExportThread() EXCLUSIVE_LOCKS_REQUIRED(handler_mu_);
+  void StartExportThread() ABSL_EXCLUSIVE_LOCKS_REQUIRED(handler_mu_);
   void RunWorkerLoop();
 
   // Calls all registered handlers and exports the spans contained in span_data.
@@ -75,22 +75,23 @@ class SpanExporterImpl {
   // returns when complete.
   void ExportForTesting();
 
-  // Returns true if the spans_ buffer has filled up.
-  bool IsBufferFull() const;
+  // Returns true if the spans_ batch is full.
+  bool IsBatchFull() const;
 
-  static SpanExporterImpl* span_exporter_;
-  const uint32_t buffer_size_;
-  const absl::Duration interval_;
   mutable absl::Mutex span_mu_;
   mutable absl::Mutex handler_mu_;
+  int batch_size_ ABSL_GUARDED_BY(handler_mu_) = 64;
+  absl::Duration interval_ ABSL_GUARDED_BY(handler_mu_) = absl::Seconds(5);
+  // Updated in RunWorkerLoop and protected by span_mu_ instead of handler_mu_.
+  int cached_batch_size_ ABSL_GUARDED_BY(span_mu_);
   std::vector<std::shared_ptr<opencensus::trace::SpanImpl>> spans_
-      GUARDED_BY(span_mu_);
+      ABSL_GUARDED_BY(span_mu_);
   std::vector<std::unique_ptr<SpanExporter::Handler>> handlers_
-      GUARDED_BY(handler_mu_);
-  bool thread_started_ GUARDED_BY(handler_mu_) = false;
+      ABSL_GUARDED_BY(handler_mu_);
+  bool thread_started_ ABSL_GUARDED_BY(handler_mu_) = false;
   // Don't collect spans until an exporter has been registered.
-  bool collect_spans_ GUARDED_BY(span_mu_) = false;
-  std::thread t_ GUARDED_BY(handler_mu_);
+  bool collect_spans_ ABSL_GUARDED_BY(span_mu_) = false;
+  std::thread t_ ABSL_GUARDED_BY(handler_mu_);
 };
 
 }  // namespace exporter
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_exporter_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_exporter_test.cc
similarity index 93%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_exporter_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_exporter_test.cc
index d54548e..ea8eeb4 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_exporter_test.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_exporter_test.cc
@@ -17,6 +17,7 @@
 #include "absl/memory/memory.h"
 #include "absl/synchronization/mutex.h"
 #include "absl/time/clock.h"
+#include "absl/time/time.h"
 #include "gtest/gtest.h"
 #include "opencensus/trace/exporter/span_data.h"
 #include "opencensus/trace/sampler.h"
@@ -46,7 +47,7 @@ class Counter {
  private:
   Counter() = default;
   mutable absl::Mutex mu_;
-  int value_ GUARDED_BY(mu_) = 0;
+  int value_ ABSL_GUARDED_BY(mu_) = 0;
 };
 
 class MyExporter : public exporter::SpanExporter::Handler {
@@ -63,6 +64,9 @@ class MyExporter : public exporter::SpanExporter::Handler {
 class SpanExporterTest : public ::testing::Test {
  protected:
   static void SetUpTestSuite() {
+    exporter::SpanExporter::SetBatchSize(1);
+    exporter::SpanExporter::SetInterval(absl::Seconds(1));
+
     // Only register once.
     MyExporter::Register();
   }
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_id.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_id.cc
similarity index 96%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_id.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_id.cc
index 20600e5..f81ee4a 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_id.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_id.cc
@@ -30,6 +30,8 @@ std::string SpanId::ToHex() const {
       absl::string_view(reinterpret_cast<const char *>(rep_), kSize));
 }
 
+const void *SpanId::Value() const { return rep_; }
+
 bool SpanId::operator==(const SpanId &that) const {
   return memcmp(rep_, that.rep_, kSize) == 0;
 }
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_id_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_id_benchmark.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_id_benchmark.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_id_benchmark.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_id_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_id_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_id_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_id_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_impl.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_impl.cc
similarity index 98%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_impl.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_impl.cc
index d32b3c8..66448a3 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_impl.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_impl.cc
@@ -161,6 +161,11 @@ bool SpanImpl::HasEnded() const {
   return has_ended_;
 }
 
+std::string SpanImpl::name() const {
+  absl::MutexLock l(&mu_);
+  return name_;
+}
+
 exporter::SpanData SpanImpl::ToSpanData() const {
   absl::MutexLock l(&mu_);
   // Make a deep copy of attributes.
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_impl.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_impl.h
similarity index 81%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_impl.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_impl.h
index 5ff6249..9be5d53 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_impl.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_impl.h
@@ -71,33 +71,32 @@ class SpanImpl final {
            absl::string_view name, const SpanId& parent_span_id,
            bool remote_parent);
 
-  void AddAttributes(AttributesRef attributes) LOCKS_EXCLUDED(mu_);
+  void AddAttributes(AttributesRef attributes) ABSL_LOCKS_EXCLUDED(mu_);
 
   void AddAnnotation(absl::string_view description, AttributesRef attributes)
-      LOCKS_EXCLUDED(mu_);
+      ABSL_LOCKS_EXCLUDED(mu_);
 
   void AddMessageEvent(exporter::MessageEvent::Type type, uint32_t message_id,
                        uint32_t compressed_message_size,
                        uint32_t uncompressed_message_size);
 
   void AddLink(const SpanContext& context, exporter::Link::Type type,
-               AttributesRef attributes) LOCKS_EXCLUDED(mu_);
+               AttributesRef attributes) ABSL_LOCKS_EXCLUDED(mu_);
 
-  void SetStatus(exporter::Status&& status) LOCKS_EXCLUDED(mu_);
+  void SetStatus(exporter::Status&& status) ABSL_LOCKS_EXCLUDED(mu_);
 
-  void SetName(absl::string_view name) LOCKS_EXCLUDED(mu_);
+  void SetName(absl::string_view name) ABSL_LOCKS_EXCLUDED(mu_);
 
   // Returns true on success (if this is the first time the Span has ended) and
   // also marks the end of the Span and sets its end_time_.
-  bool End() LOCKS_EXCLUDED(mu_);
+  bool End() ABSL_LOCKS_EXCLUDED(mu_);
 
   // Returns true if the span has ended.
-  bool HasEnded() const LOCKS_EXCLUDED(mu_);
+  bool HasEnded() const ABSL_LOCKS_EXCLUDED(mu_);
 
-  absl::string_view name() const { return name_; }
-
-  // Returns the name of the span as a constref string.
-  const std::string& name_constref() const { return name_; }
+  // Returns a copy of the current name of the Span, since SetName can be used
+  // to change it.
+  std::string name() const ABSL_LOCKS_EXCLUDED(mu_);
 
   // Returns the SpanContext associated with this Span.
   SpanContext context() const { return context_; }
@@ -111,33 +110,34 @@ class SpanImpl final {
   friend class ::opencensus::trace::SpanTestPeer;
 
   // Makes a deep copy of span contents and returns copied data in SpanData.
-  exporter::SpanData ToSpanData() const LOCKS_EXCLUDED(mu_);
+  exporter::SpanData ToSpanData() const ABSL_LOCKS_EXCLUDED(mu_);
 
   mutable absl::Mutex mu_;
   // The start time of the span.
   const absl::Time start_time_;
   // The end time of the span. Set when End() is called.
-  absl::Time end_time_ GUARDED_BY(mu_);
+  absl::Time end_time_ ABSL_GUARDED_BY(mu_);
   // The status of the span. Only set if start_options_.record_events is true.
-  exporter::Status status_ GUARDED_BY(mu_);
+  exporter::Status status_ ABSL_GUARDED_BY(mu_);
   // The displayed name of the span.
-  std::string name_ GUARDED_BY(mu_);
+  std::string name_ ABSL_GUARDED_BY(mu_);
   // The parent SpanId of this span. Parent SpanId will be not valid if this is
   // a root span.
   const SpanId parent_span_id_;
   // TraceId, SpanId, and TraceOptions for the current span.
   const SpanContext context_;
   // Queue of recorded annotations.
-  TraceEvents<EventWithTime<exporter::Annotation>> annotations_ GUARDED_BY(mu_);
+  TraceEvents<EventWithTime<exporter::Annotation>> annotations_
+      ABSL_GUARDED_BY(mu_);
   // Queue of recorded network events.
   TraceEvents<EventWithTime<exporter::MessageEvent>> message_events_
-      GUARDED_BY(mu_);
+      ABSL_GUARDED_BY(mu_);
   // Queue of recorded links to parent and child spans.
-  TraceEvents<exporter::Link> links_ GUARDED_BY(mu_);
+  TraceEvents<exporter::Link> links_ ABSL_GUARDED_BY(mu_);
   // Set of recorded attributes.
-  AttributeList attributes_ GUARDED_BY(mu_);
+  AttributeList attributes_ ABSL_GUARDED_BY(mu_);
   // Marks if the span has ended.
-  bool has_ended_ GUARDED_BY(mu_);
+  bool has_ended_ ABSL_GUARDED_BY(mu_);
   // True if the parent Span is in a different process.
   const bool remote_parent_;
 };
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_options_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_options_test.cc
similarity index 98%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_options_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_options_test.cc
index 1cdde89..1efe5d2 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_options_test.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_options_test.cc
@@ -41,7 +41,7 @@ class SpanTestPeer {
     return span->span_impl_for_test()->status_;
   }
 
-  static absl::string_view GetName(Span* span) {
+  static std::string GetName(Span* span) {
     return span->span_impl_for_test()->name();
   }
 
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/span_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/span_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/status.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/status.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/status.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/status.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/status_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/status_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/status_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/status_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_config.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_config.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_config.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_config.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_config_impl.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_config_impl.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_config_impl.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_config_impl.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_config_impl.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_config_impl.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_config_impl.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_config_impl.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_config_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_config_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_config_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_config_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_benchmark.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_benchmark.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_benchmark.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_corpus/bad_options b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_corpus/bad_options
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_corpus/bad_options
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_corpus/bad_options
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_corpus/bad_span_id b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_corpus/bad_span_id
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_corpus/bad_span_id
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_corpus/bad_span_id
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_corpus/bad_trace_id b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_corpus/bad_trace_id
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_corpus/bad_trace_id
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_corpus/bad_trace_id
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_corpus/valid b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_corpus/valid
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_corpus/valid
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_corpus/valid
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_fuzzer.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_fuzzer.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_fuzzer.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_fuzzer.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_context_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_context_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_events.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_events.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_events.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_events.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_id.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_id.cc
similarity index 96%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_id.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_id.cc
index 5beb7da..3c438eb 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_id.cc
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_id.cc
@@ -30,6 +30,8 @@ std::string TraceId::ToHex() const {
       absl::string_view(reinterpret_cast<const char *>(rep_), kSize));
 }
 
+const void *TraceId::Value() const { return rep_; }
+
 bool TraceId::operator==(const TraceId &that) const {
   return memcmp(rep_, that.rep_, kSize) == 0;
 }
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_options.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_options.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_options.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_options.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_options_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_options_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_options_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_options_test.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_params_impl.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_params_impl.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/trace_params_impl.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/trace_params_impl.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/with_span.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/with_span.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/with_span.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/with_span.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/with_span_benchmark.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/with_span_benchmark.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/with_span_benchmark.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/with_span_benchmark.cc
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/with_span_test.cc b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/with_span_test.cc
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/internal/with_span_test.cc
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/internal/with_span_test.cc
diff --git a/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/propagation/b3.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/propagation/b3.h
new file mode 100644
index 0000000..080e89b
--- /dev/null
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/propagation/b3.h
@@ -0,0 +1,68 @@
+// Copyright 2019, OpenCensus Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef OPENCENSUS_TRACE_PROPAGATION_B3_H_
+#define OPENCENSUS_TRACE_PROPAGATION_B3_H_
+
+#include <string>
+
+#include "absl/strings/string_view.h"
+#include "opencensus/trace/span_context.h"
+
+namespace opencensus {
+namespace trace {
+namespace propagation {
+
+// Implementation of the B3 propagation format:
+// https://github.com/openzipkin/b3-propagation
+
+// We handle:
+//   X-B3-TraceId
+//   X-B3-SpanId
+//   X-B3-Sampled
+//   X-B3-Flags
+//
+// But not:
+//   X-B3-ParentSpanId
+//   b3
+
+// Parses the values of the given X-B3 headers, returning a SpanContext. If
+// parsing fails, IsValid will be false.
+//
+// b3_trace_id: 32 or 16 lowercase hex chars.
+// b3_span_id: 16 lowercase hex chars.
+// b3_sampled: "1" or "0" or empty string.
+// b3_flags: "1" or empty string.
+//
+// The X-B3-ParentSpanId header is not used.
+//
+SpanContext FromB3Headers(absl::string_view b3_trace_id,
+                          absl::string_view b3_span_id,
+                          absl::string_view b3_sampled,
+                          absl::string_view b3_flags);
+
+// Returns a value for the X-B3-TraceId header.
+std::string ToB3TraceIdHeader(const SpanContext& ctx);
+
+// Returns a value for the X-B3-SpanId header.
+std::string ToB3SpanIdHeader(const SpanContext& ctx);
+
+// Returns a value for the X-B3-Sampled header.
+std::string ToB3SampledHeader(const SpanContext& ctx);
+
+}  // namespace propagation
+}  // namespace trace
+}  // namespace opencensus
+
+#endif  // OPENCENSUS_TRACE_PROPAGATION_B3_H_
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/propagation/cloud_trace_context.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/propagation/cloud_trace_context.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/propagation/cloud_trace_context.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/propagation/cloud_trace_context.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/propagation/grpc_trace_bin.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/propagation/grpc_trace_bin.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/propagation/grpc_trace_bin.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/propagation/grpc_trace_bin.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/propagation/trace_context.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/propagation/trace_context.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/propagation/trace_context.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/propagation/trace_context.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/sampler.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/sampler.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/sampler.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/sampler.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/span.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/span.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/span.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/span.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/span_context.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/span_context.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/span_context.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/span_context.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/span_id.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/span_id.h
similarity index 95%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/span_id.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/span_id.h
index 8571cd0..b8dbdc0 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/span_id.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/span_id.h
@@ -37,6 +37,9 @@ class SpanId final {
   // Returns a 16-char hex string of the SpanId value.
   std::string ToHex() const;
 
+  // Returns a pointer to the opaque value.
+  const void* Value() const;
+
   bool operator==(const SpanId& that) const;
 
   // Returns false if the SpanId is all zeros.
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/status_code.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/status_code.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/status_code.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/status_code.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/trace_config.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/trace_config.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/trace_config.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/trace_config.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/trace_id.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/trace_id.h
similarity index 95%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/trace_id.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/trace_id.h
index 6626f2a..2dc8f39 100644
--- a/cpp/third_party/opencensus/0.4.0/opencensus/trace/trace_id.h
+++ b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/trace_id.h
@@ -37,6 +37,9 @@ class TraceId final {
   // Returns a 32-char hex string of the TraceId value.
   std::string ToHex() const;
 
+  // Returns a pointer to the opaque value.
+  const void* Value() const;
+
   bool operator==(const TraceId& that) const;
 
   // Returns false if the TraceId is all zeros.
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/trace_options.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/trace_options.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/trace_options.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/trace_options.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/trace_params.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/trace_params.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/trace_params.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/trace_params.h
diff --git a/cpp/third_party/opencensus/0.4.0/opencensus/trace/with_span.h b/cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/with_span.h
similarity index 100%
rename from cpp/third_party/opencensus/0.4.0/opencensus/trace/with_span.h
rename to cpp/third_party/opencensus/0.5.0-alpha/opencensus/trace/with_span.h


[rocketmq-clients] 01/02: WIP

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lizhanhui pushed a commit to branch cpp_cmake
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git

commit 130b0ca32c9f406e3c70036ad100a5ffe873ae80
Author: Li Zhanhui <li...@gmail.com>
AuthorDate: Wed Jul 27 19:55:35 2022 +0800

    WIP
---
 cpp/source/CMakeLists.txt                           |  3 ++-
 cpp/source/rocketmq/AsyncReceiveMessageCallback.cpp |  3 ++-
 cpp/source/rocketmq/CMakeLists.txt                  |  4 ++++
 cpp/source/rocketmq/ClientImpl.cpp                  |  3 ++-
 cpp/source/rocketmq/ConsumeMessageServiceImpl.cpp   |  3 ++-
 cpp/source/rocketmq/ConsumeTask.cpp                 |  3 ++-
 cpp/source/rocketmq/TopicPublishInfo.cpp            |  3 ++-
 cpp/source/rocketmq/include/ProcessQueueImpl.h      |  3 ---
 cpp/source/stats/CMakeLists.txt                     |  3 +--
 cpp/source/trace/CMakeLists.txt                     | 13 +++++++++++++
 10 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/cpp/source/CMakeLists.txt b/cpp/source/CMakeLists.txt
index 6c1b432..e1547e4 100644
--- a/cpp/source/CMakeLists.txt
+++ b/cpp/source/CMakeLists.txt
@@ -5,7 +5,8 @@ add_subdirectory(concurrent)
 add_subdirectory(log)
 add_subdirectory(scheduler)
 add_subdirectory(stats)
-#add_subdirectory(rocketmq)
+add_subdirectory(trace)
+add_subdirectory(rocketmq)
 
 add_library(rocketmq
             $<TARGET_OBJECTS:admin>
diff --git a/cpp/source/rocketmq/AsyncReceiveMessageCallback.cpp b/cpp/source/rocketmq/AsyncReceiveMessageCallback.cpp
index 30cdb7a..1e03802 100644
--- a/cpp/source/rocketmq/AsyncReceiveMessageCallback.cpp
+++ b/cpp/source/rocketmq/AsyncReceiveMessageCallback.cpp
@@ -20,7 +20,8 @@
 
 #include "ClientManagerImpl.h"
 #include "ConsumeMessageType.h"
-#include "LoggerImpl.h"
+#include "rocketmq/Logger.h"
+#include "spdlog/spdlog.h"
 #include "ProcessQueue.h"
 #include "PushConsumerImpl.h"
 
diff --git a/cpp/source/rocketmq/CMakeLists.txt b/cpp/source/rocketmq/CMakeLists.txt
index 52411de..843c6c8 100644
--- a/cpp/source/rocketmq/CMakeLists.txt
+++ b/cpp/source/rocketmq/CMakeLists.txt
@@ -8,11 +8,15 @@ target_link_libraries(impl
         PRIVATE
             api
             absl::strings
+            asio
             base
             fmt
             proto
             client
             opencensus_api
+            opencensus_proto
+            rocketmq_stats
+            rocketmq_trace
             scheduler
             spdlog
         )
\ No newline at end of file
diff --git a/cpp/source/rocketmq/ClientImpl.cpp b/cpp/source/rocketmq/ClientImpl.cpp
index d47133a..0532d73 100644
--- a/cpp/source/rocketmq/ClientImpl.cpp
+++ b/cpp/source/rocketmq/ClientImpl.cpp
@@ -31,7 +31,8 @@
 
 #include "ClientManagerImpl.h"
 #include "InvocationContext.h"
-#include "LoggerImpl.h"
+#include "rocketmq/Logger.h"
+#include "spdlog/spdlog.h"
 #include "MessageExt.h"
 #include "NamingScheme.h"
 #include "SessionImpl.h"
diff --git a/cpp/source/rocketmq/ConsumeMessageServiceImpl.cpp b/cpp/source/rocketmq/ConsumeMessageServiceImpl.cpp
index 722347e..11e14ce 100644
--- a/cpp/source/rocketmq/ConsumeMessageServiceImpl.cpp
+++ b/cpp/source/rocketmq/ConsumeMessageServiceImpl.cpp
@@ -18,7 +18,8 @@
 
 #include "ConsumeStats.h"
 #include "ConsumeTask.h"
-#include "LoggerImpl.h"
+#include "rocketmq/Logger.h"
+#include "spdlog/spdlog.h"
 #include "PushConsumerImpl.h"
 #include "Tag.h"
 #include "ThreadPoolImpl.h"
diff --git a/cpp/source/rocketmq/ConsumeTask.cpp b/cpp/source/rocketmq/ConsumeTask.cpp
index 0c9802d..9e87828 100644
--- a/cpp/source/rocketmq/ConsumeTask.cpp
+++ b/cpp/source/rocketmq/ConsumeTask.cpp
@@ -18,7 +18,8 @@
 #include "ConsumeTask.h"
 
 #include "ConsumeStats.h"
-#include "LoggerImpl.h"
+#include "rocketmq/Logger.h"
+#include "spdlog/spdlog.h"
 #include "PushConsumerImpl.h"
 #include "Tag.h"
 #include "rocketmq/ConsumeResult.h"
diff --git a/cpp/source/rocketmq/TopicPublishInfo.cpp b/cpp/source/rocketmq/TopicPublishInfo.cpp
index 9eac1a2..6eeece4 100644
--- a/cpp/source/rocketmq/TopicPublishInfo.cpp
+++ b/cpp/source/rocketmq/TopicPublishInfo.cpp
@@ -19,7 +19,8 @@
 #include <memory>
 #include <utility>
 
-#include "LoggerImpl.h"
+#include "rocketmq/Logger.h"
+#include "spdlog/spdlog.h"
 #include "MixAll.h"
 #include "ProducerImpl.h"
 #include "TopicRouteData.h"
diff --git a/cpp/source/rocketmq/include/ProcessQueueImpl.h b/cpp/source/rocketmq/include/ProcessQueueImpl.h
index 36464fc..822f7c0 100644
--- a/cpp/source/rocketmq/include/ProcessQueueImpl.h
+++ b/cpp/source/rocketmq/include/ProcessQueueImpl.h
@@ -30,7 +30,6 @@
 #include "TopicAssignmentInfo.h"
 #include "absl/container/flat_hash_map.h"
 #include "absl/container/flat_hash_set.h"
-#include "gtest/gtest_prod.h"
 #include "rocketmq/FilterExpression.h"
 
 ROCKETMQ_NAMESPACE_BEGIN
@@ -133,8 +132,6 @@ private:
                              rmq::ReceiveMessageRequest& request);
 
   void wrapFilterExpression(rmq::FilterExpression* filter_expression);
-
-  FRIEND_TEST(ProcessQueueTest, testExpired);
 };
 
 ROCKETMQ_NAMESPACE_END
\ No newline at end of file
diff --git a/cpp/source/stats/CMakeLists.txt b/cpp/source/stats/CMakeLists.txt
index 47f113e..15622ea 100644
--- a/cpp/source/stats/CMakeLists.txt
+++ b/cpp/source/stats/CMakeLists.txt
@@ -14,5 +14,4 @@ target_link_libraries(rocketmq_stats
             opencensus_proto
             proto
             spdlog
-            scheduler
-        )
\ No newline at end of file
+            scheduler)
\ No newline at end of file
diff --git a/cpp/source/trace/CMakeLists.txt b/cpp/source/trace/CMakeLists.txt
new file mode 100644
index 0000000..caf1a1a
--- /dev/null
+++ b/cpp/source/trace/CMakeLists.txt
@@ -0,0 +1,13 @@
+add_library(rocketmq_trace OBJECT TracingUtility.cpp)
+target_include_directories(rocketmq_trace
+        PUBLIC
+            ${CMAKE_CURRENT_SOURCE_DIR}/include)
+target_link_libraries(rocketmq_trace
+        PRIVATE
+            api
+            base
+            client
+            fmt
+            opencensus::stats
+            proto
+            spdlog)
\ No newline at end of file