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

Commit ad54742

Browse files
authored
Set agent attribute on Spans exported to Stackdriver. (#92)
1 parent 697a5f5 commit ad54742

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

opencensus/exporters/trace/stackdriver/internal/stackdriver_exporter.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ static constexpr char kGoogleStackDriverTraceAddress[] =
3737

3838
namespace {
3939

40+
constexpr char kAgentKey[] = "g.co/agent";
41+
constexpr char kAgentValue[] = "opencensus-cpp";
42+
4043
gpr_timespec ConvertToTimespec(absl::Time time) {
4144
gpr_timespec g_time;
4245
int64_t secs = absl::ToUnixSeconds(time);
@@ -231,6 +234,12 @@ void ConvertSpans(
231234
to_span->mutable_status()->set_code(
232235
static_cast<int32_t>(from_span.status().CanonicalCode()));
233236
to_span->mutable_status()->set_message(from_span.status().error_message());
237+
238+
// Add agent attribute.
239+
SetTruncatableString(
240+
kAgentValue, kAttributeStringLen,
241+
(*to_span->mutable_attributes()->mutable_attribute_map())[kAgentKey]
242+
.mutable_string_value());
234243
}
235244
}
236245

0 commit comments

Comments
 (0)