Documentation ¶
Overview ¶
Package beeline aids adding instrumentation to go apps using Honeycomb.
Summary ¶
This package and its subpackages contain bits of code to use to make your life easier when instrumenting a Go app to send events to Honeycomb. The wrappers here will collect a handful of useful fields about HTTP requests and SQL calls in addition to establishing easy patterns to augment this data as your application runs. They are useful for applications handling HTTP requests or using the `sql` and `sqlx` packages.
Regardless of which subpackages are used, there is a small amount of global configuration to add to your application's startup process. At the bare minimum, you must pass in your team write key and identify a dataset name to authorize your code to send events to Honeycomb and tell it where to send events.
func main() { beeline.Init(&beeline.Config{ WriteKey: "abcabc123123defdef456456", Dataset: "myapp", }) ...
Once configured, use one of the subpackages to wrap HTTP handlers and SQL db objects.
Examples ¶
There are runnable examples at https://github.com/honeycombio/beeline-go/tree/master/examples and examples of each wrapper in the dgodoc.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddField ¶
AddField allows you to add a single field to an event anywhere downstream of an instrumented request. After adding the appropriate middleware or wrapping a Handler, feel free to call AddField freely within your code. Pass it the context from the request (`r.Context()`) and the key and value you wish to add.
func Close ¶
func Close()
Close shuts down the beeline. Closing flushes any pending events and blocks until they have been sent. It is optional to close the beeline, and prohibited to try and send an event after the beeline has been closed.
func ContextEvent ¶
ContextEvent retrieves the Honeycomb event from a context. You can add fields to the event or override settings (eg sample rate) but should not Send() the event; the wrapper that inserted the event into the Context is responsible for sending it to Hnoeycomb
func ContextWithEvent ¶
ContextWithEvent returns a new context created from the passed context with a Honeycomb event added to it. In most cases, the code adding the event to the context should also be responsible for sending that event on to Honeycomb when it's finished.
Types ¶
type Config ¶
type Config struct { // Writekey is your Honeycomb authentication token, available from // https://ui.honeycomb.io/account. default: writekey-placeholder WriteKey string // Dataset is the name of the Honeycomb dataset to which events will be // sent. default: go-http Dataset string // Service Name identifies your application. While optional, setting this // field is extremely valuable when you instrument multiple services. If set // it will be added to all events as `service_name` ServiceName string // SamplRate is a positive integer indicating the rate at which to sample // events. default: 1 SampleRate uint // APIHost is the hostname for the Honeycomb API server to which to send // this event. default: https://api.honeycomb.io/ APIHost string // STDOUT when set to true will print events to STDOUT *instead* of sending // them to honeycomb; useful for development. default: false STDOUT bool // Mute when set to true will disable Honeycomb entirely; useful for tests // and CI. default: false Mute bool // Debug will emit verbose logging to STDOUT when true. If you're having // trouble getting the beeline to work, set this to true in a dev // environment. Debug bool }
Config is the place where you configure your Honeycomb write key and dataset name. WriteKey is the only required field in order to acutally send events to Honeycomb.
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
Package timer is a small convenience package for timing blocks of code.
|
Package timer is a small convenience package for timing blocks of code. |
wrappers
|
|
hnygoji
Package hnygoji has Middleware to use with the Goji muxer.
|
Package hnygoji has Middleware to use with the Goji muxer. |
hnygorilla
Package hnygorilla has Middleware to use with the Gorilla muxer.
|
Package hnygorilla has Middleware to use with the Gorilla muxer. |
hnyhttprouter
Package hnyhttprouter has Middleware to use with the httprouter muxer.
|
Package hnyhttprouter has Middleware to use with the httprouter muxer. |
hnynethttp
Package hnynethttp provides Honeycomb wrappers for net/http Handlers.
|
Package hnynethttp provides Honeycomb wrappers for net/http Handlers. |
hnysql
Package hnysql wraps `database.sql` to emit one Honeycomb event per DB call.
|
Package hnysql wraps `database.sql` to emit one Honeycomb event per DB call. |
hnysqlx
Package hnysqlx wraps `jmoiron/sqlx` to emit one Honeycomb event per DB call.
|
Package hnysqlx wraps `jmoiron/sqlx` to emit one Honeycomb event per DB call. |