Categorygithub.com/rollbar/rollbar-go
modulepackage
0.4.2
Repository: https://github.com/rollbar/rollbar-go.git
Documentation: pkg.go.dev

# README

rollbar

rollbar is a Golang Rollbar client that makes it easy to report errors to Rollbar with full stacktraces. Errors are sent to Rollbar asynchronously in a background goroutine.

Because Go's error type doesn't include stack information from when it was set or allocated, we use the stack information from where the error was reported.

Documentation

API docs on godoc.org

Usage

package main

import (
  "github.com/stvp/rollbar"
)

func main() {
  rollbar.SetToken("MY_TOKEN")
  rollbar.SetEnvironment("production")                 // defaults to "development"
  rollbar.SetCodeVersion("v2")                         // optional Git hash/branch/tag (required for GitHub integration)
  rollbar.SetServerHost("web.1")                       // optional override; defaults to hostname
  rollbar.SetServerRoot("github.com/heroku/myproject") // path of project (required for GitHub integration and non-project stacktrace collapsing)

  result, err := DoSomething()
  if err != nil {
    rollbar.Error(rollbar.ERR, err)
  }

  rollbar.Message("info", "Message body goes here")

  rollbar.Wait()
}

Running Tests

Set up a dummy project in Rollbar and pass the access token as an environment variable to go test:

TOKEN=f0df01587b8f76b2c217af34c479f9ea go test

And verify the reported errors manually.

Contributors

A big thank you to everyone who has contributed pull requests and bug reports:

  • @kjk
  • @Soulou
  • @paulmach
  • @fabiokung

# Functions

No description provided by the author
Error asynchronously sends an error to Rollbar with the given severity level.
ErrorWithExtras asynchronously sends an error to Rollbar with the given severity level with extra custom data.
ErrorWithStackSkip asynchronously sends an error to Rollbar with the given severity level and a given number of stack trace frames skipped.
ErrorWithStackSkipWithExtras asynchronously sends an error to Rollbar with the given severity level and a given number of stack trace frames skipped with extra custom data.
String describing the running code version on the server.
custom: Any arbitrary metadata you want to send.
All errors and messages will be submitted under this environment.
host: The server hostname.
root: Path to the application code root, not including the final slash.
Rollbar access token.
Message asynchronously sends a message to Rollbar with the given severity level.
MessageWithExtras asynchronously sends a message to Rollbar with the given severity level with extra custom data.
New returns the default implementation of a Client.
NewAsync builds an asynchronous implementation of the Client interface.
RequestError asynchronously sends an error to Rollbar with the given severity level and request-specific information.
RequestErrorWithExtras asynchronously sends an error to Rollbar with the given severity level and request-specific information with extra custom data.
RequestErrorWithStackSkip asynchronously sends an error to Rollbar with the given severity level and a given number of stack trace frames skipped, in addition to extra request-specific information.
RequestErrorWithStackSkipWithExtras asynchronously sends an error to Rollbar with the given severity level and a given number of stack trace frames skipped, in addition to extra request-specific information and extra custom data.
String describing the running code version on the server.
custom: Any arbitrary metadata you want to send.
All errors and messages will be submitted under this environment.
host: The server hostname.
root: Path to the application code root, not including the final slash.
Rollbar access token.
Wait will block until the queue of errors / messages is empty.

# Constants

Severity levels.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

AsyncClient is the default concrete implementation of the Client interface which sends all data to Rollbar asynchronously.
No description provided by the author

# Interfaces

Errors can implement this interface to create a trace_chain Callers are required to call BuildStack on their own at the time the cause is wrapped.
No description provided by the author

# Type aliases

No description provided by the author