performance

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 3 Imported by: 0

README

Performance Helpers for Sentry Performance Monitoring

Helpers to get sentry performance monitoring working easily.

Build Status Go Report Card GoDoc go.dev

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.

Documentation

Overview

Package performance provides helpers to get sentry performance monitoring working fast.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSpan

func CreateSpan(transactionName string, operation string) *sentry.Span

CreateSpan creates a span and attaches it to a transaction specified by its name (returns nil if transaction doesn't exist).

func CreateTransaction

func CreateTransaction(name string, operation string) *sentry.Span

CreateTransaction creates a transaction that can be attached additional spans.

func CreateTransactionWithContext added in v1.2.0

func CreateTransactionWithContext(name string, operation string, ctx context.Context) *sentry.Span

CreateTransactionWithContext creates a transaction that can be attached additional spans and sets an existing context.

func GetSpan

func GetSpan(transactionName string, operation string) *sentry.Span

GetSpan returns a transaction by its name (or nil if none exists).

func GetTransaction

func GetTransaction(name string) *sentry.Span

GetTransaction returns a transaction by its name (or nil if none exists).

func Refresh

func Refresh()

Refresh clears current transaction context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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