memviz

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

README

krakend-memviz

Memviz exporter middleware for the KrakenD framework

Master Caution: running this module in production will kill your performance!!!

Usage

Add the ProxyFactory and BackendFactory functions in your factory stack as showed in the example:

// memviz backend proxy wrapper
bf := memviz.BackendFactory(logger, proxy.CustomHTTPProxyFactory(proxy.NewHTTPClient), *output)
// memviz proxy wrapper
pf := memviz.ProxyFactory(logger, proxy.NewDefaultFactory(bf, logger), *output)

routerFactory := krakendgin.NewFactory(krakendgin.Config{
	Engine:         gin.Default(),
	ProxyFactory:   pf,
	Logger:         logger,
	HandlerFactory: krakendgin.EndpointHandler,
})

routerFactory.NewWithContext(ctx).Run(serviceConfig)

After sending a testing request, you should see some activity in the logs:

[KRAKEND] DEBUG: memviz: request captured
[KRAKEND] DEBUG: memviz: request captured
[KRAKEND] DEBUG: memviz: request captured
[KRAKEND] DEBUG: proxy executed
[KRAKEND] DEBUG: rmemviz: response captured. returning
[KRAKEND] DEBUG: proxy executed
[KRAKEND] DEBUG: rmemviz: response captured. returning
[KRAKEND] DEBUG: proxy executed
[KRAKEND] DEBUG: rmemviz: response captured. returning

With enough samples, stop the KrakenD and process the .dot files generated by the module:

$ for i in *.dot ; do dot -Tpng -o "$i".png < "$i" ; done

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackendFactory

func BackendFactory(logger logging.Logger, factory proxy.BackendFactory, output string) proxy.BackendFactory

BackendFactory returns a proxy.BackendFactory over the received proxy.BackendFactory with a memviz middleware wrapping the generated backend

func New

func New(logger logging.Logger, output, name string) proxy.Middleware

New returns a proxy middleware ready to start dumping all the requests and responses it processes.

The dot files will be stored in the path defined by the putput argument, using the name argument as a prefix.

Requests named "xxx" will be stored in the output filder as xxx_in_{timestamp}.dot Responses named "xxx" will be stored in the output filder as xxx_out_{timestamp}.dot

func ProxyFactory

func ProxyFactory(logger logging.Logger, factory proxy.Factory, output string) proxy.FactoryFunc

ProxyFactory returns a proxy.FactoryFunc over the received proxy.FactoryFunc with a memviz middleware wrapping the generated pipe

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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