instaecho

package module
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 3 Imported by: 1

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/instana/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 = "1.22.0"

Version is the instrumentation module semantic version

Variables

This section is empty.

Functions

func Middleware

func Middleware(sensor instana.TracerLogger) 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.TracerLogger) *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