Categorygithub.com/highlight-run/highlight-go
modulepackage
0.6.0
Repository: https://github.com/highlight-run/highlight-go.git
Documentation: pkg.go.dev

# README

Go Report Card GoDoc codecov

highlight-go

Official implementation of the Highlight backend client in Go.

Usage

First, import the package

go get -u github.com/highlight-run/highlight-go

Then, add the following lines to your applications main function:

import (
	"github.com/highlight-run/highlight-go"
)

func main() {
	//...application logic...
	highlight.Start()
	defer highlight.Stop()
	//...application logic...
}

Then, use a highlight middleware in your apps router:

if you're using go-chi/chi:

import (
	highlightChi "github.com/highlight-run/highlight-go/middleware/chi"
)

func main() {
	//...
	r := chi.NewMux()
	r.Use(highlightChi.Middleware)
	//...
}

if you're using gin-gonic/gin:

import (
	highlightGin "github.com/highlight-run/highlight-go/middleware/gin"
)

func main() {
	//...
	r := gin.New()
	r.Use(highlightGin.Middleware())
	//...
}

Finally, it's time to consume errors. Add the following line to your error handling:

func someEndpoint() {
	err := someFuntionCall()
	if err != nil {
		highlight.ConsumeError(err)
		// including optional tags:
		highlight.ConsumeError(err, "environment:dev", "important")
	}
}

# Packages

No description provided by the author

# Functions

ConsumeError adds an error to the queue of errors to be sent to our backend.
InterceptRequest calls InterceptRequestWithContext using the request object's context.
InterceptRequestWithContext captures the highlight session and request ID for a particular request from the request headers, adding the values to the provided context.
No description provided by the author
No description provided by the author
RecordMetric is used to record arbitrary metrics in your golang backend.
No description provided by the author
SetFlushInterval allows you to override the amount of time in which the Highlight client will collect errors before sending them to our backend.
SetGraphqlClientAddress allows you to override the graphql client address, in case you are running Highlight on-prem, and need to point to your on-prem instance.
Start is used to start the Highlight client's collection service.
StartWithContext is used to start the Highlight client's collection service, but allows the user to pass in their own context.Context.
Stop sends an interrupt signal to the main process, closing the channels and returning the goroutines.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
Logger is an interface that implements Log and Logf.
Requester is used for making graphql requests in testing, a mock requester with an overwritten trigger function may be used.