# README
Performance Helpers for Sentry Performance Monitoring
Helpers to get sentry performance monitoring working easily.
Installation
1. Installation
go get github.com/wernerdweight/sentry-performance-helpers
Configuration
The package itself needs no configuration. Check Sentry documentation for the setup related to Sentry.
Usage
Basic usage
// create a transaction
transaction := performance.CreateTransaction("transaction-name", "operation")
doSomething()
// create a span attached to the transaction
span := performance.CreateSpan("transaction-name", "operation")
doSomethingElse()
// finish span (otherwise, it will not get to Sentry)
span.Finish()
doSomethingCompletelyDifferent()
// finish transaction (otherwise, it will not get to Sentry)
transaction.Finish()
Accessing transaction/span properties
// get transaction by its name
transaction := performance.GetTransaction("transaction-name")
// get span by operation
span := performance.GetSpan("transaction-name", "operation")
Usage with defer
package main
import "github.com/wernerdweight/sentry-performance-helpers"
func doSomething() {
defer performance.CreateSpan("my-transaction", "doSomething").Finish()
// put your code here, the transaction/span is created now
// due to how defer works, the 'Finish' method will be called at the end
}
func main() {
defer performance.CreateTransaction("my-transaction", "main").Finish()
doSomething()
}
License
This package is under the MIT license. See the complete license in the root directiory of the bundle.
# Functions
CreateSpan creates a span and attaches it to a transaction specified by its name (returns nil if transaction doesn't exist).
CreateTransaction creates a transaction that can be attached additional spans.
CreateTransactionWithContext creates a transaction that can be attached additional spans and sets an existing context.
GetSpan returns a transaction by its name (or nil if none exists).
GetTransaction returns a transaction by its name (or nil if none exists).
Refresh clears current transaction context.