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

x/net/trace: Printing events in a trace #30524

Closed
ghost opened this issue Mar 1, 2019 · 3 comments
Closed

x/net/trace: Printing events in a trace #30524

ghost opened this issue Mar 1, 2019 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@ghost
Copy link

ghost commented Mar 1, 2019

What version of Go are you using (go version)?

$ go version

1.11.4

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

darwin/amd64

go env Output
$ go env

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

What did you do?

I have a service(Service-B) which talks to another service(service-A) via GRPC. The GRPC server(service-A) is coded to return an error on every request. In the client, I have implemented a retry mechanism to retry calls to the server on every error max of 10 times. I am trying to print the logs of how many times the call was retried. I am doing this in my client(service-B).

func (s *server) Sum(ctx context.Context, req *gw.SumRequest) (*gw.SumResponse, error) {
	newTrace := trace.New("service-B", "main")
	newTrace.SetRecycler(func(args interface{}) {
		fmt.Println(args)
	})
	ctx = trace.NewContext(ctx, newTrace)
	defer newTrace.Finish()

	newEventLog := trace.NewEventLog("service-B", "main")
	defer newEventLog.Finish()

	sumResp, err := s.serviceAClient.Sum(
		ctx,
		&pbsa.SumRequest{
			A: req.A,
			B: req.B,
		},
	)
	if err != nil {
		currentTrace, _ := trace.FromContext(ctx)
		currentTrace.SetRecycler(func(args interface{}) {
			fmt.Println(args)
		})
		defer currentTrace.Finish()

		return nil, err
	}
}

What did you expect to see?

Some logs of how many times the calls were retried.

What did you see instead?

No logs. However, when I print the context(ctx) or the trace(currentTrace), I do see the trace in the log. I also saw an Events() method in both the Trace and EventLog files. But it is not in the interface, so I cannot make use of the method. I need some help as to how I can print the trace of the retries.

@bcmills
Copy link
Contributor

bcmills commented Mar 1, 2019

CC @hyangah

@bcmills bcmills added this to the Unreleased milestone Mar 1, 2019
@bcmills bcmills changed the title Printing events in a trace runtime/trace: Printing events in a trace Mar 1, 2019
@bcmills bcmills changed the title runtime/trace: Printing events in a trace x/net/trace: Printing events in a trace Mar 1, 2019
@bcmills
Copy link
Contributor

bcmills commented Mar 1, 2019

CC @mikioh @bradfitz

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 1, 2019
@andybons
Copy link
Member

Hi there,
We have decided that our experiment to allow questions on the issue tracker has not had the outcome we desired, so I am closing this issue. I'm sorry that we can't answer your question here.

There are many other methods to get help if you're still looking for answers:

Thanks

@golang golang locked and limited conversation to collaborators Aug 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants