echootel package - github.com/labstack/echo-opentelemetry - Go Packages

View Source

const (
	
	TracerKey = "labstack-echo-otelecho-tracer"
	
	ScopeName = "github.com/labstack/echo-opentelemetry"
)

Version is the current release version of the echo instrumentation.

This section is empty.

NewMiddleware creates new echo opentelemetry middleware with the given server name.

NewMiddlewareWithConfig creates new echo opentelemetry middleware with the given configuration.

func SpanNameFormatter(v Values) string

SpanNameFormatter returns the default format for the span name based on the HTTP method and path.

HTTP span names SHOULD be `{method} {target}` if there is a (low-cardinality) `target` available. If there is no (low-cardinality) `{target}` available, HTTP span names SHOULD be `{method}`.

The `{method}` MUST be `{http.request.method}` if the method represents the original method known to the instrumentation. In other cases (when `{http.request.method}` is set to `_OTHER`), `{method}` MUST be `HTTP`

Spec: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#name

SplitAddress splits server address or host into host (`server.address`) and port (`server.port`). Empty address is accepted and returns empty host and port. Port is part is not mandatory in address and can be omitted.

AttributesFunc is used to extract additional attributes from the echo.Context and return them as a slice of attribute.KeyValue.

Config is used to configure the middleware.

ToMiddleware returns echo opentelemetry middleware which will trace incoming requests.

MetricAttributesFunc is used to compose attributes for Metrics.Record.

Metrics holds a standard set of OpenTelemetry global request/response metrics

NewMetrics creates a new Metrics instance for Standard Required metric instances with the given Meter.

Record records the given RecordValues to the Metrics instance.

type MetricsRecorder interface {
	Record(c *echo.Context, v RecordValues)
}

MetricsRecorder is used to record metrics. This interface is used to allow custom metrics recording with access to the Echo context, so additional attributes can be extracted from it.

OnErrorFunc is used to specify how errors are handled in the middleware.

RecordValues represents the values to Record metrics.

Values represent extracted values from HTTP request and response to be used for Span and Metrics attributes.

Span: Semantic Conventions for HTTP client and server spans. https://opentelemetry.io/docs/specs/semconv/http/http-spans/ Metrics: Semantic Conventions for HTTP client and server metrics. https://opentelemetry.io/docs/specs/semconv/http/http-metrics/

AppendSpanEndAttributes appends attributes to be used when ending a span, after the next handler has been executed. Use this method instead of `SpanEndAttributes()` when you want to preallocate/reuse attributes slice.

AppendStartAttributes appends attributes to be used when starting a span. Use this method instead of `SpanStartAttributes()` when you want to preallocate/reuse attributes slice.

ExtractRequest extracts values from the given HTTP request and populates the Values struct.

SpanEndAttributes returns a list of attributes to be used when ending a span, after the next handler has been executed.

SpanStartAttributes returns a list of attributes to be used when starting a span.