-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xray tracer: set subsegment type for child spans #2
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ namespace Tracers { | |
namespace XRay { | ||
|
||
constexpr auto XRayTraceHeader = "x-amzn-trace-id"; | ||
constexpr absl::string_view Subsegment = "subsegment"; | ||
|
||
class Span : public Tracing::Span, Logger::Loggable<Logger::Id::config> { | ||
public: | ||
|
@@ -101,6 +102,12 @@ class Span : public Tracing::Span, Logger::Loggable<Logger::Id::config> { | |
parent_segment_id_ = std::string(parent_segment_id); | ||
} | ||
|
||
/** | ||
* Sets the type of the Span. In Xray, an independent subsegment has a type of ``subsegment``. | ||
* https://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html#api-segmentdocuments-subsegments | ||
*/ | ||
void setType(absl::string_view type) { type_ = std::string(type); } | ||
|
||
/** | ||
* Sets the aws metadata field of the Span. | ||
*/ | ||
|
@@ -156,6 +163,11 @@ class Span : public Tracing::Span, Logger::Loggable<Logger::Id::config> { | |
*/ | ||
const std::string& direction() const { return direction_; } | ||
|
||
/** | ||
* Gets this Span's type. | ||
*/ | ||
const std::string& type() const { return type_; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also considered using a boolean isChild to mark a given span, but this works too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think what you have is more flexible. |
||
|
||
/** | ||
* Gets this Span's name. | ||
*/ | ||
|
@@ -216,6 +228,7 @@ class Span : public Tracing::Span, Logger::Loggable<Logger::Id::config> { | |
std::string parent_segment_id_; | ||
std::string name_; | ||
std::string origin_; | ||
std::string type_; | ||
absl::flat_hash_map<std::string, ProtobufWkt::Value> aws_metadata_; | ||
absl::flat_hash_map<std::string, ProtobufWkt::Value> http_request_annotations_; | ||
absl::flat_hash_map<std::string, ProtobufWkt::Value> http_response_annotations_; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,6 +347,7 @@ TEST_F(XRayTracerTest, ChildSpanHasParentInfo) { | |
// Hex encoded 64 bit identifier | ||
EXPECT_STREQ("00000000000003e7", s.parent_id().c_str()); | ||
EXPECT_EQ(expected_->span_name, s.name().c_str()); | ||
EXPECT_EQ(Subsegment, s.type().c_str()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we update the test to check that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
EXPECT_STREQ(xray_parent_span->traceId().c_str(), s.trace_id().c_str()); | ||
EXPECT_STREQ("0000003d25bebe62", s.id().c_str()); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you change this also to
constexpr absl::string_view
?