call

package
v1.41.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2022 License: Apache-2.0, Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

The call package 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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	Name string
	Type Type
	Kind metrics.CallKind
	Args []logf.Marshaler

	events.Times
	events.Durations

	ErrInfo *events.ErrorInfo
}

Info tracks information about an ongoing synchronous call.

func (*Info) AddArgs

func (info *Info) AddArgs(ctx context.Context, args ...logf.Marshaler)

AddArgs appends the provided logf.Marshalers to the Args slice.

func (*Info) ApplyOpts added in v1.31.0

func (info *Info) ApplyOpts(ctx context.Context, args ...logf.Marshaler)

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) End

func (info *Info) End(ctx context.Context)

End records the finished time and updates durations.

func (*Info) MarshalLog

func (info *Info) MarshalLog(addField func(key string, value interface{}))

MarshalLog addes log.Marshaler support, logging most of the fields.

func (*Info) ReportLatency

func (info *Info) ReportLatency(ctx context.Context)

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.

func (*Info) SetStatus

func (info *Info) SetStatus(ctx context.Context, err error)

SetStatus updates the ErrInfo field based on the error.

func (*Info) Start

func (info *Info) Start(ctx context.Context, name string)

Start initializes info with the start time and some name.

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

func (Option) MarshalLog(addField func(string, interface{}))

MarshalLog is defined for being compliant with trace.StartCall contract

type Tracker

type Tracker struct {
}

Tracker helps manage a call info via the context.

func (*Tracker) EndCall

func (t *Tracker) EndCall(ctx context.Context)

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.

func (*Tracker) Info

func (t *Tracker) Info(ctx context.Context) *Info

Info returns the call Info object stashed in the context.

func (*Tracker) StartCall

func (t *Tracker) StartCall(ctx context.Context, name string, args []logf.Marshaler) context.Context

StartCall creates a new call Info object and returns a new context where tracker.Info(ctx) will return the newly setup call Info object.

type Type

type Type string

Type tracks the call type.

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"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL