...

Package internal

import "go.opentelemetry.io/otel/semconv/internal/v4"
Overview
Index

Overview ▾

type HTTPConv

HTTPConv are the HTTP semantic convention attributes defined for a version of the OpenTelemetry specification.

type HTTPConv struct {
    NetConv *NetConv

    EnduserIDKey                 attribute.Key
    HTTPClientIPKey              attribute.Key
    NetProtocolNameKey           attribute.Key
    NetProtocolVersionKey        attribute.Key
    HTTPMethodKey                attribute.Key
    HTTPRequestContentLengthKey  attribute.Key
    HTTPResponseContentLengthKey attribute.Key
    HTTPRouteKey                 attribute.Key
    HTTPSchemeHTTP               attribute.KeyValue
    HTTPSchemeHTTPS              attribute.KeyValue
    HTTPStatusCodeKey            attribute.Key
    HTTPTargetKey                attribute.Key
    HTTPURLKey                   attribute.Key
    UserAgentOriginalKey         attribute.Key
}

func (*HTTPConv) ClientRequest

func (c *HTTPConv) ClientRequest(req *http.Request) []attribute.KeyValue

ClientRequest returns attributes for an HTTP request made by a client. The following attributes are always returned: "http.url", "http.flavor", "http.method", "net.peer.name". The following attributes are returned if the related values are defined in req: "net.peer.port", "http.user_agent", "http.request_content_length", "enduser.id".

func (*HTTPConv) ClientResponse

func (c *HTTPConv) ClientResponse(resp *http.Response) []attribute.KeyValue

ClientResponse returns attributes for an HTTP response received by a client from a server. The following attributes are returned if the related values are defined in resp: "http.status.code", "http.response_content_length".

This does not add all OpenTelemetry required attributes for an HTTP event, it assumes ClientRequest was used to create the span with a complete set of attributes. If a complete set of attributes can be generated using the request contained in resp. For example:

append(ClientResponse(resp), ClientRequest(resp.Request)...)

func (*HTTPConv) ClientStatus

func (c *HTTPConv) ClientStatus(code int) (codes.Code, string)

ClientStatus returns a span status code and message for an HTTP status code value received by a client.

func (*HTTPConv) RequestHeader

func (c *HTTPConv) RequestHeader(h http.Header) []attribute.KeyValue

RequestHeader returns the contents of h as OpenTelemetry attributes.

func (*HTTPConv) ResponseHeader

func (c *HTTPConv) ResponseHeader(h http.Header) []attribute.KeyValue

ResponseHeader returns the contents of h as OpenTelemetry attributes.

func (*HTTPConv) ServerRequest

func (c *HTTPConv) ServerRequest(server string, req *http.Request) []attribute.KeyValue

ServerRequest returns 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.

The following attributes are always returned: "http.method", "http.scheme", "http.flavor", "http.target", "net.host.name". The following attributes are returned if they related values are defined in req: "net.host.port", "net.sock.peer.addr", "net.sock.peer.port", "http.user_agent", "enduser.id", "http.client_ip".

func (*HTTPConv) ServerStatus

func (c *HTTPConv) ServerStatus(code int) (codes.Code, string)

ServerStatus 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 NetConv

NetConv are the network semantic convention attributes defined for a version of the OpenTelemetry specification.

type NetConv struct {
    NetHostNameKey     attribute.Key
    NetHostPortKey     attribute.Key
    NetPeerNameKey     attribute.Key
    NetPeerPortKey     attribute.Key
    NetSockFamilyKey   attribute.Key
    NetSockPeerAddrKey attribute.Key
    NetSockPeerPortKey attribute.Key
    NetSockHostAddrKey attribute.Key
    NetSockHostPortKey attribute.Key
    NetTransportOther  attribute.KeyValue
    NetTransportTCP    attribute.KeyValue
    NetTransportUDP    attribute.KeyValue
    NetTransportInProc attribute.KeyValue
}

func (*NetConv) Client

func (c *NetConv) Client(address string, conn net.Conn) []attribute.KeyValue

Client returns attributes for a client network connection to address. See net.Dial for information about acceptable address values, address should be the same as the one used to create conn. If conn is nil, only network peer attributes will be returned that describe address. Otherwise, the socket level information about conn will also be included.

func (*NetConv) Host

func (c *NetConv) Host(address string) []attribute.KeyValue

Host returns attributes for a network host address.

func (*NetConv) HostName

func (c *NetConv) HostName(name string) attribute.KeyValue

func (*NetConv) HostPort

func (c *NetConv) HostPort(port int) attribute.KeyValue

func (*NetConv) Peer

func (c *NetConv) Peer(address string) []attribute.KeyValue

Peer returns attributes for a network peer address.

func (*NetConv) PeerName

func (c *NetConv) PeerName(name string) attribute.KeyValue

func (*NetConv) PeerPort

func (c *NetConv) PeerPort(port int) attribute.KeyValue

func (*NetConv) Server

func (c *NetConv) Server(address string, ln net.Listener) []attribute.KeyValue

Server returns attributes for a network listener listening at address. See net.Listen for information about acceptable address values, address should be the same as the one used to create ln. If ln is nil, only network host attributes will be returned that describe address. Otherwise, the socket level information about ln will also be included.

func (*NetConv) SockPeerAddr

func (c *NetConv) SockPeerAddr(addr string) attribute.KeyValue

func (*NetConv) SockPeerPort

func (c *NetConv) SockPeerPort(port int) attribute.KeyValue

func (*NetConv) Transport

func (c *NetConv) Transport(network string) attribute.KeyValue