ocgremlin

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestIDAttribute = "gremlin.request_id"
	OperationAttribute = "gremlin.operation"
	QueryAttribute     = "gremlin.query"
	BindingAttribute   = "gremlin.binding"
	CodeAttribute      = "gremlin.code"
	MessageAttribute   = "gremlin.message"
)

Attributes recorded on the span for the requests.

Variables

View Source
var (
	RequestCount = stats.Int64(
		"gremlin/request_count",
		"Number of Gremlin requests started",
		stats.UnitDimensionless,
	)
	ResponseBytes = stats.Int64(
		"gremlin/response_bytes",
		"Total number of bytes in response data",
		stats.UnitBytes,
	)
	RoundTripLatency = stats.Float64(
		"gremlin/roundtrip_latency",
		"End-to-end latency",
		stats.UnitMilliseconds,
	)
)

The following measures are supported for use in custom views.

View Source
var (
	DefaultSizeDistribution    = view.Distribution(32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576)
	DefaultLatencyDistribution = view.Distribution(1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000)
)

Default distributions used by views in this package.

View Source
var (
	RequestCountView = &view.View{
		Name:        "gremlin/request_count",
		Measure:     RequestCount,
		Aggregation: view.Count(),
		Description: "Count of Gremlin requests started",
	}

	ResponseCountView = &view.View{
		Name:        "gremlin/response_count",
		Measure:     RoundTripLatency,
		Aggregation: view.Count(),
		Description: "Count of responses received, by response status",
		TagKeys:     []tag.Key{StatusCode},
	}

	ResponseBytesView = &view.View{
		Name:        "gremlin/response_bytes",
		Measure:     ResponseBytes,
		Aggregation: DefaultSizeDistribution,
		Description: "Total number of bytes in response data",
	}

	RoundTripLatencyView = &view.View{
		Name:        "gremlin/roundtrip_latency",
		Measure:     RoundTripLatency,
		Aggregation: DefaultLatencyDistribution,
		Description: "End-to-end latency, by response code",
		TagKeys:     []tag.Key{StatusCode},
	}
)

Package ocgremlin provides some convenience views for measures. You still need to register these views for data to actually be collected.

View Source
var (
	// StatusCode is the numeric Gremlin response status code,
	// or "error" if a transport error occurred and no status code was read.
	StatusCode, _ = tag.NewKey("gremlin_status_code")
)

The following tags are applied to stats recorded by this package.

Functions

func TraceStatus

func TraceStatus(status int) trace.Status

TraceStatus is a utility to convert the gremlin status code to a trace.Status.

func Views

func Views() []*view.View

Views are the default views provided by this package.

Types

type Transport

type Transport struct {
	// Base is a wrapped gremlin.RoundTripper that does the actual requests.
	Base gremlin.RoundTripper

	// StartOptions are applied to the span started by this Transport around each
	// request.
	//
	// StartOptions.SpanKind will always be set to trace.SpanKindClient
	// for spans started by this transport.
	StartOptions trace.StartOptions

	// GetStartOptions allows to set start options per request. If set,
	// StartOptions is going to be ignored.
	GetStartOptions func(context.Context, *gremlin.Request) trace.StartOptions

	// NameFromRequest holds the function to use for generating the span name
	// from the information found in the outgoing Gremlin Request. By default the
	// name equals the URL Path.
	FormatSpanName func(context.Context, *gremlin.Request) string

	// WithQuery, if set to true, will enable recording of gremlin queries in spans.
	// Only allow this if it is safe to have queries recorded with respect to
	// security.
	WithQuery bool
}

Transport is an gremlin.RoundTripper that instruments all outgoing requests with OpenCensus stats and tracing.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(ctx context.Context, req *gremlin.Request) (*gremlin.Response, error)

RoundTrip implements gremlin.RoundTripper, delegating to Base and recording stats and traces for the request.

Jump to

Keyboard shortcuts

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