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

Commit 98970f7

Browse files
authored
Add OcAgentOptions override for service_name. (#391)
* Don't set service name to Hostname. Other languages' exporters don't do this either.
1 parent fe2f91a commit 98970f7

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

opencensus/exporters/trace/ocagent/internal/ocagent_exporter.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ void Handler::InitNode() {
310310
library_info->set_core_library_version(OPENCENSUS_VERSION);
311311

312312
auto service_info = nodeInfo_.mutable_service_info();
313-
service_info->set_name(::opencensus::common::Hostname());
313+
if (!opts_.service_name.empty()) {
314+
service_info->set_name(opts_.service_name);
315+
}
314316
}
315317

316318
void Handler::ConnectAgent() {

opencensus/exporters/trace/ocagent/ocagent_exporter.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ struct OcAgentOptions {
3333
// The RPC deadline to use when exporting to OcAgent.
3434
absl::Duration rpc_deadline = absl::Seconds(5);
3535

36+
// (optional) If not empty, set the service name to this.
37+
std::string service_name;
38+
3639
// (optional) By default, the exporter connects to OcAgent using address. If
3740
// this stub is non-null, the exporter will use this stub to send
3841
// gRPC calls instead and ignore the address. Useful for testing.

0 commit comments

Comments
 (0)