othttp

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 6 Imported by: 0

README

othttp

OpenTracing plugin for the Go standard library net/http.

Usage

Client
package main

import (
	"github.com/yuewokeji/opentracing-go-plugins/module/othttp"
	"net/http"
	"strings"
)

func main() {
	client := othttp.WrapClient(&http.Client{})
	req, err := http.NewRequest("GET", "https://github.com", strings.NewReader(""))
	if err != nil {
		panic(err)
	}

	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}

	// do something
}

Server

Implement later.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientSpanName

func ClientSpanName(req string) string

func GetRemoteAddr

func GetRemoteAddr(r *http.Request) string

func IsStatusError

func IsStatusError(code int) bool

func NoopRequestIgnore

func NoopRequestIgnore(r *http.Request) bool

func RequestWithContext

func RequestWithContext(r *http.Request, s opentracing.Span) *http.Request

func ServerSpanName

func ServerSpanName(serverName, req string) string

func SpanContextFormRequest

func SpanContextFormRequest(r *http.Request, tracer opentracing.Tracer) (opentracing.SpanContext, error)

func URLPathRequestNameFunc

func URLPathRequestNameFunc(r *http.Request) string

func WrapClient

func WrapClient(c *http.Client, options ...Option) *http.Client

func WrapRoundTripper

func WrapRoundTripper(r http.RoundTripper, options ...Option) http.RoundTripper

Types

type ClientIPFunc

type ClientIPFunc func(r *http.Request) string

type Option

type Option func(*roundTripper)

func WithRequestIgnoreFunc

func WithRequestIgnoreFunc(ri RequestIgnoreFunc) Option

func WithRequestNameFunc

func WithRequestNameFunc(rn RequestNameFunc) Option

func WithTracer

func WithTracer(tracer opentracing.Tracer) Option

type RequestIgnoreFunc

type RequestIgnoreFunc func(r *http.Request) bool

type RequestNameFunc

type RequestNameFunc func(r *http.Request) string

Jump to

Keyboard shortcuts

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