Skip to content

Commit

Permalink
Change the Stackdriver exporters' Register() to return Status.
Browse files Browse the repository at this point in the history
Make this non-breaking change to the API now, so we can use it
to implement census-instrumentation#175
later.
  • Loading branch information
g-easy committed Nov 23, 2018
1 parent 083fa40 commit 174b5ab
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@ bool Handler::MaybeRegisterView(
} // namespace

// static
void StackdriverExporter::Register(const StackdriverOptions& opts) {
grpc::Status StackdriverExporter::Register(const StackdriverOptions& opts) {
opencensus::stats::StatsExporter::RegisterPushHandler(
absl::WrapUnique(new Handler(opts)));
// TODO: Propagate errors to caller. For now we just return OK.
return grpc::Status::OK;
}

// static, DEPRECATED
Expand Down
6 changes: 4 additions & 2 deletions opencensus/exporters/stats/stackdriver/stackdriver_exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <string>

#include <grpcpp/support/status.h>
#include "absl/base/macros.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
Expand All @@ -42,8 +43,9 @@ struct StackdriverOptions {
// Stackdriver. StackdriverExporter is thread-safe.
class StackdriverExporter {
public:
// Registers the exporter.
static void Register(const StackdriverOptions& opts);
// Registers the exporter and returns OK on success or another Status code
// otherwise.
static grpc::Status Register(const StackdriverOptions& opts);

// TODO: Retire this:
ABSL_DEPRECATED(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,13 @@ void Handler::Export(
} // namespace

// static
void StackdriverExporter::Register(const StackdriverOptions& opts) {
grpc::Status StackdriverExporter::Register(const StackdriverOptions& opts) {
auto creds = grpc::GoogleDefaultCredentials();
auto channel = ::grpc::CreateChannel(kGoogleStackdriverTraceAddress, creds);
::opencensus::trace::exporter::SpanExporter::RegisterHandler(
absl::make_unique<Handler>(opts, channel));
// TODO: Propagate errors to caller. For now we just return OK.
return grpc::Status::OK;
}

// static, DEPRECATED
Expand Down
6 changes: 4 additions & 2 deletions opencensus/exporters/trace/stackdriver/stackdriver_exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <string>

#include <grpcpp/support/status.h>
#include "absl/base/macros.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
Expand All @@ -35,8 +36,9 @@ struct StackdriverOptions {

class StackdriverExporter {
public:
// Registers the exporter.
static void Register(const StackdriverOptions& opts);
// Registers the exporter and returns OK on success or another Status code
// otherwise.
static grpc::Status Register(const StackdriverOptions& opts);

// TODO: Retire this:
ABSL_DEPRECATED(
Expand Down

0 comments on commit 174b5ab

Please sign in to comment.