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

Adding Subsegment.setShouldPropagate(boolean) #346

Open
Kurru opened this issue Jul 28, 2022 · 1 comment
Open

Adding Subsegment.setShouldPropagate(boolean) #346

Kurru opened this issue Jul 28, 2022 · 1 comment

Comments

@Kurru
Copy link
Contributor

Kurru commented Jul 28, 2022

Currently there exists Subsegment.shouldPropagate() which for regular subsegments always returns true and is only false for some use-cases of AWSXrayRecorder.beginSubsegment() (when there is no segment in the thread context).

SubsegmentImpl already returns shouldPropagate() based on a variable, though no-where sets this value to anything other than true.

My use-case is, I have a code path that generates thousands of xray subsegments (calls thousands of RPCs), which in aggregate (including downstream segments), exceeds the AWSXRay trace document size limit. I was looking for a way to suppress downstream x-ray segments in other APIs and this seemed to be named for this use-case.

Alternatively, I've been considering explicitly setting Segment.setSampled(false) to false once a certain number of subsegments are created, and then back to true before the Segment is completed. This would also allow me to stop generating downstream segments from my other apis (as we propagate sampled to our downstream).

Is there another alternative to help me manage segment generation/trace document size during massive fanout like this?

@wangzlei
Copy link
Contributor

wangzlei commented Jul 28, 2022

Control segment size by sampled flag is a good idea. Actually we are thinking about using sampled flag control the size of trace in other XRay feature since XRay trace quota has total size limit 500k bytes.

Alternatively you can use OpenTelemetry sdk instead of XRay sdk. There are several benefits for your requirement:

  1. OpenTelemetry span is independent with each other, spans maintain parent-child relationship by SpanContext, not like XRay SDK segment POJO contains a batch of child subsegments.
  2. OpenTelemetry provides Sampler API, you can implement a custom sampler to control the total size of trace(not span/segment).

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

No branches or pull requests

2 participants