Skip to content
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

Merged
merged 2 commits into from
Dec 21, 2021
Merged

Conversation

rexnp
Copy link
Owner

@rexnp rexnp commented Dec 15, 2021

Signed-off-by: Rex Chang 58710378+rexnp@users.noreply.github.com

Commit Message: xray tracer: sets the xray segment with type "subsegment" from child spans.
xray doc: https://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html#api-segmentdocuments-subsegments
Additional Description:
Risk Level: low
Testing: unit test, manual setup verifying new xray behavior
Docs Changes: N/A
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue] aws/aws-app-mesh-roadmap#354
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

Here's a piece of the output with this change and using the same howto-ecs-basics walkthrough:
in particular looking at the trace with "name": "howto-ecs-basics/howto-ecs-basics-front-node", which is emitted by Envoy, it now contains a subsegment for the egress call to cds_egress_howto-ecs-basics_howto-ecs-basics-color-node_http_8080. Now, the only thing that remains is the fact that the name of this subsegment is the same as its parent howto-ecs-basics/howto-ecs-basics-front-node. We'll have to confirm what the intended behavior is.

        {
            "Id": "6ea5cd91017e6724",
            "Document": {
                "id": "6ea5cd91017e6724",
                "name": "howto-ecs-basics/howto-ecs-basics-front-node",
                "start_time": 1640120006.301012,
                "trace_id": "1-61c23ec6-3aa5c60827a10c0813945d03",
                "end_time": 1640120006.3039644,
                "parent_id": "cd5a9805b35afdfc",
                "http": {
                    "request": {
                        "url": "http://color.howto-ecs-basics.mesh.local:8080/",
                        "method": "GET",
                        "user_agent": "Go-http-client/1.1",
                        "client_ip": "10.0.88.84",
                        "x_forwarded_for": false
                    },
                    "response": {
                        "status": 200,
                        "content_length": 5
                    }
                },
                "aws": {
                    "app_mesh": {
                        "mesh_name": "howto-ecs-basics",
                        "virtual_node_name": "howto-ecs-basics-front-node"
                    }
                },
                "annotations": {
                    "response_flags": "-",
                    "component": "proxy",
                    "upstream_cluster": "cds_egress_howto-ecs-basics_howto-ecs-basics-color-node_http_8080",
                    "downstream_cluster": "-",
                    "request_size": "0",
                    "node_id": "mesh/howto-ecs-basics/virtualNode/howto-ecs-basics-front-node",
                    "direction": "egress"
                },
                "origin": "AWS::AppMesh::Proxy",
                "subsegments": [
                    {
                        "id": "0d09a9135dfb39a5",
                        "name": "howto-ecs-basics/howto-ecs-basics-front-node",
                        "start_time": 1640120006.3011773,
                        "end_time": 1640120006.303721,
                        "http": {
                            "request": {},
                            "response": {
                                "status": 200
                            }
                        },
                        "aws": {},
                        "annotations": {
                            "response_flags": "-",
                            "component": "proxy",
                            "upstream_cluster": "cds_egress_howto-ecs-basics_howto-ecs-basics-color-node_http_8080",
                            "upstream_address": "10.0.93.193:8080",
                            "direction": "egress"
                        }
                    }
                ]
            }
        }

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>
/**
* Gets this Span's type.
*/
const std::string& type() const { return type_; }
Copy link
Owner Author

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what you have is more flexible.

@@ -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());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update the test to check that type() is not set for a parent span?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

@abaptiste abaptiste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Had one minor suggestion.

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>
@rexnp rexnp requested a review from abaptiste December 20, 2021 20:21
Copy link
Collaborator

@abaptiste abaptiste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rexnp rexnp merged commit ebc816f into main Dec 21, 2021
Copy link

@suniltheta suniltheta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also include a note in docs/root/version_history/current.rst? Probably under Minor Behavior Changes

@@ -26,6 +26,7 @@ namespace Tracers {
namespace XRay {

constexpr auto XRayTraceHeader = "x-amzn-trace-id";

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 ?

@rexnp rexnp mentioned this pull request Feb 21, 2022
rexnp added a commit that referenced this pull request Mar 2, 2022
* xray tracer: set subsegment type for child spans

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

* adds test coverage

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>
rexnp added a commit that referenced this pull request Mar 2, 2022
Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

xray tracer: set subsegment type for child spans (#2)

* xray tracer: set subsegment type for child spans

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

* adds test coverage

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

Xray subsegment (#3)

* xray tracer: set subsegment type for child spans

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

* adds test coverage

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

* updates xray subsegment name to use operation name (instead of parent's span name)

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

* updates doc

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

* updates doc

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

Xray subsegment (#4)

* xray tracer: set subsegment type for child spans

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

* adds test coverage

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

* updates xray subsegment name to use operation name (instead of parent's span name)

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

* updates doc

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

* updates doc

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

* adds to spell check dictionary

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>

fixes spellcheck

Signed-off-by: Rex Chang <58710378+rexnp@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants