Skip to content

Latest commit

 

History

History
50 lines (40 loc) · 1.82 KB

README.md

File metadata and controls

50 lines (40 loc) · 1.82 KB

Go Reference tests Go Report Card codecov GitHub release (latest SemVer) GitHub go.mod Go version

Otelfox

Otelfox is a middleware for Fox that provides distributed tracing using OpenTelemetry.

Disclaimer

Otelfox's API is linked to Fox router, and it will only reach v1 when the router is stabilized. During the pre-v1 phase, breaking changes may occur and will be documented in the release notes.

Getting started

Installation

go get -u github.com/tigerwill90/otelfox

Features

  • Automatically creates spans for incoming HTTP requests
  • Extracts and propagates trace context from incoming requests
  • Annotates spans with HTTP-specific attributes, such as method, route, and status code

Usage

package main

import (
	"github.com/tigerwill90/fox"
	"github.com/tigerwill90/otelfox"
	"log"
	"net/http"
)

func main() {
	r := fox.New(
		fox.WithMiddleware(otelfox.Middleware("fox")),
	)

	r.MustHandle(http.MethodGet, "/hello/{name}", func(c fox.Context) {
		_ = c.String(http.StatusOK, "hello %s\n", c.Param("name"))
	})

	log.Fatalln(http.ListenAndServe(":8080", r))
}