Skip to content

Commit

Permalink
Fix status mapping in fluentd exporter (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomsonTan authored Oct 25, 2023
1 parent adad337 commit 0930baa
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions exporters/fluentd/src/trace/recordable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ template <typename T> static inline json create_message(T ts, json body) {
}

// constexpr needs keys to be constexpr, const is next best to use.
static const std::map<opentelemetry::trace::SpanKind, std::string>
static const std::map<opentelemetry::trace::SpanKind, int>
kSpanKindMap = {
{opentelemetry::trace::SpanKind::kClient, "CLIENT"},
{opentelemetry::trace::SpanKind::kServer, "SERVER"},
{opentelemetry::trace::SpanKind::kConsumer, "CONSUMER"},
{opentelemetry::trace::SpanKind::kProducer, "PRODUCER"},
{opentelemetry::trace::SpanKind::kInternal, 0},
{opentelemetry::trace::SpanKind::kServer, 1},
{opentelemetry::trace::SpanKind::kClient, 2},
{opentelemetry::trace::SpanKind::kProducer, 3},
{opentelemetry::trace::SpanKind::kConsumer, 4},
};

//
Expand Down Expand Up @@ -91,10 +92,11 @@ void Recordable::AddLink(

void Recordable::SetStatus(opentelemetry::trace::StatusCode code,
nostd::string_view description) noexcept {
options_[FLUENT_FIELD_SUCCESS] = code != opentelemetry::trace::StatusCode::kError;
if (code != opentelemetry::trace::StatusCode::kUnset) {
options_["tags"]["otel.status_code"] = code;
if (code == opentelemetry::trace::StatusCode::kError) {
options_["tags"]["error"] = description;
options_[FLUENT_FIELD_STATUSMESSAGE] = description;
}
}
}
Expand Down

0 comments on commit 0930baa

Please sign in to comment.