instaecho

package module
v0.0.0-...-9bf41b3 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MIT Imports: 2 Imported by: 0

README

Instana instrumentation for Echo framework

This module contains middleware to instrument HTTP services written with github.com/labstack/echo.

PkgGoDev

Installation

To add the module to your go.mod file run the following command in your project directory:

$ go get github.com/mier85/go-sensor/instrumentation/instaecho

Usage

// create a sensor
sensor := instana.NewSensor("echo-sensor")

// init instrumented Echo
e := instaecho.New(sensor)

// define API
e.GET("/foo", func(c echo.Context) error { /* ... */ })
// ...

Full example

Documentation

Overview

Example

This example shows how to instrument an HTTP server that uses github.com/labstack/echo with Instana

sensor := instana.NewSensor("my-web-server")

// Use instaecho.New() to create a new instance of Echo. The returned instance is instrumented
// with Instana and will create an entry HTTP span for each incoming request.
engine := instaecho.New(sensor)

// Use the instrumented instance as usual
engine.GET("/myendpoint", func(c echo.Context) error {
	return c.JSON(200, map[string]string{
		"message": "pong",
	})
})

log.Fatalln(engine.Start(":0"))
Output:

Index

Examples

Constants

View Source
const Version = "v1.1.1"

Version is the instrumentation module semantic version

Variables

This section is empty.

Functions

func Middleware

func Middleware(sensor *instana.Sensor) echo.MiddlewareFunc

Middleware wraps Echo's handlers execution. Adds tracing context and handles entry span. It should be added as a first Middleware to the Echo, before defining handlers.

func New

func New(sensor *instana.Sensor) *echo.Echo

New returns an instrumented Echo.

Types

This section is empty.

Jump to

Keyboard shortcuts

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