otelharpy

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package otelharpy provides middleware that instruments JSON-RPC servers with OpenTelemetry tracing and metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics added in v0.6.1

type Metrics struct {
	// Next is the next exchanger in the middleware stack.
	Next harpy.Exchanger

	// MeterProvider is the OpenTelemetry MeterProvider used to create meters.
	MeterProvider metric.MeterProvider

	// ServiceName is an application specific service name to use in the span
	// name and attributes.
	//
	// It may be prefixed with a dot-separated "package name", for example
	// "myapp.test.EchoService".
	//
	// It may be empty, in which case it is omitted from the span.
	ServiceName string
	// contains filtered or unexported fields
}

Metrics is an implementation of harpy.Exchanger that provides OpenTelemetry metrics for each JSON-RPC request.

func (*Metrics) Call added in v0.6.1

func (m *Metrics) Call(ctx context.Context, req harpy.Request) harpy.Response

Call handles a call request and returns the response.

func (*Metrics) Notify added in v0.6.1

func (m *Metrics) Notify(ctx context.Context, req harpy.Request) error

Notify handles a notification request.

It invokes the handler associated with the method specified by the request. If no such method has been registered it does nothing.

type Tracing added in v0.6.0

type Tracing struct {
	// Next is the next exchanger in the middleware stack.
	Next harpy.Exchanger

	// TracerProvider is the OpenTelemetry TracerProvider to use for creating
	// spans.
	TracerProvider trace.TracerProvider

	// ServiceName is an application specific service name to use in the span
	// name and attributes.
	//
	// It may be prefixed with a dot-separated "package name", for example
	// "myapp.test.EchoService".
	//
	// It may be empty, in which case it is omitted from the span.
	ServiceName string

	// CreateNewSpan controls whether a new span is created for each request, or
	// JSON-RPC attributes are added to an existing span.
	//
	// By default it is assumed that the transport layer is responsibe for
	// creating the span, and no new span will be created.
	CreateNewSpan bool
	// contains filtered or unexported fields
}

Tracing is an implementation of harpy.Exchanger that provides OpenTelemetry tracing for each JSON-RPC request.

It adheres to the OpenTelemetry RPC semantic conventions as specified in https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/rpc.md.

func (*Tracing) Call added in v0.6.0

func (t *Tracing) Call(ctx context.Context, req harpy.Request) harpy.Response

Call handles a call request and returns the response.

func (*Tracing) Notify added in v0.6.0

func (t *Tracing) Notify(ctx context.Context, req harpy.Request) error

Notify handles a notification request.

It invokes the handler associated with the method specified by the request. If no such method has been registered it does nothing.

Jump to

Keyboard shortcuts

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