xopresty

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 9 Imported by: 0

README

xopresty - Golang XOP (Cross Observability Platform) propagator using resty

GoDoc unit tests report card codecov

Package xopresty and outbound propagator for xop using resty.

Documentation

Overview

package xopresty adds to the resty package to propagate xop context to through an HTTP request.

As of March 29th, 2023, the released resty package does not provide a way to have a logger that knows which request it is logging about. The resty package does not provide a way to know when requests are complete.

Pull requests to fix these issues have been merged but not made part of a release.

In the meantime, this package depends upon https://github.com/muir/resty.

The agumented resty Client requires that a context that has the parent log span be provided:

client.R().SetContext(log.IntoContext(context.Background()))

If there is no logger in the context, the request will fail.

If you use resty's Client.SetDebug(true), note that the output will be logged at Debug level which is below the default minimum level for xop.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(client *resty.Client, opts ...ClientOpt) *resty.Client

func WithNameInContext

func WithNameInContext(ctx context.Context, nameOrDescription string) context.Context

WithNameInDescription adds a span name to a context. If present, a name in context overrides WithNameGenerate.

Types

type ClientOpt

type ClientOpt func(*config)

func WithExtraLogging

func WithExtraLogging(f ExtraLogging) ClientOpt

func WithNameGenerate

func WithNameGenerate(f func(*resty.Request) string) ClientOpt

WithNameGenerate provides a function to convert a request into a description for the span.

type ExtraLogging

type ExtraLogging func(log *xop.Logger, originalStartTime time.Time, retryCount int, request *resty.Request, response *resty.Response, err error)

ExtraLogging provides a hook for extra logging to be done. It is possible that the response parameter will be null. If error is not null, then the request has failed. ExtraLogging should only be called once but if another resty callback panic's, it is possible ExtraLogging will be called twice.

Jump to

Keyboard shortcuts

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