Documentation ¶
Overview ¶
Package call helps support tracking latency and other metrics for calls.
Copyright 2022 Outreach Corporation. All Rights Reserved. Description: This file contains the call option definition used by trace.
Index ¶
- type Info
- func (info *Info) AddArgs(ctx context.Context, args ...logf.Marshaler)
- func (info *Info) ApplyOpts(ctx context.Context, args ...logf.Marshaler)
- func (info *Info) End(ctx context.Context)
- func (info *Info) MarshalLog(addField func(key string, value interface{}))
- func (info *Info) ReportLatency(ctx context.Context)
- func (info *Info) SetStatus(ctx context.Context, err error)
- func (info *Info) Start(ctx context.Context, name string)
- type Option
- type Options
- type Tracker
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct { // Name is the name of the call, this is used for the message of the log // and the name of the trace. Name string // Type is the type of the call, see `Type` for more information. Type Type // Opts are the options for this call, see `Options` for more information. Opts Options // Kind is the type of call being made. See metrics.CallKind for more // information. Kind metrics.CallKind // Args are the arguments to the call, this is used for attributes on // logs and traces. Args []logf.Marshaler // ErrInfo is the information for an error that occurred during the call. // This is set by SetStatus and used for reporting that an error occurred. ErrInfo *events.ErrorInfo events.Times events.Durations // contains filtered or unexported fields }
Info tracks information about an ongoing synchronous call.
func (*Info) ApplyOpts ¶ added in v1.31.0
ApplyOpts applies call Option functions to the call Info object. even if args are logf.Marshalers, but there might be some call.Options this is done intentionally to preserve compatibility of StartCall API and extend it with new functionality
func (*Info) MarshalLog ¶
MarshalLog addes log.Marshaler support, logging most of the fields.
func (*Info) ReportLatency ¶
ReportLatency reports the call latency via the metrics package based on the call Kind. If the Kind is not one of HTTP, GRPC or Outbound, it does nothing.
type Option ¶ added in v1.31.0
type Option func(c *Info)
Option defines the call Info adjustment function
func (Option) MarshalLog ¶ added in v1.31.0
MarshalLog is defined for being compliant with trace.StartCall contract
type Options ¶ added in v1.70.0
type Options struct { // DisableInfoLogging turns off per-call info logging if set to true. If false, every successful // (statuscodes.CategoryOK) call will have an Info line emitted. DisableInfoLogging bool }
Options contains options for all tracing calls.
type Tracker ¶
type Tracker struct{}
Tracker helps manage a call info via the context.
func (*Tracker) EndCall ¶
EndCall is meant to be called in a defer abc.EndCall(ctx) pattern. It checks if there is a panic. If so, it uses that to update the current call Info object. It calls info.End(ctx) before returning. It rethrows any panic.
type Type ¶
type Type string
Type tracks the type of call being made.
const ( // TypeHTTP is a constant that denotes the call type being an HTTP // request. TypeHTTP Type = "http" // TypeGRPC is a constant that denotes the call type being a gRPC // request. TypeGRPC Type = "grpc" // TypeOutbound is a constant that denotes the call type being an // outbound request. TypeOutbound Type = "outbound" )
Contains the call type constants.