Categorygithub.com/scout-inc/scout-go
modulepackage
1.0.1
Repository: https://github.com/scout-inc/scout-go.git
Documentation: pkg.go.dev

# README

Go Report Card GoDoc codecov

scout-go

The official Go SDK for Scout. Read the docs at https://docs.getscout.dev/sdks/go/overview

Usage

Require package:

go get github.com/scout-inc/scout-go

In your entrypoint function:

import "github.com/scout-inc/scout-go"

func main() {
	// some code

	scout.Init(
		scout.WithProjectID(SCOUT_PROJECT_ID)
	)
	defer scout.Stop()
	
	// some code
}

Scout provides middleware for the more common Go server frameworks:

go-chi/chi:

import (
	"github.com/scout-inc/scout-go"
	s "github.com/scout-inc/scout-go/middleware/chi"
)

func main() {
	// some code
	scout.Init(
		scout.WithProjectID(SCOUT_PROJECT_ID)
	)
	defer scout.Stop()

	r := chi.NewMux()
	r.Use(s.Middleware)
	// some code
}

gin-gonic/gin:

import (
	"github.com/scout-inc/scout-go"
	s "github.com/scout-inc/scout-go/middleware/gin"
)

func main() {
	// some code
	scout.Init(
		scout.WithProjectID(SCOUT_PROJECT_ID)
	)
	defer scout.Stop()

	r := chi.NewMux()
	r.Use(s.Middleware())
	// some code
}

See https://docs.getscout.dev/sdks/go/frameworks for more examples.

To manually record an error:

import (
	...
	"go.opentelemetry.io/otel/attribute"
)

func LoginWithOAuth(ctx context.Context, email string) {
	value, err := doSomething()
	if err != nil {
		// tags can be used to enrich errors and traces with additional information
		errorTags := []attribute.KeyValue{
			{
				Key: attribute.Key("user.email"),
				Value: attribute.StringValue(email)
			}
		}
		scout.RecordError(ctx, err, errorTags...)
	}
	// some code
}

# Packages

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

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Initialise telemetry collector.
InterceptRequest calls InterceptRequestWithContext using the request object's context.
InterceptRequestWithContext captures the and request ID for a particular request from the request headers, adding the values to the provided context.
No description provided by the author
RecordError processes `err` to be recorded as a part of the session or network request.
RecordMetric is used to record arbitrary metrics in your Go backend.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SetOtelEndpoint allows you to override the otlp address used for sending errors and traces.
No description provided by the author
Start readies Scout to start collecting telemetry.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
StartWithContext is used to start Scout's telemetry collection service, but allows the user to pass in their own context.Context.
Flush buffers and stop collecting telemetry.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
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

# Interfaces

No description provided by the author
Logger is an interface that implements Log and Logf.
No description provided by the author

# Type aliases

No description provided by the author