echotrace

package module
v0.0.0-...-cda3030 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2019 License: MIT Imports: 3 Imported by: 2

README

echo-trace

MIT licensed GoDoc Build Status Coverage Status Go Report Card

Request tracing for the the echo framework based on golang.org/x/net/trace.

Installation

go get -u github.com/awbraunstein/echo-trace

Usage

package main

import (
	"net/http"

	echotrace "github.com/awbraunstein/echo-trace"
	"github.com/labstack/echo"
	"golang.org/x/net/trace"
)

func main() {
	e := echo.New()
	// Install the echotrace middleware.
	e.Use(echotrace.Middleware)

	// Enable the echotrace handler on /debug/requests.
	e.GET("/debug/requests", echotrace.Handler)

	e.GET("/", func(c echo.Context) error {
		tr := c.Get(ehcotrace.ContextKey).(trace.Trace)
		tr.LazyPrintf("Adding some data to the trace")
		return c.String(http.StatusOK, "Handled /")
	})
}

Documentation

Overview

Package echotrace enables golang.org/x/net/trace based request tracing for echo based servers.

Index

Constants

View Source
const (
	// ContextKey is the key used to lookup the trace.Trace for the current
	// request from the echo.Context.
	ContextKey = "trace-context-key"
)

Variables

View Source
var Handler = echo.WrapHandler(http.HandlerFunc(trace.Traces))

Handler is a echo.HandlerFunc that serves the page of traces.

Functions

func Middleware

func Middleware(next echo.HandlerFunc) echo.HandlerFunc

Middleware is a echo.MiddlewareFunc that creates a new trace.Trace for the current request and sets in on the echo.Context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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