deferclient

package
v0.0.0-...-2a1e5ed Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2016 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package deferclient implements access to the deferpanic api.

Index

Constants

View Source
const (
	// ApiVersion is the version of this client
	ApiVersion = "v1.17"

	// ApiBase is the base url that client requests goto
	ApiBase = "https://api.deferpanic.com/" + ApiVersion

	// UserAgent is the User Agent that is used with this client
	UserAgent = "deferclient " + ApiVersion
)

Variables

View Source
var (
	// Your deferpanic client token
	// this is being DEPRECATED
	Token string

	// Bool that turns off tracking of errors and panics - useful for
	// dev/test environments
	// this is being DEPRECATED
	NoPost = false
)

being DEPRECATED

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Name       string `json:"Name"`
	Cpucores   int    `json:"Cpucores"`
	Goarch     string `json:"goarch"`
	Goos       string `json:"goos"`
	Totalmem   uint64 `json:"totalmem"`
	Govers     string `json:"govers"`
	ApiVersion string `json:"ApiVersion"`
	CRC32      uint32 `json:"CRC32"`
	Size       int64  `json:"Size"`
}

Agent contains information about this client's agent

func NewAgent

func NewAgent() *Agent

NewAgent instantitates and returns a new agent it is meant to be called once at the start of a new agent checking in (a new process)

func (*Agent) SetName

func (a *Agent) SetName()

SetName sets a 'unique'ish id for this agent

type CPUProfile

type CPUProfile struct {
	Out       []byte `json:"Out,omitempty"`
	Pkg       []byte `json:"Pkg,omitempty"`
	CommandId int    `json:"CommandId"`
	Ignored   bool   `json:"Ignored"`
}

CPUProfile contains information about this client's cpu profile and its producing package

func NewCPUProfile

func NewCPUProfile(out []byte, pkg []byte, commandid int, ignored bool) *CPUProfile

NewCPUProfile instantitates and returns a new cpu profile it is meant to be called once after the completing application cpu profiling

type Command

type Command struct {
	Id        int         `json:"Id"`
	Type      CommandType `json:"Type"`
	Requested bool        `json:"Requested"`
	Executed  bool        `json:"Executed"`
}

Command contains information about this client's command, that has to be executed

func NewCommand

func NewCommand(id int, commandtype CommandType, requested bool, executed bool) *Command

NewCommand instantitates and returns a new command it is meant to be called once before the executing client's command

type CommandType

type CommandType byte

CommandType defines command list supported by the clinet

const (
	// CommandTypeTrace is a command for generating traces
	CommandTypeTrace CommandType = iota + 1
	// CommandTypeBlockProfile is a command for generating block profile
	CommandTypeBlockProfile
	// CommandTypeCPUProfile is a command for generating cpu profile
	CommandTypeCPUProfile
	// CommandTypeMemProfile is a command for generating memory profile
	CommandTypeMemProfile
)

type DeferJSON

type DeferJSON struct {
	Msg       string `json:"ErrorName"`
	BackTrace string `json:"Body"`
	SpanId    int64  `json:"SpanId,omitempty"`
}

DeferJSON is a struct that holds json body for POSTing to deferpanic API

type DeferPanicClient

type DeferPanicClient struct {
	Token       string
	UserAgent   string
	Environment string
	AppGroup    string

	Agent       *Agent
	NoPost      bool
	PrintPanics bool

	HttpClient *http.Client

	RunningCommands map[int]bool
	sync.Mutex
}

DeferPanicClient is the base struct for making requests to the defer panic api

FIXME: move all globals for future api bump

func NewDeferPanicClient

func NewDeferPanicClient(token string) *DeferPanicClient

NewDeferPanicClient instantiates and returns a new deferpanic client

func (*DeferPanicClient) MakeCPUProfile

func (c *DeferPanicClient) MakeCPUProfile(commandId int, agent *Agent)

MakeCPUProfile POST CPUProfile binaries to the deferpanic website

func (*DeferPanicClient) MakeMemProfile

func (c *DeferPanicClient) MakeMemProfile(commandId int, agent *Agent)

MakeMemProfile POST MemProfile binaries to the deferpanic website

func (*DeferPanicClient) MakeTrace

func (c *DeferPanicClient) MakeTrace(commandId int, agent *Agent)

MakeTrace POST Trace binaries to the deferpanic website

func (*DeferPanicClient) Persist

func (c *DeferPanicClient) Persist()

Persist ensures any panics will post to deferpanic website for tracking typically used in non http go-routines

func (*DeferPanicClient) PersistRepanic

func (c *DeferPanicClient) PersistRepanic()

PersistRepanic ensures any panics will post to deferpanic website for tracking, it also reissues the panic afterwards. typically used in non http go-routines

func (*DeferPanicClient) Postit

func (c *DeferPanicClient) Postit(b []byte, url string, analyseResponse bool)

Postit Posts an API request w/b body to url and sets appropriate headers

func (*DeferPanicClient) Prep

func (c *DeferPanicClient) Prep(err interface{}, spanId int64)

Prep takes an error && a spanId it cleans up the error/trace before calling ShipTrace if spanId is zero it is ommited

func (*DeferPanicClient) PrepSync

func (c *DeferPanicClient) PrepSync(err interface{}, spanId int64)

PrepSync takes an error && a spanId it cleans up the error/trace before calling ShipTrace waits for ShipTrace, in a go routine, to complete before continuing if spanId is zero it is ommited

func (*DeferPanicClient) ShipTrace

func (c *DeferPanicClient) ShipTrace(exception string, errorstr string, spanId int64)

ShipTrace POSTs a DeferJSON json body to the deferpanic website if spanId is zero it is ignored

type Mem

type Mem struct {
	Total uint64
}

Mem simply grabs the total memory avail on the system

func (*Mem) SetTotal

func (m *Mem) SetTotal()

SetTotal returns the number of bytes from /proc/meminfo on linux

type MemProfile

type MemProfile struct {
	Out       []byte `json:"Out,omitempty"`
	Pkg       []byte `json:"Pkg,omitempty"`
	CommandId int    `json:"CommandId"`
	Ignored   bool   `json:"Ignored"`
}

MemProfile contains information about this client's memory profile and its producing package

func NewMemProfile

func NewMemProfile(out []byte, pkg []byte, commandid int, ignored bool) *MemProfile

NewMemProfile instantitates and returns a new memory profile it is meant to be called once after the completing application memory profiling

type Response

type Response struct {
	Agent    Agent     `json:"AgentID"`
	Commands []Command `json:"Commands,omitempty"`
}

Response is a struct that holds list of commands to be executed and agent state at server

type Trace

type Trace struct {
	Out       []byte `json:"Out,omitempty"`
	Pkg       []byte `json:"Pkg,omitempty"`
	CommandId int    `json:"CommandId"`
	Ignored   bool   `json:"Ignored"`
}

Trace contains information about this client's trace and its producing package

func NewTrace

func NewTrace(out []byte, pkg []byte, commandid int, ignored bool) *Trace

NewTrace instantitates and returns a new trace it is meant to be called once after the completing application tracing

Jump to

Keyboard shortcuts

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