treblle

package module
v0.0.0-...-892c69a Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 14 Imported by: 0

README

treblle-go-gin

The offical Treblle SDK for Go using Gin

Installation

go get github.com/treblle/treblle-go-gin

Trebble uses Go Modules to manage dependencies.

Basic configuration

Configure Treblle at the start of your main() function:

import "github.com/treblle/treblle-go-gin"

func main() {
	treblle.Configure(treblle.Configuration{
		APIKey:     "YOUR API KEY HERE",
		ProjectID:  "YOUR PROJECT ID HERE",
		KeysToMask: []string{"password", "card_number"}, // optional, mask fields you don't want sent to Treblle
		ServerURL:  "https://rocknrolla.treblle.com",    // optional, don't use default server URL
	}

    // rest of your program.
}

After that, just use the middleware with any of your Gin handlers:

r := gin.Default()
r.Use(treblle.GinMiddleware())

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config internalConfiguration
View Source
var ErrNotJson = errors.New("request body is not JSON")

Functions

func Configure

func Configure(config Configuration)

func GinMiddleware

func GinMiddleware() gin.HandlerFunc

Types

type BaseUrlOptions

type BaseUrlOptions struct {
	Debug bool
}

type BodyLogWriter

type BodyLogWriter struct {
	gin.ResponseWriter
	Body *bytes.Buffer
}

type Configuration

type Configuration struct {
	APIKey                 string
	ProjectID              string
	AdditionalFieldsToMask []string
}

Configuration sets up and customizes communication with the Treblle API

type DataInfo

type DataInfo struct {
	Server   ServerInfo   `json:"server"`
	Language LanguageInfo `json:"language"`
	Request  RequestInfo  `json:"request"`
	Response ResponseInfo `json:"response"`
}

type ErrorInfo

type ErrorInfo struct {
	Source  string `json:"source"`
	Type    string `json:"type"`
	Message string `json:"message"`
	File    string `json:"file"`
	Line    int    `json:"line"`
}

type LanguageInfo

type LanguageInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type MetaData

type MetaData struct {
	ApiKey    string   `json:"api_key"`
	ProjectID string   `json:"project_id"`
	Version   string   `json:"version"`
	Sdk       string   `json:"sdk"`
	Data      DataInfo `json:"data"`
}

type OsInfo

type OsInfo struct {
	Name         string `json:"name"`
	Release      string `json:"release"`
	Architecture string `json:"architecture"`
}

type RequestInfo

type RequestInfo struct {
	Timestamp string          `json:"timestamp"`
	Ip        string          `json:"ip"`
	Url       string          `json:"url"`
	UserAgent string          `json:"user_agent"`
	Method    string          `json:"method"`
	Headers   json.RawMessage `json:"headers"`
	Body      json.RawMessage `json:"body"`
}

type ResponseInfo

type ResponseInfo struct {
	Headers  json.RawMessage `json:"headers"`
	Code     int             `json:"code"`
	Size     int             `json:"size"`
	LoadTime float64         `json:"load_time"`
	Body     json.RawMessage `json:"body"`
	Errors   []ErrorInfo     `json:"errors"`
}

type ServerInfo

type ServerInfo struct {
	Ip        string `json:"ip"`
	Timezone  string `json:"timezone"`
	Software  string `json:"software"`
	Signature string `json:"signature"`
	Protocol  string `json:"protocol"`
	Os        OsInfo `json:"os"`
}

Jump to

Keyboard shortcuts

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