semconv

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const OTelSemConvStabilityOptIn = "OTEL_SEMCONV_STABILITY_OPT_IN"

OTelSemConvStabilityOptIn is an environment variable. That can be set to "old" or "http/dup" to opt into the new HTTP semantic conventions.

Variables

This section is empty.

Functions

func HTTPStatusCode

func HTTPStatusCode(status int) attribute.KeyValue

HTTPStatusCode returns the attribute for the HTTP status code. This is a temporary function needed by metrics. This will be removed when MetricsRequest is added.

func SplitHostPort

func SplitHostPort(hostport string) (host string, port int)

SplitHostPort splits a network address hostport of the form "host", "host%zone", "[host]", "[host%zone], "host:port", "host%zone:port", "[host]:port", "[host%zone]:port", or ":port" into host or host%zone and port.

An empty host is returned if it is not provided or unparsable. A negative port is returned if it is not provided or unparsable.

Types

type CurrentHTTPClient

type CurrentHTTPClient struct{}

func (CurrentHTTPClient) ErrorType

func (n CurrentHTTPClient) ErrorType(err error) attribute.KeyValue

func (CurrentHTTPClient) MetricAttributes

func (n CurrentHTTPClient) MetricAttributes(req *http.Request, statusCode int, additionalAttributes []attribute.KeyValue) []attribute.KeyValue

func (CurrentHTTPClient) RequestTraceAttrs

func (n CurrentHTTPClient) RequestTraceAttrs(req *http.Request) []attribute.KeyValue

RequestTraceAttrs returns trace attributes for an HTTP request made by a client.

func (CurrentHTTPClient) ResponseTraceAttrs

func (n CurrentHTTPClient) ResponseTraceAttrs(resp *http.Response) []attribute.KeyValue

ResponseTraceAttrs returns trace attributes for an HTTP response made by a client.

func (CurrentHTTPClient) TraceAttributes

func (n CurrentHTTPClient) TraceAttributes(host string) []attribute.KeyValue

Attributes for httptrace.

type CurrentHTTPServer

type CurrentHTTPServer struct{}

func (CurrentHTTPServer) MetricAttributes

func (n CurrentHTTPServer) MetricAttributes(server string, req *http.Request, statusCode int, additionalAttributes []attribute.KeyValue) []attribute.KeyValue

func (CurrentHTTPServer) NetworkTransportAttr

func (o CurrentHTTPServer) NetworkTransportAttr(network string) attribute.KeyValue

func (CurrentHTTPServer) RequestTraceAttrs

func (n CurrentHTTPServer) RequestTraceAttrs(server string, req *http.Request) []attribute.KeyValue

TraceRequest returns trace attributes for an HTTP request received by a server.

