internal
v1.47.0
Documentation
pkg.go.dev ↗Package internal provides common semconv functionality.
Types
HTTPConv
type HTTPConv struct {
NetConv *NetConv
EnduserIDKey attribute.Key
HTTPClientIPKey attribute.Key
HTTPFlavorKey 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
}
HTTPConv are the HTTP semantic convention attributes defined for a version of the OpenTelemetry specification.
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".
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)...)
HTTPConv.ClientStatus
func (*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.
HTTPConv.RequestHeader
func (c *HTTPConv) RequestHeader(h http.Header) []attribute.KeyValue
RequestHeader returns the contents of h as OpenTelemetry attributes.
HTTPConv.ResponseHeader
func (c *HTTPConv) ResponseHeader(h http.Header) []attribute.KeyValue
ResponseHeader returns the contents of h as OpenTelemetry attributes.
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".
HTTPConv.ServerStatus
func (*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.
NetConv
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
}
NetConv are the network semantic convention attributes defined for a version of the OpenTelemetry specification.
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.
NetConv.Host
func (c *NetConv) Host(address string) []attribute.KeyValue
Host returns attributes for a network host address.
NetConv.HostName
func (c *NetConv) HostName(name string) attribute.KeyValue
HostName returns a network host name attribute for name.
NetConv.HostPort
func (c *NetConv) HostPort(port int) attribute.KeyValue
HostPort returns a network host port attribute for port.
NetConv.Peer
func (c *NetConv) Peer(address string) []attribute.KeyValue
Peer returns attributes for a network peer address.
NetConv.PeerName
func (c *NetConv) PeerName(name string) attribute.KeyValue
PeerName returns a network peer name attribute for name.
NetConv.PeerPort
func (c *NetConv) PeerPort(port int) attribute.KeyValue
PeerPort returns a network peer port attribute for port.
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.
NetConv.SockPeerAddr
func (c *NetConv) SockPeerAddr(addr string) attribute.KeyValue
SockPeerAddr returns a network socket peer address attribute for addr.
NetConv.SockPeerPort
func (c *NetConv) SockPeerPort(port int) attribute.KeyValue
SockPeerPort returns a network socket peer port attribute for port.
NetConv.Transport
func (c *NetConv) Transport(network string) attribute.KeyValue
Transport returns a network transport attribute for the given network as returned by net.Dial or similar.