Documentation ¶
Index ¶
- func HTTPClientRequest(req *http.Request) []attribute.KeyValue
- func HTTPClientResponse(resp *http.Response) []attribute.KeyValue
- func HTTPClientStatus(code int) (codes.Code, string)
- func HTTPRequestHeader(h http.Header) []attribute.KeyValue
- func HTTPResponseHeader(h http.Header) []attribute.KeyValue
- func HTTPServerRequest(server string, req *http.Request) []attribute.KeyValue
- func HTTPServerRequestMetrics(server string, req *http.Request) []attribute.KeyValue
- func HTTPServerStatus(code int) (codes.Code, string)
- func NetClient(address string, conn net.Conn) []attribute.KeyValue
- func NetServer(address string, ln net.Listener) []attribute.KeyValue
- func NetTransport(network string) attribute.KeyValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPClientRequest ¶
HTTPClientRequest returns trace 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 HTTPClientResponse ¶
HTTPClientResponse returns trace attributes for an HTTP response received by a client from a server. It will return the following attributes 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(HTTPClientResponse(resp), ClientRequest(resp.Request)...)
func HTTPClientStatus ¶
HTTPClientStatus returns a span status code and message for an HTTP status code value received by a client.
func HTTPRequestHeader ¶
HTTPRequestHeader returns the contents of h as attributes.
Instrumentation should require an explicit configuration of which headers to captured and then prune what they pass here. Including all headers can be a security risk - explicit configuration helps avoid leaking sensitive information.
The User-Agent header is already captured in the http.user_agent attribute from ClientRequest and ServerRequest. Instrumentation may provide an option to capture that header here even though it is not recommended. Otherwise, instrumentation should filter that out of what is passed.
func HTTPResponseHeader ¶
HTTPResponseHeader returns the contents of h as attributes.
Instrumentation should require an explicit configuration of which headers to captured and then prune what they pass here. Including all headers can be a security risk - explicit configuration helps avoid leaking sensitive information.
The User-Agent header is already captured in the http.user_agent attribute from ClientRequest and ServerRequest. Instrumentation may provide an option to capture that header here even though it is not recommended. Otherwise, instrumentation should filter that out of what is passed.
func HTTPServerRequest ¶
HTTPServerRequest 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.
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 HTTPServerRequestMetrics ¶
HTTPServerRequestMetrics returns metric 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", "net.host.name". The following attributes are returned if they related values are defined in req: "net.host.port".
func HTTPServerStatus ¶
HTTPServerStatus 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.
func NetClient ¶
NetClient returns trace 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 NetServer ¶
NetServer returns trace 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 NetTransport ¶
NetTransport returns a trace attribute describing the transport protocol of the passed network. See the net.Dial for information about acceptable network values.
Types ¶
This section is empty.