net-http

command module
v0.0.0-...-00c83e7 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: BSD-2-Clause Imports: 9 Imported by: 0

README

net/http OpenTelemetry instrumentation example

PkgGoDev

Quickstart

Install otelhttp instrumentation:

go get go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp

Then wrap your handlers with otelhttp.NewHandler:

func main() {
    http.Handle("/hello", otelhttp.NewHandler(
        http.HandlerFunc(helloHandler),
        "hello-handler",
    ))
}

func helloHandler(w http.ResponseWriter, req *http.Request) { ... }

Example

To run this example:

UPTRACE_DSN="https://<token>@api.uptrace.dev/<project_id>" go run main.go

Then open http://localhost:9999

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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