Пример #1
0
func (c Context) Call(service, method string, in, out appengine_internal.ProtoMessage, opts *appengine_internal.CallOptions) error {
	c.Stats.wg.Add(1)
	defer c.Stats.wg.Done()

	if service == "__go__" {
		return c.Context.Call(service, method, in, out, opts)
	}

	stat := RPCStat{
		Service:   service,
		Method:    method,
		Start:     time.Now(),
		Offset:    time.Since(c.Stats.Start),
		StackData: string(debug.Stack()),
	}
	err := c.Context.Call(service, method, in, out, opts)
	stat.Duration = time.Since(stat.Start)
	stat.In = in.String()
	stat.Out = out.String()
	stat.Cost = GetCost(out)

	if len(stat.In) > ProtoMaxBytes {
		stat.In = stat.In[:ProtoMaxBytes] + "..."
	}
	if len(stat.Out) > ProtoMaxBytes {
		stat.Out = stat.Out[:ProtoMaxBytes] + "..."
	}

	c.Stats.lock.Lock()
	c.Stats.RPCStats = append(c.Stats.RPCStats, stat)
	c.Stats.Cost += stat.Cost
	c.Stats.lock.Unlock()
	return err
}
Пример #2
0
func (c Context) Call(service, method string, in, out appengine_internal.ProtoMessage, opts *appengine_internal.CallOptions) (err error) {
	if c.Timer != nil && service != "__go__" {
		c.StepCustomTiming(service, method, fmt.Sprintf("%v\n\n%v", method, in.String()), func() {
			err = c.Context.Call(service, method, in, out, opts)
		})
	} else {
		err = c.Context.Call(service, method, in, out, opts)
	}
	return
}