rollbar

package module
v0.0.0-...-123da3c Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2017 License: BSD-3-Clause Imports: 21 Imported by: 0

README

go-rollbar

CircleCI codecov.io godoc.org Releases GA

Go client for Rollbar.com.

Requirements

  • Go 1.6 or higher

Usage

TODO(zchee): write Usage.

Install

go get -u github.com/zchee/go-rollbar

TODO

  • POST
    • data.trace.***
    • data.trace_chain
    • data.telemetry
  • GET
  • PATCH

License

go-rollbar is released under the BSD 3-Clause License.

Documentation

Overview

Package rollbar implements Rollbar REST API client.

Index

Constants

View Source
const (
	// Name name of client package.
	Name = "go-rollbar"
	// Version version of client package.
	Version = "0.0.0"

	// UserAgent name of go-rollbar package user agent.
	UserAgent = "go-rollbar/" + Version
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call interface {
	Request(*http.Request) Call
	Person(string, string, string) Call
	Custom(map[string]interface{}) Call
	UUID(string) Call
	Title(string) Call
	Do(context.Context) (*api.Response, error)
}

Call respesents a fluent style call options.

type Client

type Client interface {
	Debug(error) Call
	Info(error) Call
	Error(error) Call
	Warn(error) Call
	Critical(error) Call
}

Client represents a first Client methods.

func New

func New(token string, options ...Option) Client

New creates a new REST rollbar API client.

The `token` is required, other optional parameters can be passed using the various `With...` functions.

type CriticalCall

type CriticalCall struct {
	// contains filtered or unexported fields
}

CriticalCall represents a calls the critical level stack trace.

func (*CriticalCall) Custom

func (c *CriticalCall) Custom(custom map[string]interface{}) Call

Custom is any arbitrary metadata you want to send. "custom" itself should be an object.

func (*CriticalCall) Do

func (c *CriticalCall) Do(ctx context.Context) (*api.Response, error)

Do executes the call to access rollbar endpoint.

func (*CriticalCall) Person

func (c *CriticalCall) Person(id, username, email string) Call

Person is the user affected by this event. Will be indexed by ID, username, and email. People are stored in Rollbar keyed by ID. If you send a multiple different usernames/emails for the same ID, the last received values will overwrite earlier ones.

func (*CriticalCall) Request

func (c *CriticalCall) Request(req *http.Request) Call

Request is a data about the request this event occurred in.

func (*CriticalCall) Title

func (c *CriticalCall) Title(title string) Call

Title is an optional text description that is displayed when viewing an item. It must be a string, of length 1-255 characters. You can change the title in this configuration without impacting the fingerprint. The new title will take effect if the item is reactivated after being resolved.

func (*CriticalCall) UUID

func (c *CriticalCall) UUID(id string) Call

UUID a string, up to 36 characters, that uniquely identifies this occurrence. While it can now be any latin1 string, this may change to be a 16 byte field in the future. We recommend using a UUID4 (16 random bytes). The UUID space is unique to each project, and can be used to look up an occurrence later. It is also used to detect duplicate requests. If you send the same UUID in two payloads, the second one will be discarded. While optional, it is recommended that all clients generate and provide this field.

type DebugCall

type DebugCall struct {
	// contains filtered or unexported fields
}

DebugCall represents a calls the debug level stack trace.

func (*DebugCall) Custom

func (c *DebugCall) Custom(custom map[string]interface{}) Call

Custom is any arbitrary metadata you want to send. "custom" itself should be an object.

func (*DebugCall) Do

func (c *DebugCall) Do(ctx context.Context) (*api.Response, error)

Do executes the call to access rollbar endpoint.

func (*DebugCall) Person

func (c *DebugCall) Person(id, username, email string) Call

Person is the user affected by this event. Will be indexed by ID, username, and email. People are stored in Rollbar keyed by ID. If you send a multiple different usernames/emails for the same ID, the last received values will overwrite earlier ones.

func (*DebugCall) Request

func (c *DebugCall) Request(req *http.Request) Call

Request is a data about the request this event occurred in.

func (*DebugCall) Title

func (c *DebugCall) Title(title string) Call

Title is an optional text description that is displayed when viewing an item. It must be a string, of length 1-255 characters. You can change the title in this configuration without impacting the fingerprint. The new title will take effect if the item is reactivated after being resolved.

func (*DebugCall) UUID

func (c *DebugCall) UUID(id string) Call

UUID a string, up to 36 characters, that uniquely identifies this occurrence. While it can now be any latin1 string, this may change to be a 16 byte field in the future. We recommend using a UUID4 (16 random bytes). The UUID space is unique to each project, and can be used to look up an occurrence later. It is also used to detect duplicate requests. If you send the same UUID in two payloads, the second one will be discarded. While optional, it is recommended that all clients generate and provide this field.

type ErrorCall

type ErrorCall struct {
	// contains filtered or unexported fields
}

ErrorCall represents a calls the error level stack trace.

func (*ErrorCall) Custom

func (c *ErrorCall) Custom(custom map[string]interface{}) Call

Custom is any arbitrary metadata you want to send. "custom" itself should be an object.

func (*ErrorCall) Do

func (c *ErrorCall) Do(ctx context.Context) (*api.Response, error)

Do executes the call to access rollbar endpoint.

func (*ErrorCall) Person

func (c *ErrorCall) Person(id, username, email string) Call

Person is the user affected by this event. Will be indexed by ID, username, and email. People are stored in Rollbar keyed by ID. If you send a multiple different usernames/emails for the same ID, the last received values will overwrite earlier ones.

func (*ErrorCall) Request

func (c *ErrorCall) Request(req *http.Request) Call

Request is a data about the request this event occurred in.

func (*ErrorCall) Title

func (c *ErrorCall) Title(title string) Call

Title is an optional text description that is displayed when viewing an item. It must be a string, of length 1-255 characters. You can change the title in this configuration without impacting the fingerprint. The new title will take effect if the item is reactivated after being resolved.

func (*ErrorCall) UUID

func (c *ErrorCall) UUID(id string) Call

UUID a string, up to 36 characters, that uniquely identifies this occurrence. While it can now be any latin1 string, this may change to be a 16 byte field in the future. We recommend using a UUID4 (16 random bytes). The UUID space is unique to each project, and can be used to look up an occurrence later. It is also used to detect duplicate requests. If you send the same UUID in two payloads, the second one will be discarded. While optional, it is recommended that all clients generate and provide this field.

type InfoCall

type InfoCall struct {
	// contains filtered or unexported fields
}

InfoCall represents a calls the info level stack trace.

func (*InfoCall) Custom

func (c *InfoCall) Custom(custom map[string]interface{}) Call

Custom is any arbitrary metadata you want to send. "custom" itself should be an object.

func (*InfoCall) Do

func (c *InfoCall) Do(ctx context.Context) (*api.Response, error)

Do executes the call to access rollbar endpoint.

func (*InfoCall) Person

func (c *InfoCall) Person(id, username, email string) Call

Person is the user affected by this event. Will be indexed by ID, username, and email. People are stored in Rollbar keyed by ID. If you send a multiple different usernames/emails for the same ID, the last received values will overwrite earlier ones.

func (*InfoCall) Request

func (c *InfoCall) Request(req *http.Request) Call

Request is a data about the request this event occurred in.

func (*InfoCall) Title

func (c *InfoCall) Title(title string) Call

Title is an optional text description that is displayed when viewing an item. It must be a string, of length 1-255 characters. You can change the title in this configuration without impacting the fingerprint. The new title will take effect if the item is reactivated after being resolved.

func (*InfoCall) UUID

func (c *InfoCall) UUID(id string) Call

UUID a string, up to 36 characters, that uniquely identifies this occurrence. While it can now be any latin1 string, this may change to be a 16 byte field in the future. We recommend using a UUID4 (16 random bytes). The UUID space is unique to each project, and can be used to look up an occurrence later. It is also used to detect duplicate requests. If you send the same UUID in two payloads, the second one will be discarded. While optional, it is recommended that all clients generate and provide this field.

type Level

type Level string

Level level of stack trace.

const (
	// DebugLevel logs are typically voluminous, and are usually disabled in production.
	DebugLevel Level = "debug"
	// InfoLevel is the default logging priority.
	InfoLevel Level = "info"
	// WarnLevel logs are more important than Info, but don't need individual human review.
	WarnLevel Level = "warning"
	// ErrorLevel logs are high-priority. If an application is running smoothly, it shouldn't generate any error-level logs.
	ErrorLevel Level = "error"
	// CriticalLevel logs are particularly important errors. In development the logger panics after writing the message.
	CriticalLevel Level = "critical"
)

type Logger

type Logger interface {
	Debugf(context.Context, string, ...interface{})
	Infof(context.Context, string, ...interface{})
}

Logger is an interface for logging/tracing the client's execution.

In particular, `Debug` will only be called if `WithDebug` is provided to the constructor.

type Option

type Option func(*httpClient)

Option defines an interface of optional parameters to the `rollbar.New` constructor.

func WithClient

func WithClient(cl *http.Client) Option

WithClient allows you to specify an net/http.Client object to use to communicate with the Rollbar endpoints.

For example, if you need to use this in Google App Engine, you can pass it the result of `urlfetch.Client`.

func WithCodeVersion

func WithCodeVersion(version string) Option

WithCodeVersion is a string, up to 40 characters, describing the version of the application code

Rollbar understands these formats:

  • semantic version (i.e. "2.1.12")
  • integer (i.e. "45")
  • git SHA (i.e. "3da541559918a808c2402bba5012f6c60b27661c")

func WithDebug

func WithDebug(b bool) Option

WithDebug specifies that we want to run in debugging mode. You can set this value manually to override any existing global defaults.

If one is not specified, the default value is false, or the value specified in ROLLBAR_DEBUG environment variable.

func WithEndpoint

func WithEndpoint(s string) Option

WithEndpoint allows you to specify an alternate API endpoint. The default is DefaultEndpoint.

func WithEnvironment

func WithEnvironment(env string) Option

WithEnvironment name of the environment in which this occurrence was seen.

A string up to 255 characters. For best results, use "production" or "prod" for your production environment. You don't need to configure anything in the Rollbar UI for new environment names; we'll detect them automatically.

func WithLogger

func WithLogger(l Logger) Option

WithLogger specifies the logger object to be used. If not specified and `WithDebug` is enabled, then a default logger which writes to os.Stderr.

func WithPlatform

func WithPlatform(platform string) Option

WithPlatform name of platform on which this occurred.

Meaningful platform names:

"browser", "android", "ios", "flash", "client", "heroku", "google-app-engine"

If this is a client-side event, be sure to specify the platform and use a post_client_item access token.

func WithServerBranch

func WithServerBranch(branch string) Option

WithServerBranch name of the checked-out source control branch. Defaults to "master".

func WithServerHost

func WithServerHost(hostname string) Option

WithServerHost is the server hostname. Will be indexed.

func WithServerRoot

func WithServerRoot(root string) Option

WithServerRoot is the path to the application code root. Not including the final slash. Used to collapse non-project code when displaying tracebacks.

func WithStackSkip

func WithStackSkip(skip int) Option

WithStackSkip number of skip error stacks.

type Stack

type Stack []*api.Frame

Stack represents a api.Frame slice.

func CreateStack

func CreateStack(skip int) Stack

CreateStack creates the Stack data except before skip callers.

func CreateStackFromCaller

func CreateStackFromCaller(callers []uintptr) Stack

CreateStackFromCaller creates the Stack data from callers.

func (Stack) Fingerprint

func (s Stack) Fingerprint() string

Fingerprint create a fingerprint that uniqely identify a given message. We use the full callstack, including file names. That ensure that there are no false duplicates but also means that after changing the code (adding/removing lines), the fingerprints will change. It's a trade-off.

type WarnCall

type WarnCall struct {
	// contains filtered or unexported fields
}

WarnCall represents a calls the warning level stack trace.

func (*WarnCall) Custom

func (c *WarnCall) Custom(custom map[string]interface{}) Call

Custom is any arbitrary metadata you want to send. "custom" itself should be an object.

func (*WarnCall) Do

func (c *WarnCall) Do(ctx context.Context) (*api.Response, error)

Do executes the call to access rollbar endpoint.

func (*WarnCall) Person

func (c *WarnCall) Person(id, username, email string) Call

Person is the user affected by this event. Will be indexed by ID, username, and email. People are stored in Rollbar keyed by ID. If you send a multiple different usernames/emails for the same ID, the last received values will overwrite earlier ones.

func (*WarnCall) Request

func (c *WarnCall) Request(req *http.Request) Call

Request is a data about the request this event occurred in.

func (*WarnCall) Title

func (c *WarnCall) Title(title string) Call

Title is an optional text description that is displayed when viewing an item. It must be a string, of length 1-255 characters. You can change the title in this configuration without impacting the fingerprint. The new title will take effect if the item is reactivated after being resolved.

func (*WarnCall) UUID

func (c *WarnCall) UUID(id string) Call

UUID a string, up to 36 characters, that uniquely identifies this occurrence. While it can now be any latin1 string, this may change to be a 16 byte field in the future. We recommend using a UUID4 (16 random bytes). The UUID space is unique to each project, and can be used to look up an occurrence later. It is also used to detect duplicate requests. If you send the same UUID in two payloads, the second one will be discarded. While optional, it is recommended that all clients generate and provide this field.

Directories

Path Synopsis
api
v1
Package v1 implements Rollbar v1 REST API.
Package v1 implements Rollbar v1 REST API.

Jump to

Keyboard shortcuts

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