The server must be the primary server name if it is known. For example this would be the ServerName directive (https://httpd.apache.org/docs/2.4/mod/core.html#servername) for an Apache server, and the server_name directive (http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name) for an nginx server. More generically, the primary server name would be the host header value that matches the default virtual host of an HTTP server. It should include the host identifier and if a port is used to route to the server that port identifier should be included as an appropriate port suffix.

If the primary server name is not known, server should be an empty string. The req Host will be used to determine the server instead.

func (CurrentHTTPServer) ResponseTraceAttrs

func (n CurrentHTTPServer) ResponseTraceAttrs(resp ResponseTelemetry) []attribute.KeyValue

TraceResponse returns trace attributes for telemetry from an HTTP response.

If any of the fields in the ResponseTelemetry are not set the attribute will be omitted.

func (CurrentHTTPServer) Route

func (n CurrentHTTPServer) Route(route string) attribute.KeyValue

Route returns the attribute for the route.

type HTTPClient

type HTTPClient struct {
	// contains filtered or unexported fields
}

func NewHTTPClient

func NewHTTPClient(meter metric.Meter) HTTPClient

func (HTTPClient) ErrorType

func (c HTTPClient) ErrorType(err error) attribute.KeyValue

func (HTTPClient) MetricOptions

func (c HTTPClient) MetricOptions(ma MetricAttributes) map[string]MetricOpts

func (HTTPClient) RecordMetrics

func (s HTTPClient) RecordMetrics(ctx context.Context, md MetricData, opts map[string]MetricOpts)

func (HTTPClient) RecordResponseSize

func (s HTTPClient) RecordResponseSize(ctx context.Context, responseData int64, opts map[string]MetricOpts)

func (HTTPClient) RequestTraceAttrs

func (c HTTPClient) RequestTraceAttrs(req *http.Request) []attribute.KeyValue

RequestTraceAttrs returns attributes for an HTTP request made by a client.

func (HTTPClient) ResponseTraceAttrs

func (c HTTPClient) ResponseTraceAttrs(resp *http.Response) []attribute.KeyValue

ResponseTraceAttrs returns metric attributes for an HTTP request made by a client.

func (HTTPClient) Status

func (c HTTPClient) Status(code int) (codes.Code, string)

func (HTTPClient) TraceAttributes

func (s HTTPClient) TraceAttributes(host string) []attribute.KeyValue

type HTTPServer

type HTTPServer struct {
	// contains filtered or unexported fields
}

func NewHTTPServer

func NewHTTPServer(meter metric.Meter) HTTPServer

func (HTTPServer) NetworkTransportAttr

func (s HTTPServer) NetworkTransportAttr(network string) []attribute.KeyValue

func (HTTPServer) RecordMetrics

func (s HTTPServer) RecordMetrics(ctx context.Context, md ServerMetricData)

func (HTTPServer) RequestTraceAttrs

func (s HTTPServer) RequestTraceAttrs(server string, req *http.Request) []attribute.KeyValue

RequestTraceAttrs returns trace attributes for an HTTP request received by a server.

The server must be the primary server name if it is known. For example this would be the ServerName directive (https://httpd.apache.org/docs/2.4/mod/core.html#servername) for an Apache server, and the server_name directive (http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name) for an nginx server. More generically, the primary server name would be the host header value that matches the default virtual host of an HTTP server. It should include the host identifier and if a port is used to route to the server that port identifier should be included as an appropriate port suffix.

If the primary server name is not known, server should be an empty string. The req Host will be used to determine the server instead.

func (HTTPServer) ResponseTraceAttrs

func (s HTTPServer) ResponseTraceAttrs(resp ResponseTelemetry) []attribute.KeyValue

ResponseTraceAttrs returns trace attributes for telemetry from an HTTP response.

If any of the fields in the ResponseTelemetry are not set the attribute will be omitted.

func (HTTPServer) Route

func (s HTTPServer) Route(route string) attribute.KeyValue

Route returns the attribute for the route.

func (HTTPServer) Status

func (s HTTPServer) Status(code int) (codes.Code, string)

Status returns a span status code and message for an HTTP status code value returned by a server. Status codes in the 400-499 range are not returned as errors.

type MetricAttributes

type MetricAttributes struct {
	Req                  *http.Request
	StatusCode           int
	AdditionalAttributes []attribute.KeyValue
}

type MetricData

type MetricData struct {
	RequestSize int64
	ElapsedTime float64
}

type MetricOpts

type MetricOpts struct {
	// contains filtered or unexported fields
}

func (MetricOpts) AddOptions

func (o MetricOpts) AddOptions() metric.AddOption

func (MetricOpts) MeasurementOption

func (o MetricOpts) MeasurementOption() metric.MeasurementOption

type OldHTTPClient

type OldHTTPClient struct{}

func (OldHTTPClient) MetricAttributes

func (o OldHTTPClient) MetricAttributes(req *http.Request, statusCode int, additionalAttributes []attribute.KeyValue) []attribute.KeyValue

func (OldHTTPClient) RequestTraceAttrs

func (o OldHTTPClient) RequestTraceAttrs(req *http.Request) []attribute.KeyValue

func (OldHTTPClient) ResponseTraceAttrs

func (o OldHTTPClient) ResponseTraceAttrs(resp *http.Response) []attribute.KeyValue

func (OldHTTPClient) TraceAttributes

func (c OldHTTPClient) TraceAttributes(host string) []attribute.KeyValue

Attributes for httptrace.

type OldHTTPServer

type OldHTTPServer struct{}

func (OldHTTPServer) MetricAttributes

func (o OldHTTPServer) MetricAttributes(server string, req *http.Request, statusCode int, additionalAttributes []attribute.KeyValue) []attribute.KeyValue

func (OldHTTPServer) NetworkTransportAttr

func (o OldHTTPServer) NetworkTransportAttr(network string) attribute.KeyValue

func (OldHTTPServer) RequestTraceAttrs

func (o OldHTTPServer) RequestTraceAttrs(server string, req *http.Request) []attribute.KeyValue

RequestTraceAttrs returns trace attributes for an HTTP request received by a server.

The server must be the primary server name if it is known. For example this would be the ServerName directive (https://httpd.apache.org/docs/2.4/mod/core.html#servername) for an Apache server, and the server_name directive (http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name) for an nginx server. More generically, the primary server name would be the host header value that matches the default virtual host of an HTTP server. It should include the host identifier and if a port is used to route to the server that port identifier should be included as an appropriate port suffix.

If the primary server name is not known, server should be an empty string. The req Host will be used to determine the server instead.

func (OldHTTPServer) ResponseTraceAttrs

func (o OldHTTPServer) ResponseTraceAttrs(resp ResponseTelemetry) []attribute.KeyValue

ResponseTraceAttrs returns trace attributes for telemetry from an HTTP response.

If any of the fields in the ResponseTelemetry are not set the attribute will be omitted.

func (OldHTTPServer) Route

func (o OldHTTPServer) Route(route string) attribute.KeyValue

Route returns the attribute for the route.

type ResponseTelemetry

type ResponseTelemetry struct {
	StatusCode int
	ReadBytes  int64
	ReadError  error
	WriteBytes int64
	WriteError error
}

type ServerMetricData

type ServerMetricData struct {
	ServerName   string
	ResponseSize int64

	MetricData
	MetricAttributes
}

Directories

Path Synopsis
test module

Jump to

Keyboard shortcuts

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