trace

package
v1.6.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: Apache-2.0 Imports: 18 Imported by: 1

README

Trace chain element

The purpose of trace.trace{Client, Server} is to log requests and responses of wrapped NetworkService{Client, Server} to span. It creates a new span for every Request() or Close().

Instead of logging full request, trace element saves it in context, so that the trace element that wrapped the next client or server, compares the request in the context with its own, and if they do not match, calculates the diff and logs only it. The same with response.

Benchmarks

If we assume that

  • logRequest() - logs full proto.Message
  • logRequestIfDiffers() - Compares previous and current proto.Message. Logs the current message only if they differ.
  • logRequestDiff() - Compares previous and current proto.Message. If they differ calculates the diff of them and logs only it.

then we get the following results:

Type Ops ns/op
logRequest() 32778 36565
logRequestIfDiffers() 33396 41140
logRequestDiff() 34741 42793

Documentation

Overview

Package trace provides a wrapper for tracing around a networkservice.NetworkServiceClient

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(oldMessage, newMessage protoreflect.Message) (map[string]interface{}, bool)

Diff - calculate a protobuf message diff

func NewNetworkServiceClient

NewNetworkServiceClient - wraps tracing around the supplied networkservice.NetworkServiceClient

func NewNetworkServiceServer

NewNetworkServiceServer - wraps tracing around the supplied traced

Types

This section is empty.

Jump to

Keyboard shortcuts

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