chttp_middleware_opentracing

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 4 Imported by: 0

README

OpenTracing middleware for the cHTTP client

Adds an OpenTracing logs and headers to the request.

Usage example
package clients

import (
	"context"

	"github.com/spyzhov/chttp"
	middleware "github.com/spyzhov/chttp-middleware-opentracing"
)

type Client struct {
	Client *chttp.JSONClient
}

func New() *Client {
	client := chttp.NewJSON(nil)
	client.With(middleware.Opentracing())

	return &Client{
		Client: client,
	}
}

func (c *Client) GetCount(ctx context.Context) (result int, err error) {
    return result, c.Client.GET(ctx, "https://example.com/get/count", nil, &result)
}

License

MIT licensed. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Opentracing

func Opentracing() func(request *http.Request, next func(*http.Request) (*http.Response, error)) (*http.Response, error)

Opentracing is a chttp.Middleware constructor to add opentracing to the request. Use the default name generator: Method + Path

func OpentracingCustom

func OpentracingCustom(getName func(*http.Request) string) func(request *http.Request, next func(*http.Request) (*http.Response, error)) (*http.Response, error)

OpentracingCustom is a chttp.Middleware constructor to add opentracing to the request.

Types

This section is empty.

Jump to

Keyboard shortcuts

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