splunkhttprouter

package module
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

Splunk instrumentation for github.com/julienschmidt/httprouter

This package provides OpenTelemetry instrumentation for the github.com/julienschmidt/httprouter module.

Getting Started

This package is designed to be used as a drop-in replacement for the use of the github.com/julienschmidt/httprouter package. See example_test.go for more information.

Documentation

Overview

Package splunkhttprouter provides OpenTelemetry instrumentation for the github.com/julienschmidt/httprouter module.

Example
package main

import (
	"fmt"
	"net/http"

	"github.com/julienschmidt/httprouter"

	"github.com/signalfx/splunk-otel-go/instrumentation/github.com/julienschmidt/httprouter/splunkhttprouter"
)

func Index(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
	fmt.Fprint(w, "Welcome!\n")
}

func Hello(w http.ResponseWriter, _ *http.Request, ps httprouter.Params) {
	fmt.Fprintf(w, "hello, %s!\n", ps.ByName("name"))
}

func main() {
	router := splunkhttprouter.New()
	router.GET("/", Index)
	router.GET("/hello/:name", Hello)

	if err := http.ListenAndServe(":8080", router); err != nil {
		panic(err)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Router

type Router struct {
	*httprouter.Router
	// contains filtered or unexported fields
}

Router is a traced version of httprouter.Router.

func New

func New(opts ...otelhttp.Option) *Router

New returns a new router augmented with tracing.

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP serves req writing a response to w and tracing the process.

Jump to

Keyboard shortcuts

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