Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Change the Stackdriver exporters' Register() to return Status. #240

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,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
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 @@ -271,12 +271,14 @@ void Handler::Export(
} // namespace

// static
void StackdriverExporter::Register(const StackdriverOptions& opts) {
grpc::Status StackdriverExporter::Register(const StackdriverOptions& opts) {
auto channel = ::grpc::CreateCustomChannel(
kGoogleStackdriverTraceAddress, ::grpc::GoogleDefaultCredentials(),
::opencensus::common::WithUserAgent());
::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
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