Documentation ¶
Overview ¶
Package tracing provides the otel tracing & metrics implement of tracer
Index ¶
- Constants
- Variables
- func CGIVariableToHTTPHeaderMetadata(metadata map[string]string) map[string]string
- func ClientMiddleware(cfg *config) endpoint.Middleware
- func Extract(ctx context.Context, c *config, metadata map[string]string) (baggage.Baggage, trace.SpanContext)
- func ExtractFromPropagator(ctx context.Context) map[string]string
- func Inject(ctx context.Context, c *config, metadata map[string]string)
- func NewClientSuite(opts ...Option) *clientSuite
- func NewFramedClientSuite(opts ...Option) *clientSuitedeprecated
- func NewGRPCClientSuite(opts ...Option) *clientSuitedeprecated
- func NewGRPCServerSuite(opts ...Option) *serverSuitedeprecated
- func NewServerSuite(opts ...Option) *serverSuite
- func SemVersion() string
- func ServerMiddleware(cfg *config) endpoint.Middleware
- func Version() string
- type Option
Constants ¶
const ( ServerDuration = "rpc.server.duration" // measures duration of inbound RPC ServerRequestSize = "rpc.server.request.size" // measures size of RPC request messages (uncompressed) ServerResponseSize = "rpc.server.response.size" // measures size of RPC response messages (uncompressed) ServerRequestsPerRPC = "rpc.server.requests_per_rpc" // measures the number of messages received per RPC. Should be 1 for all non-streaming RPCs ServerResponsesPerRPC = "rpc.server.responses_per_rpc" // measures the number of messages sent per RPC. Should be 1 for all non-streaming RPCs )
RPC Server metrics ref to https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc.md#rpc-server
const ( ClientDuration = "rpc.client.duration" // measures duration of outbound RPC ClientRequestSize = "rpc.client.request.size" // measures size of RPC request messages (uncompressed) ClientResponseSize = "rpc.client.response.size" // measures size of RPC response messages (uncompressed) ClientRequestsPerRPC = "rpc.client.requests_per_rpc" // measures the number of messages received per RPC. Should be 1 for all non-streaming RPCs ClientResponsesPerRPC = "rpc.client.responses_per_rpc" // measures the number of messages sent per RPC. Should be 1 for all non-streaming RPCs )
RPC Client metrics ref to https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc.md#rpc-client
const ( // RPCSystemKitexRecvSize recv_size RPCSystemKitexRecvSize = attribute.Key("kitex.recv_size") // RPCSystemKitexSendSize send_size RPCSystemKitexSendSize = attribute.Key("kitex.send_size") )
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 ( // SourceOperationKey source operation // // Type: string // Required: Optional // Examples: '/operation1' SourceOperationKey = attribute.Key("source_operation") )
const (
StatusKey = attribute.Key("status.code")
)
Variables ¶
var ( // RPCMetricsAttributes rpc metrics attributes // ref to https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc.md#attributes RPCMetricsAttributes = []attribute.Key{ semconv.RPCServiceKey, semconv.RPCSystemKey, semconv.RPCMethodKey, semconv.NetPeerNameKey, semconv.NetTransportKey, } PeerMetricsAttributes = []attribute.Key{ semconv.PeerServiceKey, PeerServiceNamespaceKey, PeerDeploymentEnvironmentKey, RequestProtocolKey, SourceOperationKey, } // 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, } )
var RPCSystemKitex = semconv.RPCSystemKey.String("kitex")
RPCSystemKitex Semantic convention for kitex as the remoting system.
Functions ¶
func CGIVariableToHTTPHeaderMetadata ¶
CGIVariableToHTTPHeaderMetadata converts all CGI variable into HTTP header key. For example, `ABC_DEF` will be converted to `abc-def`.
func ClientMiddleware ¶
func ClientMiddleware(cfg *config) endpoint.Middleware
ClientMiddleware inject span context into req meta
func Extract ¶
func Extract(ctx context.Context, c *config, metadata map[string]string) (baggage.Baggage, trace.SpanContext)
Extract returns the baggage and span context
func ExtractFromPropagator ¶ added in v0.2.6
ExtractFromPropagator get metadata from propagator
func NewClientSuite ¶
func NewClientSuite(opts ...Option) *clientSuite
NewClientSuite client suite for otel with http2 and ttheader meta handler
func NewFramedClientSuite
deprecated
func NewFramedClientSuite(opts ...Option) *clientSuite
Deprecated: Use NewClientSuite instead.
func NewGRPCClientSuite
deprecated
func NewGRPCClientSuite(opts ...Option) *clientSuite
Deprecated: Use NewClientSuite instead.
func NewGRPCServerSuite
deprecated
func NewGRPCServerSuite(opts ...Option) *serverSuite
Deprecated: Use NewServerSuite instead.
func NewServerSuite ¶
func NewServerSuite(opts ...Option) *serverSuite
NewServerSuite server suite for otel with http2 and ttheader meta handler
func SemVersion ¶
func SemVersion() string
func ServerMiddleware ¶
func ServerMiddleware(cfg *config) endpoint.Middleware
ServerMiddleware extract req meta into span context
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option opts for opentelemetry tracer provider
func WithEnableGRPCMetadata ¶ added in v0.2.8
func WithEnableGRPCMetadata() Option
WithEnableGRPCMetadata Enable retrieving data from metadata or adding data to metadata
func WithRecordSourceOperation ¶
WithRecordSourceOperation configures record source operation dimension
func WithTextMapPropagator ¶
func WithTextMapPropagator(p propagation.TextMapPropagator) Option
WithTextMapPropagator configures propagation