Documentation ¶
Index ¶
- Constants
- Variables
- func ClientMiddleware(opts ...Option) client.Middleware
- func Extract(ctx context.Context, c *Config, headers *protocol.RequestHeader) (baggage.Baggage, trace.SpanContext)
- func Inject(ctx context.Context, c *Config, headers *protocol.RequestHeader)
- func SemVersion() string
- func ServerMiddleware(cfg *Config) app.HandlerFunc
- func Version() string
- type Config
- type Option
- type StringHeader
Constants ¶
const ( RequestCount = "http.server.request_count" // Incoming request count total RequestContentLength = "http.server.request_content_length" // Incoming request bytes total ResponseContentLength = "http.server.response_content_length" // Incoming response bytes total ServerLatency = "http.server.duration" // Incoming end to end duration, microseconds )
Server HTTP metrics. ref to https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/http-metrics.md#http-server
const ( ClientLatency = "http.client.duration" ClientRequestSize = "http.client.request.size" ClientResponseSize = "http.client.response.size" )
Client HTTP metrics. ref to https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/http-metrics.md#http-client http.client.duration Histogram milliseconds ms measures the duration outbound HTTP requests http.client.request.size Histogram bytes By measures the size of HTTP request messages (compressed) http.client.response.size Histogram bytes By measures the size of HTTP response messages (compressed)
const ( ReadBytesKey = attribute.Key("http.read_bytes") // if anything was read from the request body, the total number of bytes read ReadErrorKey = attribute.Key("http.read_error") // If an error occurred while reading a request, the string of the error (io.EOF is not recorded) WroteBytesKey = attribute.Key("http.wrote_bytes") // if anything was written to the response writer, the total number of bytes written WriteErrorKey = attribute.Key("http.write_error") // if an error occurred while writing a reply, the string of the error (io.EOF is not recorded) )
Attribute keys that can be added to a span.
const ( // PeerServiceNamespaceKey peer.service.namespace PeerServiceNamespaceKey = attribute.Key("peer.service.namespace") // PeerDeploymentEnvironmentKey peer.deployment.environment PeerDeploymentEnvironmentKey = attribute.Key("peer.deployment.environment") )
const ( // RequestProtocolKey protocol of the request. // // Type: string // Required: Always // Examples: // http: 'http' // rpc: 'grpc', 'java_rmi', 'wcf', 'kitex' // db: mysql, postgresql // mq: 'rabbitmq', 'activemq', 'AmazonSQS' RequestProtocolKey = attribute.Key("request.protocol") )
const (
StatusKey = attribute.Key("status.code")
)
Variables ¶
var ( HTTPMetricsAttributes = []attribute.Key{ semconv.HTTPHostKey, semconv.HTTPRouteKey, semconv.HTTPMethodKey, semconv.HTTPStatusCodeKey, } PeerMetricsAttributes = []attribute.Key{ semconv.PeerServiceKey, PeerServiceNamespaceKey, PeerDeploymentEnvironmentKey, RequestProtocolKey, } // MetricResourceAttributes resource attributes MetricResourceAttributes = []attribute.Key{ semconv.ServiceNameKey, semconv.ServiceNamespaceKey, semconv.DeploymentEnvironmentKey, semconv.ServiceInstanceIDKey, semconv.ServiceVersionKey, semconv.TelemetrySDKLanguageKey, semconv.TelemetrySDKVersionKey, semconv.ProcessPIDKey, semconv.HostNameKey, semconv.HostIDKey, } )
Functions ¶
func ClientMiddleware ¶
func ClientMiddleware(opts ...Option) client.Middleware
func Extract ¶
func Extract(ctx context.Context, c *Config, headers *protocol.RequestHeader) (baggage.Baggage, trace.SpanContext)
Extract returns the baggage and span context
func Inject ¶
func Inject(ctx context.Context, c *Config, headers *protocol.RequestHeader)
Inject injects span context into the hertz metadata info
func SemVersion ¶
func SemVersion() string
func ServerMiddleware ¶
func ServerMiddleware(cfg *Config) app.HandlerFunc
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func NewServerTracer ¶
func NewServerTracer(opts ...Option) (serverconfig.Option, *Config)
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option opts for opentelemetry tracer provider
func WithCustomResponseHandler ¶ added in v0.3.0
func WithCustomResponseHandler(h app.HandlerFunc) Option
WithCustomResponseHandler configures CustomResponseHandler
func WithRecordSourceOperation ¶
WithRecordSourceOperation configures record source operation dimension
func WithTextMapPropagator ¶
func WithTextMapPropagator(p propagation.TextMapPropagator) Option
WithTextMapPropagator configures propagation
type StringHeader ¶
type StringHeader protocol.RequestHeader
func (*StringHeader) Visit ¶
func (sh *StringHeader) Visit(f func(k, v string))
Visit implements the metainfo.HTTPHeaderCarrier interface.