instrument

package module
v0.0.0-...-8f83375 Latest Latest
Warning

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

Go to latest
Published: May 14, 2017 License: MIT Imports: 1 Imported by: 0

README

Golang Instrument

Build Status Coverage Status GoDoc

Simple interfaces for instrumentation

Installation

go get github.com/dafiti/go-instrument

Instruments

  • New Relic

Usage Examples

package main

import (
	"fmt"
	"github.com/dafiti/go-instrument"
	newrelic "github.com/newrelic/go-agent"
	"os"
)

var (
	inst instrument.Instrument
)

func main() {
	inst = new(instrument.NewRelic)

	app, err := newrelic.NewApplication(
		newrelic.NewConfig("Example App", os.Getenv("NEWRELIC_LICENSE_KEY")),
	)

	if nil != err {
		fmt.Println(err)
		os.Exit(1)
	}

	inst.SetTransaction(app.StartTransaction("background", nil, nil))

	fmt.Println(sum(10, 20))
}

func sum(v1 int, v2 int) int {
	defer inst.Segment("sum").End()

	return v1 + v2
}

Documentation

Read the full documentation at https://godoc.org/github.com/dafiti/go-instrument.

License

This project is released under the MIT licence. See LICENCE for more details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dummy

type Dummy struct {
}

Dummy Structure

func (*Dummy) ExternalSegment

func (d *Dummy) ExternalSegment(url string) Segment

Create a external segment

func (*Dummy) Segment

func (d *Dummy) Segment(name string) Segment

Create a segment

func (*Dummy) SetTransaction

func (d *Dummy) SetTransaction(txn interface{})

Set the NewRelic transaction

type DummyExternalSegment

type DummyExternalSegment struct {
}

Dummy External Structure

func (DummyExternalSegment) End

func (es DummyExternalSegment) End() error

Ends the external segment

type DummySegment

type DummySegment struct {
}

Dummy Segment Structure

func (DummySegment) End

func (s DummySegment) End() error

Ends the segment

type Instrument

type Instrument interface {
	// Added new external segment metric (ex. http clients)
	ExternalSegment(url string) Segment

	// Added a segment metric
	Segment(name string) Segment

	// Define a transaction used in segments
	SetTransaction(txn interface{})
}

Instrumentation interface for metrics

type NewRelic

type NewRelic struct {
	// contains filtered or unexported fields
}

Structure used to storage the NewRelic transaction

func (*NewRelic) ExternalSegment

func (nr *NewRelic) ExternalSegment(url string) Segment

Create a external segment

func (*NewRelic) Segment

func (nr *NewRelic) Segment(name string) Segment

Create a segment

func (*NewRelic) SetTransaction

func (nr *NewRelic) SetTransaction(txn interface{})

Set the NewRelic transaction

type NewRelicExternalSegment

type NewRelicExternalSegment struct {
	// contains filtered or unexported fields
}

Structure used to storage the NewRelic External Segment

func (NewRelicExternalSegment) End

func (es NewRelicExternalSegment) End() error

Ends the external segment

type NewRelicSegment

type NewRelicSegment struct {
	// contains filtered or unexported fields
}

Structure used to storage the NewRelic Segment

func (NewRelicSegment) End

func (s NewRelicSegment) End() error

Ends the segment

type Segment

type Segment interface {
	// Collection ends for segment
	End() error
}

Segment interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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