Documentation ¶
Overview ¶
Package hosted implements event collection for hosted third-party services. Collectors are provided for Honeybadger, Loggly, Opbeat, Rollbar, and Sentry. Additional collectors will be added upon request.
Inclusion Criteria ¶
The following criteria are used to evaluate third-party services:
1. Does the service provide a perpetual free tier? This is a must-have requirement.
2. Does the service offer transport security? This is a must-have requirement.
3. Is the service a good fit for collecting cue events? Logging and error reporting services are a great fit. E-mail and messaging services, on the other hand, are intentionally omitted.
4. Does the service provide a sane API/integration mechanism? Firing JSON HTTP posts is simple, whereas implementing proprietary transport mechanisms is a pain.
If a third-party service meets the above criteria and isn't supported, feel free to open a feature request.
Frame Collection ¶
By default, cue collects a single stack frame for all logged events. Increasing the number of frames collected for ERROR and FATAL events is a good idea when using error reporting services. See the cue.SetFrames docs for details.
Nil Instances ¶
Collector implementations emit a WARN log event and return a nil collector instance if required parameters are missing. The cue.Collect and cue.CollectAsync functions treat nil collectors as a no-op, so this is perfectly safe.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Honeybadger ¶
type Honeybadger struct { // Required Key string // Honeybadger API key // Optional Tags []string // Tags to send with every event ExtraContext cue.Context // Additional context values to send with every event Environment string // Environment name ("development", "production", etc.) }
Honeybadger represents configuration for the Honeybadger service. Collected events are sent to Honeybadger as new error occurrences, complete with relevant stack trace. Honeybadger only supports error/fatal events, so collectors for the service should only be registered at the ERROR or FATAL log levels.
func (Honeybadger) New ¶
func (h Honeybadger) New() cue.Collector
New returns a new collector based on the Honeybadger configuration.
type Loggly ¶
type Loggly struct { // Required Token string // Loggly auth token. Omit the trailing @41058 from this value. App string // Syslog app name Facility collector.Facility // Syslog facility // Optional socket config Network string // Default: "tcp" Address string // Default: "logs-01.loggly.com:514" TLS *tls.Config // TLS transport config // Optional formatting config Formatter format.Formatter // Default: format.JSONMessage Tags []string // Tags to send with every event }
Loggly represents configuration for the Loggly service.
By default, logs are transported -in clear text-. This is very bad for security. Please see the example for enabling TLS transport encryption with Loggly.
Example (TransportEncryption) ¶
This example demonstrates how to use Loggly with TLS transport encryption enabled.
package main import ( "crypto/tls" "crypto/x509" "github.com/bobziuchkovski/cue" "github.com/bobziuchkovski/cue/collector" "github.com/bobziuchkovski/cue/hosted" "io/ioutil" "os" ) func main() { // Load Loggly's CA cert. Please see the Loggly docs for details on // retrieving their cert files. pem, err := ioutil.ReadFile("sf_bundle.crt") if err != nil { panic(err) } cacert := x509.NewCertPool() if !cacert.AppendCertsFromPEM(pem) { panic("failed to load loggly CA cert") } cue.Collect(cue.INFO, hosted.Loggly{ Token: os.Getenv("LOGGLY_TOKEN"), App: "example_loggly_tls", Facility: collector.LOCAL0, Network: "tcp", Address: "logs-01.loggly.com:6514", // Loggly uses port 6514 for TLS TLS: &tls.Config{RootCAs: cacert}, }.New()) log := cue.NewLogger("example") log.Info("This event is sent over TLS") }
Output:
type Opbeat ¶
type Opbeat struct { // Required Token string // Auth token AppID string // Application ID OrganizationID string // Organization ID // Optional ExtraContext cue.Context // Additional context values to send with every event }
Opbeat represents configuration for the Opbeat service. Collected events are sent to Opbeat at matching event levels (debug, info, etc.), complete with relevant stack trace.
type Rollbar ¶
type Rollbar struct { // Required Token string // Auth token Environment string // Environment name ("development", "production", etc.) // Optional ExtraContext cue.Context // Additional context values to send with every event ProjectVersion string // Project version (SHA value, semantic version, etc.) ProjectFramework string // Project framework name }
Rollbar represents configuration for the Rollbar service. Collected events are sent to Rollbar at matching event levels (debug, info, etc.), complete with relevant stack trace.
type Sentry ¶
type Sentry struct { // Required DSN string // DSN for the app (e.g. https://<public>:<private>@app.getsentry.com/<appid>) // Optional ExtraContext cue.Context // Additional context values to send with every event ProjectVersion string // Project version (SHA value, semantic version, etc.) }
Sentry represents configuration for the Sentry service. Collected events are sent to Sentry at matching event levels (debug, info, etc.), complete with relevant stack trace.