@@ -579,6 +579,12 @@ func (zc *debugZipContext) getCurrentHeapProfile(
579579func (zc * debugZipContext ) getStackInformation (
580580 ctx context.Context , nodePrinter * zipReporter , id string , prefix string ,
581581) error {
582+ // zipCtx.includeStacks controls specifically the inclusion of stacks.txt, as
583+ // the debug=2 collection scheme has a "stop the world" implementation that
584+ // makes it potentially disruptive and thus has an option to skip it. This
585+ // option does _not_ need to skip collection of stack groups (debug=1) or the
586+ // binary goroutine profile (debug=3 or debug=0), as these do not have that
587+ // same stop-the-world disruption.
582588 if zipCtx .includeStacks {
583589 if zipCtx .files .shouldIncludeFile (stacksFileName ) {
584590 var stacksData []byte
@@ -600,32 +606,32 @@ func (zc *debugZipContext) getStackInformation(
600606 } else {
601607 nodePrinter .info ("skipping %s due to file filters" , stacksFileName )
602608 }
609+ } else {
610+ nodePrinter .info ("Skipping fetching goroutine stacks. Enable via the --%s flag." , cliflags .ZipIncludeGoroutineStacks .Name )
611+ }
603612
604- var stacksDataWithLabels []byte
605- if zipCtx .files .shouldIncludeFile (stacksWithLabelFileName ) {
606- s := nodePrinter .start ("requesting stacks with labels" )
607- requestErr := zc .runZipFn (ctx , s ,
608- func (ctx context.Context ) error {
609- stacks , err := zc .status .Stacks (ctx , & serverpb.StacksRequest {
610- NodeId : id ,
611- Type : serverpb .StacksType_GOROUTINE_STACKS_DEBUG_1 ,
612- })
613- if err == nil {
614- stacksDataWithLabels = stacks .Data
615- }
616- return err
613+ var stacksDataWithLabels []byte
614+ if zipCtx .files .shouldIncludeFile (stacksWithLabelFileName ) {
615+ s := nodePrinter .start ("requesting stacks with labels" )
616+ requestErr := zc .runZipFn (ctx , s ,
617+ func (ctx context.Context ) error {
618+ stacks , err := zc .status .Stacks (ctx , & serverpb.StacksRequest {
619+ NodeId : id ,
620+ Type : serverpb .StacksType_GOROUTINE_STACKS_DEBUG_1 ,
617621 })
618- if zipCtx .redact {
619- stacksDataWithLabels = redactStackTrace (stacksDataWithLabels )
620- }
621- if err := zc .z .createRawOrError (s , prefix + "/" + stacksWithLabelFileName , stacksDataWithLabels , requestErr ); err != nil {
622+ if err == nil {
623+ stacksDataWithLabels = stacks .Data
624+ }
622625 return err
623- }
624- } else {
625- nodePrinter .info ("skipping %s due to file filters" , stacksWithLabelFileName )
626+ })
627+ if zipCtx .redact {
628+ stacksDataWithLabels = redactStackTrace (stacksDataWithLabels )
629+ }
630+ if err := zc .z .createRawOrError (s , prefix + "/" + stacksWithLabelFileName , stacksDataWithLabels , requestErr ); err != nil {
631+ return err
626632 }
627633 } else {
628- nodePrinter .info ("Skipping fetching goroutine stacks. Enable via the --%s flag. " , cliflags . ZipIncludeGoroutineStacks . Name )
634+ nodePrinter .info ("skipping %s due to file filters " , stacksWithLabelFileName )
629635 }
630636 return nil
631637}
0 commit comments