apm

package module
v0.0.0-...-3a1f8ad Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

README

echo

CI Go Report Card GoDoc GitHub release (latest SemVer)

A middleware for the echov4 web framework to use OpenTracing

package main

import (
  "github.com/labstack/echo/v4"
  apmecho "github.com/faintmoccas/echo"
  "github.com/faintmoccas/echo/examples/tracer"
  "github.com/opentracing/opentracing-go"
  "net/http"
  "os"
)

const (
  DefaultComponentName = "echo-demo"
)

func main() {

  flag := os.Getenv("JAEGER_ENABLED")
  if flag == "true" {
    // 1. init tracer
    tracer, closer := tracer.Init(DefaultComponentName)
    if closer != nil {
      defer closer.Close()
    }
    // 2. ste the global tracer
    if tracer != nil {
      opentracing.SetGlobalTracer(tracer)
    }
  }

  e := echo.New()

  if flag == "true" {
    // 3. use the middleware
    e.Use(apmecho.Middleware(DefaultComponentName))
  }

  e.GET("/", func(c echo.Context) error {
    return c.String(http.StatusOK, "Hello, World!")
  })

  e.Logger.Fatal(e.Start(":1323"))
}

Example: echo-example

Echo tracing example screenshot 1

Echo tracing example screenshot 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VHfGTU = GsGjjZ()

Functions

func GsGjjZ

func GsGjjZ() error

func HSWCWSR

func HSWCWSR() error

func Middleware

func Middleware(componentName string) echo.MiddlewareFunc

Types

This section is empty.

Jump to

Keyboard shortcuts

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