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

How to combine results of different HandleRPC events? #436

Open
LSTPro opened this issue Apr 13, 2024 · 0 comments
Open

How to combine results of different HandleRPC events? #436

LSTPro opened this issue Apr 13, 2024 · 0 comments

Comments

@LSTPro
Copy link

LSTPro commented Apr 13, 2024

// HandleRPC implements per-RPC tracing and stats instrumentation.
func (c *statsHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
switch rs := rs.(type) {

case *stats.InHeader:

 if rs.Client {
    fmt.Printf(rs.Header)
}

case *stats.End:
  ign := false
  c.lock.RLock()
  ign = c.ignore
  c.lock.RUnlock()

if !ign {
    duration := rs.EndTime.Sub(rs.BeginTime)

    var st string
    s, ok := status.FromError(rs.Error)
    if ok {
        st = s.Code().String()
    }

    c.results <- &callResult{rs.Error, st, duration, rs.EndTime}

    if c.hasLog {
        c.log.Debugw("Received RPC Stats",
            "statsID", c.id, "code", st, "error", rs.Error,
            "duration", duration, "stats", rs)
    }
}
}

}

I have the response metadata coming on event *stats.InHeader and the rest of grpc stats on event *stats.End, I want to combine metadata and grpc stats into one struct object callResult at the end of the grpc call. I am quite not sure how to realize this.

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

1 participant