repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
algolia/algoliasearch-client-go
algolia/internal/opt/get_ranking_info.go
ExtractGetRankingInfo
func ExtractGetRankingInfo(opts ...interface{}) *opt.GetRankingInfoOption { for _, o := range opts { if v, ok := o.(*opt.GetRankingInfoOption); ok { return v } } return nil }
go
func ExtractGetRankingInfo(opts ...interface{}) *opt.GetRankingInfoOption { for _, o := range opts { if v, ok := o.(*opt.GetRankingInfoOption); ok { return v } } return nil }
[ "func", "ExtractGetRankingInfo", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "GetRankingInfoOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "GetRankingIn...
// ExtractGetRankingInfo returns the first found GetRankingInfoOption from the // given variadic arguments or nil otherwise.
[ "ExtractGetRankingInfo", "returns", "the", "first", "found", "GetRankingInfoOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/get_ranking_info.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/opt/explain.go
ExplainEqual
func ExplainEqual(o1, o2 *ExplainOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func ExplainEqual(o1, o2 *ExplainOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "ExplainEqual", "(", "o1", ",", "o2", "*", "ExplainOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "Equal", "(", ...
// ExplainEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "ExplainEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", "defaul...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/explain.go#L58-L66
train
algolia/algoliasearch-client-go
algolia/opt/valid_until.go
UnmarshalJSON
func (o *ValidUntilOption) UnmarshalJSON(data []byte) error { if string(data) == "null" { o.value = time.Time{} return nil } return json.Unmarshal(data, &o.value) }
go
func (o *ValidUntilOption) UnmarshalJSON(data []byte) error { if string(data) == "null" { o.value = time.Time{} return nil } return json.Unmarshal(data, &o.value) }
[ "func", "(", "o", "*", "ValidUntilOption", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "if", "string", "(", "data", ")", "==", "\"null\"", "{", "o", ".", "value", "=", "time", ".", "Time", "{", "}", "\n", "return", "nil"...
// UnmarshalJSON implements the json.Unmarshaler interface for // ValidUntilOption.
[ "UnmarshalJSON", "implements", "the", "json", ".", "Unmarshaler", "interface", "for", "ValidUntilOption", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/valid_until.go#L35-L41
train
algolia/algoliasearch-client-go
algolia/opt/valid_until.go
ValidUntilEqual
func ValidUntilEqual(o1, o2 *ValidUntilOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func ValidUntilEqual(o1, o2 *ValidUntilOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "ValidUntilEqual", "(", "o1", ",", "o2", "*", "ValidUntilOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "Equal", "...
// ValidUntilEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "ValidUntilEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", "def...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/valid_until.go#L56-L64
train
algolia/algoliasearch-client-go
algolia/debug/debug.go
Display
func Display(itf interface{}) { if !debug { return } switch v := itf.(type) { case *http.Request: printRequest(v) case *http.Response: printResponse(v) default: fmt.Printf("do not know how to debug-print %#v\n", v) } }
go
func Display(itf interface{}) { if !debug { return } switch v := itf.(type) { case *http.Request: printRequest(v) case *http.Response: printResponse(v) default: fmt.Printf("do not know how to debug-print %#v\n", v) } }
[ "func", "Display", "(", "itf", "interface", "{", "}", ")", "{", "if", "!", "debug", "{", "return", "\n", "}", "\n", "switch", "v", ":=", "itf", ".", "(", "type", ")", "{", "case", "*", "http", ".", "Request", ":", "printRequest", "(", "v", ")", ...
// Display displays the given parameter on the standard output in a custom way, // depending on the given input type. This function is internally used by the // Algolia API client to display, for instance, HTTP requests and responses when // debug logging is enabled.
[ "Display", "displays", "the", "given", "parameter", "on", "the", "standard", "output", "in", "a", "custom", "way", "depending", "on", "the", "given", "input", "type", ".", "This", "function", "is", "internally", "used", "by", "the", "Algolia", "API", "client...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/debug/debug.go#L33-L45
train
algolia/algoliasearch-client-go
algolia/internal/opt/offset.go
ExtractOffset
func ExtractOffset(opts ...interface{}) *opt.OffsetOption { for _, o := range opts { if v, ok := o.(*opt.OffsetOption); ok { return v } } return nil }
go
func ExtractOffset(opts ...interface{}) *opt.OffsetOption { for _, o := range opts { if v, ok := o.(*opt.OffsetOption); ok { return v } } return nil }
[ "func", "ExtractOffset", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "OffsetOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "OffsetOption", ")", ";",...
// ExtractOffset returns the first found OffsetOption from the // given variadic arguments or nil otherwise.
[ "ExtractOffset", "returns", "the", "first", "found", "OffsetOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/offset.go#L11-L18
train
grpc-ecosystem/go-grpc-prometheus
client_metrics.go
NewClientMetrics
func NewClientMetrics(counterOpts ...CounterOption) *ClientMetrics { opts := counterOptions(counterOpts) return &ClientMetrics{ clientStartedCounter: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_client_started_total", Help: "Total number of RPCs started on the client.", }), []string{"grpc_type", "grpc_service", "grpc_method"}), clientHandledCounter: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_client_handled_total", Help: "Total number of RPCs completed by the client, regardless of success or failure.", }), []string{"grpc_type", "grpc_service", "grpc_method", "grpc_code"}), clientStreamMsgReceived: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_client_msg_received_total", Help: "Total number of RPC stream messages received by the client.", }), []string{"grpc_type", "grpc_service", "grpc_method"}), clientStreamMsgSent: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_client_msg_sent_total", Help: "Total number of gRPC stream messages sent by the client.", }), []string{"grpc_type", "grpc_service", "grpc_method"}), clientHandledHistogramEnabled: false, clientHandledHistogramOpts: prom.HistogramOpts{ Name: "grpc_client_handling_seconds", Help: "Histogram of response latency (seconds) of the gRPC until it is finished by the application.", Buckets: prom.DefBuckets, }, clientHandledHistogram: nil, clientStreamRecvHistogramEnabled: false, clientStreamRecvHistogramOpts: prom.HistogramOpts{ Name: "grpc_client_msg_recv_handling_seconds", Help: "Histogram of response latency (seconds) of the gRPC single message receive.", Buckets: prom.DefBuckets, }, clientStreamRecvHistogram: nil, clientStreamSendHistogramEnabled: false, clientStreamSendHistogramOpts: prom.HistogramOpts{ Name: "grpc_client_msg_send_handling_seconds", Help: "Histogram of response latency (seconds) of the gRPC single message send.", Buckets: prom.DefBuckets, }, clientStreamSendHistogram: nil, } }
go
func NewClientMetrics(counterOpts ...CounterOption) *ClientMetrics { opts := counterOptions(counterOpts) return &ClientMetrics{ clientStartedCounter: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_client_started_total", Help: "Total number of RPCs started on the client.", }), []string{"grpc_type", "grpc_service", "grpc_method"}), clientHandledCounter: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_client_handled_total", Help: "Total number of RPCs completed by the client, regardless of success or failure.", }), []string{"grpc_type", "grpc_service", "grpc_method", "grpc_code"}), clientStreamMsgReceived: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_client_msg_received_total", Help: "Total number of RPC stream messages received by the client.", }), []string{"grpc_type", "grpc_service", "grpc_method"}), clientStreamMsgSent: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_client_msg_sent_total", Help: "Total number of gRPC stream messages sent by the client.", }), []string{"grpc_type", "grpc_service", "grpc_method"}), clientHandledHistogramEnabled: false, clientHandledHistogramOpts: prom.HistogramOpts{ Name: "grpc_client_handling_seconds", Help: "Histogram of response latency (seconds) of the gRPC until it is finished by the application.", Buckets: prom.DefBuckets, }, clientHandledHistogram: nil, clientStreamRecvHistogramEnabled: false, clientStreamRecvHistogramOpts: prom.HistogramOpts{ Name: "grpc_client_msg_recv_handling_seconds", Help: "Histogram of response latency (seconds) of the gRPC single message receive.", Buckets: prom.DefBuckets, }, clientStreamRecvHistogram: nil, clientStreamSendHistogramEnabled: false, clientStreamSendHistogramOpts: prom.HistogramOpts{ Name: "grpc_client_msg_send_handling_seconds", Help: "Histogram of response latency (seconds) of the gRPC single message send.", Buckets: prom.DefBuckets, }, clientStreamSendHistogram: nil, } }
[ "func", "NewClientMetrics", "(", "counterOpts", "...", "CounterOption", ")", "*", "ClientMetrics", "{", "opts", ":=", "counterOptions", "(", "counterOpts", ")", "\n", "return", "&", "ClientMetrics", "{", "clientStartedCounter", ":", "prom", ".", "NewCounterVec", "...
// NewClientMetrics returns a ClientMetrics object. Use a new instance of // ClientMetrics when not using the default Prometheus metrics registry, for // example when wanting to control which metrics are added to a registry as // opposed to automatically adding metrics via init functions.
[ "NewClientMetrics", "returns", "a", "ClientMetrics", "object", ".", "Use", "a", "new", "instance", "of", "ClientMetrics", "when", "not", "using", "the", "default", "Prometheus", "metrics", "registry", "for", "example", "when", "wanting", "to", "control", "which", ...
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/client_metrics.go#L38-L87
train
grpc-ecosystem/go-grpc-prometheus
client_metrics.go
EnableClientHandlingTimeHistogram
func (m *ClientMetrics) EnableClientHandlingTimeHistogram(opts ...HistogramOption) { for _, o := range opts { o(&m.clientHandledHistogramOpts) } if !m.clientHandledHistogramEnabled { m.clientHandledHistogram = prom.NewHistogramVec( m.clientHandledHistogramOpts, []string{"grpc_type", "grpc_service", "grpc_method"}, ) } m.clientHandledHistogramEnabled = true }
go
func (m *ClientMetrics) EnableClientHandlingTimeHistogram(opts ...HistogramOption) { for _, o := range opts { o(&m.clientHandledHistogramOpts) } if !m.clientHandledHistogramEnabled { m.clientHandledHistogram = prom.NewHistogramVec( m.clientHandledHistogramOpts, []string{"grpc_type", "grpc_service", "grpc_method"}, ) } m.clientHandledHistogramEnabled = true }
[ "func", "(", "m", "*", "ClientMetrics", ")", "EnableClientHandlingTimeHistogram", "(", "opts", "...", "HistogramOption", ")", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "o", "(", "&", "m", ".", "clientHandledHistogramOpts", ")", "\n", "}", "\n"...
// EnableClientHandlingTimeHistogram turns on recording of handling time of RPCs. // Histogram metrics can be very expensive for Prometheus to retain and query.
[ "EnableClientHandlingTimeHistogram", "turns", "on", "recording", "of", "handling", "time", "of", "RPCs", ".", "Histogram", "metrics", "can", "be", "very", "expensive", "for", "Prometheus", "to", "retain", "and", "query", "." ]
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/client_metrics.go#L129-L140
train
grpc-ecosystem/go-grpc-prometheus
client_metrics.go
EnableClientStreamReceiveTimeHistogram
func (m *ClientMetrics) EnableClientStreamReceiveTimeHistogram(opts ...HistogramOption) { for _, o := range opts { o(&m.clientStreamRecvHistogramOpts) } if !m.clientStreamRecvHistogramEnabled { m.clientStreamRecvHistogram = prom.NewHistogramVec( m.clientStreamRecvHistogramOpts, []string{"grpc_type", "grpc_service", "grpc_method"}, ) } m.clientStreamRecvHistogramEnabled = true }
go
func (m *ClientMetrics) EnableClientStreamReceiveTimeHistogram(opts ...HistogramOption) { for _, o := range opts { o(&m.clientStreamRecvHistogramOpts) } if !m.clientStreamRecvHistogramEnabled { m.clientStreamRecvHistogram = prom.NewHistogramVec( m.clientStreamRecvHistogramOpts, []string{"grpc_type", "grpc_service", "grpc_method"}, ) } m.clientStreamRecvHistogramEnabled = true }
[ "func", "(", "m", "*", "ClientMetrics", ")", "EnableClientStreamReceiveTimeHistogram", "(", "opts", "...", "HistogramOption", ")", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "o", "(", "&", "m", ".", "clientStreamRecvHistogramOpts", ")", "\n", "}"...
// EnableClientStreamReceiveTimeHistogram turns on recording of single message receive time of streaming RPCs. // Histogram metrics can be very expensive for Prometheus to retain and query.
[ "EnableClientStreamReceiveTimeHistogram", "turns", "on", "recording", "of", "single", "message", "receive", "time", "of", "streaming", "RPCs", ".", "Histogram", "metrics", "can", "be", "very", "expensive", "for", "Prometheus", "to", "retain", "and", "query", "." ]
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/client_metrics.go#L144-L157
train
grpc-ecosystem/go-grpc-prometheus
client_metrics.go
EnableClientStreamSendTimeHistogram
func (m *ClientMetrics) EnableClientStreamSendTimeHistogram(opts ...HistogramOption) { for _, o := range opts { o(&m.clientStreamSendHistogramOpts) } if !m.clientStreamSendHistogramEnabled { m.clientStreamSendHistogram = prom.NewHistogramVec( m.clientStreamSendHistogramOpts, []string{"grpc_type", "grpc_service", "grpc_method"}, ) } m.clientStreamSendHistogramEnabled = true }
go
func (m *ClientMetrics) EnableClientStreamSendTimeHistogram(opts ...HistogramOption) { for _, o := range opts { o(&m.clientStreamSendHistogramOpts) } if !m.clientStreamSendHistogramEnabled { m.clientStreamSendHistogram = prom.NewHistogramVec( m.clientStreamSendHistogramOpts, []string{"grpc_type", "grpc_service", "grpc_method"}, ) } m.clientStreamSendHistogramEnabled = true }
[ "func", "(", "m", "*", "ClientMetrics", ")", "EnableClientStreamSendTimeHistogram", "(", "opts", "...", "HistogramOption", ")", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "o", "(", "&", "m", ".", "clientStreamSendHistogramOpts", ")", "\n", "}", ...
// EnableClientStreamSendTimeHistogram turns on recording of single message send time of streaming RPCs. // Histogram metrics can be very expensive for Prometheus to retain and query.
[ "EnableClientStreamSendTimeHistogram", "turns", "on", "recording", "of", "single", "message", "send", "time", "of", "streaming", "RPCs", ".", "Histogram", "metrics", "can", "be", "very", "expensive", "for", "Prometheus", "to", "retain", "and", "query", "." ]
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/client_metrics.go#L161-L174
train
grpc-ecosystem/go-grpc-prometheus
client_metrics.go
UnaryClientInterceptor
func (m *ClientMetrics) UnaryClientInterceptor() func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { monitor := newClientReporter(m, Unary, method) monitor.SentMessage() err := invoker(ctx, method, req, reply, cc, opts...) if err != nil { monitor.ReceivedMessage() } st, _ := status.FromError(err) monitor.Handled(st.Code()) return err } }
go
func (m *ClientMetrics) UnaryClientInterceptor() func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { monitor := newClientReporter(m, Unary, method) monitor.SentMessage() err := invoker(ctx, method, req, reply, cc, opts...) if err != nil { monitor.ReceivedMessage() } st, _ := status.FromError(err) monitor.Handled(st.Code()) return err } }
[ "func", "(", "m", "*", "ClientMetrics", ")", "UnaryClientInterceptor", "(", ")", "func", "(", "ctx", "context", ".", "Context", ",", "method", "string", ",", "req", ",", "reply", "interface", "{", "}", ",", "cc", "*", "grpc", ".", "ClientConn", ",", "i...
// UnaryClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Unary RPCs.
[ "UnaryClientInterceptor", "is", "a", "gRPC", "client", "-", "side", "interceptor", "that", "provides", "Prometheus", "monitoring", "for", "Unary", "RPCs", "." ]
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/client_metrics.go#L177-L189
train
grpc-ecosystem/go-grpc-prometheus
client_metrics.go
StreamClientInterceptor
func (m *ClientMetrics) StreamClientInterceptor() func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { monitor := newClientReporter(m, clientStreamType(desc), method) clientStream, err := streamer(ctx, desc, cc, method, opts...) if err != nil { st, _ := status.FromError(err) monitor.Handled(st.Code()) return nil, err } return &monitoredClientStream{clientStream, monitor}, nil } }
go
func (m *ClientMetrics) StreamClientInterceptor() func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { monitor := newClientReporter(m, clientStreamType(desc), method) clientStream, err := streamer(ctx, desc, cc, method, opts...) if err != nil { st, _ := status.FromError(err) monitor.Handled(st.Code()) return nil, err } return &monitoredClientStream{clientStream, monitor}, nil } }
[ "func", "(", "m", "*", "ClientMetrics", ")", "StreamClientInterceptor", "(", ")", "func", "(", "ctx", "context", ".", "Context", ",", "desc", "*", "grpc", ".", "StreamDesc", ",", "cc", "*", "grpc", ".", "ClientConn", ",", "method", "string", ",", "stream...
// StreamClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Streaming RPCs.
[ "StreamClientInterceptor", "is", "a", "gRPC", "client", "-", "side", "interceptor", "that", "provides", "Prometheus", "monitoring", "for", "Streaming", "RPCs", "." ]
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/client_metrics.go#L192-L203
train
grpc-ecosystem/go-grpc-prometheus
examples/grpc-server-with-prometheus/server/server.go
SayHello
func (s *DemoServiceServer) SayHello(ctx context.Context, request *pb.HelloRequest) (*pb.HelloResponse, error) { customizedCounterMetric.WithLabelValues(request.Name).Inc() return &pb.HelloResponse{Message: fmt.Sprintf("Hello %s", request.Name)}, nil }
go
func (s *DemoServiceServer) SayHello(ctx context.Context, request *pb.HelloRequest) (*pb.HelloResponse, error) { customizedCounterMetric.WithLabelValues(request.Name).Inc() return &pb.HelloResponse{Message: fmt.Sprintf("Hello %s", request.Name)}, nil }
[ "func", "(", "s", "*", "DemoServiceServer", ")", "SayHello", "(", "ctx", "context", ".", "Context", ",", "request", "*", "pb", ".", "HelloRequest", ")", "(", "*", "pb", ".", "HelloResponse", ",", "error", ")", "{", "customizedCounterMetric", ".", "WithLabe...
// SayHello implements a interface defined by protobuf.
[ "SayHello", "implements", "a", "interface", "defined", "by", "protobuf", "." ]
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/examples/grpc-server-with-prometheus/server/server.go#L26-L29
train
grpc-ecosystem/go-grpc-prometheus
server.go
EnableHandlingTimeHistogram
func EnableHandlingTimeHistogram(opts ...HistogramOption) { DefaultServerMetrics.EnableHandlingTimeHistogram(opts...) prom.Register(DefaultServerMetrics.serverHandledHistogram) }
go
func EnableHandlingTimeHistogram(opts ...HistogramOption) { DefaultServerMetrics.EnableHandlingTimeHistogram(opts...) prom.Register(DefaultServerMetrics.serverHandledHistogram) }
[ "func", "EnableHandlingTimeHistogram", "(", "opts", "...", "HistogramOption", ")", "{", "DefaultServerMetrics", ".", "EnableHandlingTimeHistogram", "(", "opts", "...", ")", "\n", "prom", ".", "Register", "(", "DefaultServerMetrics", ".", "serverHandledHistogram", ")", ...
// EnableHandlingTimeHistogram turns on recording of handling time // of RPCs. Histogram metrics can be very expensive for Prometheus // to retain and query. This function acts on the DefaultServerMetrics // variable and the default Prometheus metrics registry.
[ "EnableHandlingTimeHistogram", "turns", "on", "recording", "of", "handling", "time", "of", "RPCs", ".", "Histogram", "metrics", "can", "be", "very", "expensive", "for", "Prometheus", "to", "retain", "and", "query", ".", "This", "function", "acts", "on", "the", ...
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/server.go#L45-L48
train
grpc-ecosystem/go-grpc-prometheus
server_metrics.go
NewServerMetrics
func NewServerMetrics(counterOpts ...CounterOption) *ServerMetrics { opts := counterOptions(counterOpts) return &ServerMetrics{ serverStartedCounter: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_server_started_total", Help: "Total number of RPCs started on the server.", }), []string{"grpc_type", "grpc_service", "grpc_method"}), serverHandledCounter: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_server_handled_total", Help: "Total number of RPCs completed on the server, regardless of success or failure.", }), []string{"grpc_type", "grpc_service", "grpc_method", "grpc_code"}), serverStreamMsgReceived: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_server_msg_received_total", Help: "Total number of RPC stream messages received on the server.", }), []string{"grpc_type", "grpc_service", "grpc_method"}), serverStreamMsgSent: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_server_msg_sent_total", Help: "Total number of gRPC stream messages sent by the server.", }), []string{"grpc_type", "grpc_service", "grpc_method"}), serverHandledHistogramEnabled: false, serverHandledHistogramOpts: prom.HistogramOpts{ Name: "grpc_server_handling_seconds", Help: "Histogram of response latency (seconds) of gRPC that had been application-level handled by the server.", Buckets: prom.DefBuckets, }, serverHandledHistogram: nil, } }
go
func NewServerMetrics(counterOpts ...CounterOption) *ServerMetrics { opts := counterOptions(counterOpts) return &ServerMetrics{ serverStartedCounter: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_server_started_total", Help: "Total number of RPCs started on the server.", }), []string{"grpc_type", "grpc_service", "grpc_method"}), serverHandledCounter: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_server_handled_total", Help: "Total number of RPCs completed on the server, regardless of success or failure.", }), []string{"grpc_type", "grpc_service", "grpc_method", "grpc_code"}), serverStreamMsgReceived: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_server_msg_received_total", Help: "Total number of RPC stream messages received on the server.", }), []string{"grpc_type", "grpc_service", "grpc_method"}), serverStreamMsgSent: prom.NewCounterVec( opts.apply(prom.CounterOpts{ Name: "grpc_server_msg_sent_total", Help: "Total number of gRPC stream messages sent by the server.", }), []string{"grpc_type", "grpc_service", "grpc_method"}), serverHandledHistogramEnabled: false, serverHandledHistogramOpts: prom.HistogramOpts{ Name: "grpc_server_handling_seconds", Help: "Histogram of response latency (seconds) of gRPC that had been application-level handled by the server.", Buckets: prom.DefBuckets, }, serverHandledHistogram: nil, } }
[ "func", "NewServerMetrics", "(", "counterOpts", "...", "CounterOption", ")", "*", "ServerMetrics", "{", "opts", ":=", "counterOptions", "(", "counterOpts", ")", "\n", "return", "&", "ServerMetrics", "{", "serverStartedCounter", ":", "prom", ".", "NewCounterVec", "...
// NewServerMetrics returns a ServerMetrics object. Use a new instance of // ServerMetrics when not using the default Prometheus metrics registry, for // example when wanting to control which metrics are added to a registry as // opposed to automatically adding metrics via init functions.
[ "NewServerMetrics", "returns", "a", "ServerMetrics", "object", ".", "Use", "a", "new", "instance", "of", "ServerMetrics", "when", "not", "using", "the", "default", "Prometheus", "metrics", "registry", "for", "example", "when", "wanting", "to", "control", "which", ...
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/server_metrics.go#L27-L58
train
grpc-ecosystem/go-grpc-prometheus
server_metrics.go
EnableHandlingTimeHistogram
func (m *ServerMetrics) EnableHandlingTimeHistogram(opts ...HistogramOption) { for _, o := range opts { o(&m.serverHandledHistogramOpts) } if !m.serverHandledHistogramEnabled { m.serverHandledHistogram = prom.NewHistogramVec( m.serverHandledHistogramOpts, []string{"grpc_type", "grpc_service", "grpc_method"}, ) } m.serverHandledHistogramEnabled = true }
go
func (m *ServerMetrics) EnableHandlingTimeHistogram(opts ...HistogramOption) { for _, o := range opts { o(&m.serverHandledHistogramOpts) } if !m.serverHandledHistogramEnabled { m.serverHandledHistogram = prom.NewHistogramVec( m.serverHandledHistogramOpts, []string{"grpc_type", "grpc_service", "grpc_method"}, ) } m.serverHandledHistogramEnabled = true }
[ "func", "(", "m", "*", "ServerMetrics", ")", "EnableHandlingTimeHistogram", "(", "opts", "...", "HistogramOption", ")", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "o", "(", "&", "m", ".", "serverHandledHistogramOpts", ")", "\n", "}", "\n", "i...
// EnableHandlingTimeHistogram enables histograms being registered when // registering the ServerMetrics on a Prometheus registry. Histograms can be // expensive on Prometheus servers. It takes options to configure histogram // options such as the defined buckets.
[ "EnableHandlingTimeHistogram", "enables", "histograms", "being", "registered", "when", "registering", "the", "ServerMetrics", "on", "a", "Prometheus", "registry", ".", "Histograms", "can", "be", "expensive", "on", "Prometheus", "servers", ".", "It", "takes", "options"...
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/server_metrics.go#L64-L75
train
grpc-ecosystem/go-grpc-prometheus
server_metrics.go
UnaryServerInterceptor
func (m *ServerMetrics) UnaryServerInterceptor() func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { monitor := newServerReporter(m, Unary, info.FullMethod) monitor.ReceivedMessage() resp, err := handler(ctx, req) st, _ := status.FromError(err) monitor.Handled(st.Code()) if err == nil { monitor.SentMessage() } return resp, err } }
go
func (m *ServerMetrics) UnaryServerInterceptor() func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { monitor := newServerReporter(m, Unary, info.FullMethod) monitor.ReceivedMessage() resp, err := handler(ctx, req) st, _ := status.FromError(err) monitor.Handled(st.Code()) if err == nil { monitor.SentMessage() } return resp, err } }
[ "func", "(", "m", "*", "ServerMetrics", ")", "UnaryServerInterceptor", "(", ")", "func", "(", "ctx", "context", ".", "Context", ",", "req", "interface", "{", "}", ",", "info", "*", "grpc", ".", "UnaryServerInfo", ",", "handler", "grpc", ".", "UnaryHandler"...
// UnaryServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Unary RPCs.
[ "UnaryServerInterceptor", "is", "a", "gRPC", "server", "-", "side", "interceptor", "that", "provides", "Prometheus", "monitoring", "for", "Unary", "RPCs", "." ]
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/server_metrics.go#L104-L116
train
grpc-ecosystem/go-grpc-prometheus
server_metrics.go
StreamServerInterceptor
func (m *ServerMetrics) StreamServerInterceptor() func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { monitor := newServerReporter(m, streamRPCType(info), info.FullMethod) err := handler(srv, &monitoredServerStream{ss, monitor}) st, _ := status.FromError(err) monitor.Handled(st.Code()) return err } }
go
func (m *ServerMetrics) StreamServerInterceptor() func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { monitor := newServerReporter(m, streamRPCType(info), info.FullMethod) err := handler(srv, &monitoredServerStream{ss, monitor}) st, _ := status.FromError(err) monitor.Handled(st.Code()) return err } }
[ "func", "(", "m", "*", "ServerMetrics", ")", "StreamServerInterceptor", "(", ")", "func", "(", "srv", "interface", "{", "}", ",", "ss", "grpc", ".", "ServerStream", ",", "info", "*", "grpc", ".", "StreamServerInfo", ",", "handler", "grpc", ".", "StreamHand...
// StreamServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Streaming RPCs.
[ "StreamServerInterceptor", "is", "a", "gRPC", "server", "-", "side", "interceptor", "that", "provides", "Prometheus", "monitoring", "for", "Streaming", "RPCs", "." ]
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/server_metrics.go#L119-L127
train
grpc-ecosystem/go-grpc-prometheus
server_metrics.go
InitializeMetrics
func (m *ServerMetrics) InitializeMetrics(server *grpc.Server) { serviceInfo := server.GetServiceInfo() for serviceName, info := range serviceInfo { for _, mInfo := range info.Methods { preRegisterMethod(m, serviceName, &mInfo) } } }
go
func (m *ServerMetrics) InitializeMetrics(server *grpc.Server) { serviceInfo := server.GetServiceInfo() for serviceName, info := range serviceInfo { for _, mInfo := range info.Methods { preRegisterMethod(m, serviceName, &mInfo) } } }
[ "func", "(", "m", "*", "ServerMetrics", ")", "InitializeMetrics", "(", "server", "*", "grpc", ".", "Server", ")", "{", "serviceInfo", ":=", "server", ".", "GetServiceInfo", "(", ")", "\n", "for", "serviceName", ",", "info", ":=", "range", "serviceInfo", "{...
// InitializeMetrics initializes all metrics, with their appropriate null // value, for all gRPC methods registered on a gRPC server. This is useful, to // ensure that all metrics exist when collecting and querying.
[ "InitializeMetrics", "initializes", "all", "metrics", "with", "their", "appropriate", "null", "value", "for", "all", "gRPC", "methods", "registered", "on", "a", "gRPC", "server", ".", "This", "is", "useful", "to", "ensure", "that", "all", "metrics", "exist", "...
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/server_metrics.go#L132-L139
train
grpc-ecosystem/go-grpc-prometheus
server_metrics.go
preRegisterMethod
func preRegisterMethod(metrics *ServerMetrics, serviceName string, mInfo *grpc.MethodInfo) { methodName := mInfo.Name methodType := string(typeFromMethodInfo(mInfo)) // These are just references (no increments), as just referencing will create the labels but not set values. metrics.serverStartedCounter.GetMetricWithLabelValues(methodType, serviceName, methodName) metrics.serverStreamMsgReceived.GetMetricWithLabelValues(methodType, serviceName, methodName) metrics.serverStreamMsgSent.GetMetricWithLabelValues(methodType, serviceName, methodName) if metrics.serverHandledHistogramEnabled { metrics.serverHandledHistogram.GetMetricWithLabelValues(methodType, serviceName, methodName) } for _, code := range allCodes { metrics.serverHandledCounter.GetMetricWithLabelValues(methodType, serviceName, methodName, code.String()) } }
go
func preRegisterMethod(metrics *ServerMetrics, serviceName string, mInfo *grpc.MethodInfo) { methodName := mInfo.Name methodType := string(typeFromMethodInfo(mInfo)) // These are just references (no increments), as just referencing will create the labels but not set values. metrics.serverStartedCounter.GetMetricWithLabelValues(methodType, serviceName, methodName) metrics.serverStreamMsgReceived.GetMetricWithLabelValues(methodType, serviceName, methodName) metrics.serverStreamMsgSent.GetMetricWithLabelValues(methodType, serviceName, methodName) if metrics.serverHandledHistogramEnabled { metrics.serverHandledHistogram.GetMetricWithLabelValues(methodType, serviceName, methodName) } for _, code := range allCodes { metrics.serverHandledCounter.GetMetricWithLabelValues(methodType, serviceName, methodName, code.String()) } }
[ "func", "preRegisterMethod", "(", "metrics", "*", "ServerMetrics", ",", "serviceName", "string", ",", "mInfo", "*", "grpc", ".", "MethodInfo", ")", "{", "methodName", ":=", "mInfo", ".", "Name", "\n", "methodType", ":=", "string", "(", "typeFromMethodInfo", "(...
// preRegisterMethod is invoked on Register of a Server, allowing all gRPC services labels to be pre-populated.
[ "preRegisterMethod", "is", "invoked", "on", "Register", "of", "a", "Server", "allowing", "all", "gRPC", "services", "labels", "to", "be", "pre", "-", "populated", "." ]
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/server_metrics.go#L173-L186
train
grpc-ecosystem/go-grpc-prometheus
client.go
EnableClientHandlingTimeHistogram
func EnableClientHandlingTimeHistogram(opts ...HistogramOption) { DefaultClientMetrics.EnableClientHandlingTimeHistogram(opts...) prom.Register(DefaultClientMetrics.clientHandledHistogram) }
go
func EnableClientHandlingTimeHistogram(opts ...HistogramOption) { DefaultClientMetrics.EnableClientHandlingTimeHistogram(opts...) prom.Register(DefaultClientMetrics.clientHandledHistogram) }
[ "func", "EnableClientHandlingTimeHistogram", "(", "opts", "...", "HistogramOption", ")", "{", "DefaultClientMetrics", ".", "EnableClientHandlingTimeHistogram", "(", "opts", "...", ")", "\n", "prom", ".", "Register", "(", "DefaultClientMetrics", ".", "clientHandledHistogra...
// EnableClientHandlingTimeHistogram turns on recording of handling time of // RPCs. Histogram metrics can be very expensive for Prometheus to retain and // query. This function acts on the DefaultClientMetrics variable and the // default Prometheus metrics registry.
[ "EnableClientHandlingTimeHistogram", "turns", "on", "recording", "of", "handling", "time", "of", "RPCs", ".", "Histogram", "metrics", "can", "be", "very", "expensive", "for", "Prometheus", "to", "retain", "and", "query", ".", "This", "function", "acts", "on", "t...
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/client.go#L36-L39
train
grpc-ecosystem/go-grpc-prometheus
client.go
EnableClientStreamReceiveTimeHistogram
func EnableClientStreamReceiveTimeHistogram(opts ...HistogramOption) { DefaultClientMetrics.EnableClientStreamReceiveTimeHistogram(opts...) prom.Register(DefaultClientMetrics.clientStreamRecvHistogram) }
go
func EnableClientStreamReceiveTimeHistogram(opts ...HistogramOption) { DefaultClientMetrics.EnableClientStreamReceiveTimeHistogram(opts...) prom.Register(DefaultClientMetrics.clientStreamRecvHistogram) }
[ "func", "EnableClientStreamReceiveTimeHistogram", "(", "opts", "...", "HistogramOption", ")", "{", "DefaultClientMetrics", ".", "EnableClientStreamReceiveTimeHistogram", "(", "opts", "...", ")", "\n", "prom", ".", "Register", "(", "DefaultClientMetrics", ".", "clientStrea...
// EnableClientStreamReceiveTimeHistogram turns on recording of // single message receive time of streaming RPCs. // This function acts on the DefaultClientMetrics variable and the // default Prometheus metrics registry.
[ "EnableClientStreamReceiveTimeHistogram", "turns", "on", "recording", "of", "single", "message", "receive", "time", "of", "streaming", "RPCs", ".", "This", "function", "acts", "on", "the", "DefaultClientMetrics", "variable", "and", "the", "default", "Prometheus", "met...
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/client.go#L45-L48
train
grpc-ecosystem/go-grpc-prometheus
client.go
EnableClientStreamSendTimeHistogram
func EnableClientStreamSendTimeHistogram(opts ...HistogramOption) { DefaultClientMetrics.EnableClientStreamSendTimeHistogram(opts...) prom.Register(DefaultClientMetrics.clientStreamSendHistogram) }
go
func EnableClientStreamSendTimeHistogram(opts ...HistogramOption) { DefaultClientMetrics.EnableClientStreamSendTimeHistogram(opts...) prom.Register(DefaultClientMetrics.clientStreamSendHistogram) }
[ "func", "EnableClientStreamSendTimeHistogram", "(", "opts", "...", "HistogramOption", ")", "{", "DefaultClientMetrics", ".", "EnableClientStreamSendTimeHistogram", "(", "opts", "...", ")", "\n", "prom", ".", "Register", "(", "DefaultClientMetrics", ".", "clientStreamSendH...
// EnableClientStreamReceiveTimeHistogram turns on recording of // single message send time of streaming RPCs. // This function acts on the DefaultClientMetrics variable and the // default Prometheus metrics registry.
[ "EnableClientStreamReceiveTimeHistogram", "turns", "on", "recording", "of", "single", "message", "send", "time", "of", "streaming", "RPCs", ".", "This", "function", "acts", "on", "the", "DefaultClientMetrics", "variable", "and", "the", "default", "Prometheus", "metric...
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/client.go#L54-L57
train
grpc-ecosystem/go-grpc-prometheus
metric_options.go
WithConstLabels
func WithConstLabels(labels prom.Labels) CounterOption { return func(o *prom.CounterOpts) { o.ConstLabels = labels } }
go
func WithConstLabels(labels prom.Labels) CounterOption { return func(o *prom.CounterOpts) { o.ConstLabels = labels } }
[ "func", "WithConstLabels", "(", "labels", "prom", ".", "Labels", ")", "CounterOption", "{", "return", "func", "(", "o", "*", "prom", ".", "CounterOpts", ")", "{", "o", ".", "ConstLabels", "=", "labels", "\n", "}", "\n", "}" ]
// WithConstLabels allows you to add ConstLabels to Counter metrics.
[ "WithConstLabels", "allows", "you", "to", "add", "ConstLabels", "to", "Counter", "metrics", "." ]
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/metric_options.go#L20-L24
train
grpc-ecosystem/go-grpc-prometheus
metric_options.go
WithHistogramBuckets
func WithHistogramBuckets(buckets []float64) HistogramOption { return func(o *prom.HistogramOpts) { o.Buckets = buckets } }
go
func WithHistogramBuckets(buckets []float64) HistogramOption { return func(o *prom.HistogramOpts) { o.Buckets = buckets } }
[ "func", "WithHistogramBuckets", "(", "buckets", "[", "]", "float64", ")", "HistogramOption", "{", "return", "func", "(", "o", "*", "prom", ".", "HistogramOpts", ")", "{", "o", ".", "Buckets", "=", "buckets", "}", "\n", "}" ]
// WithHistogramBuckets allows you to specify custom bucket ranges for histograms if EnableHandlingTimeHistogram is on.
[ "WithHistogramBuckets", "allows", "you", "to", "specify", "custom", "bucket", "ranges", "for", "histograms", "if", "EnableHandlingTimeHistogram", "is", "on", "." ]
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/metric_options.go#L31-L33
train
grpc-ecosystem/go-grpc-prometheus
metric_options.go
WithHistogramConstLabels
func WithHistogramConstLabels(labels prom.Labels) HistogramOption { return func(o *prom.HistogramOpts) { o.ConstLabels = labels } }
go
func WithHistogramConstLabels(labels prom.Labels) HistogramOption { return func(o *prom.HistogramOpts) { o.ConstLabels = labels } }
[ "func", "WithHistogramConstLabels", "(", "labels", "prom", ".", "Labels", ")", "HistogramOption", "{", "return", "func", "(", "o", "*", "prom", ".", "HistogramOpts", ")", "{", "o", ".", "ConstLabels", "=", "labels", "\n", "}", "\n", "}" ]
// WithHistogramConstLabels allows you to add custom ConstLabels to // histograms metrics.
[ "WithHistogramConstLabels", "allows", "you", "to", "add", "custom", "ConstLabels", "to", "histograms", "metrics", "." ]
ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
https://github.com/grpc-ecosystem/go-grpc-prometheus/blob/ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da/metric_options.go#L37-L41
train
jaegertracing/jaeger-client-go
metrics.go
NewMetrics
func NewMetrics(factory metrics.Factory, globalTags map[string]string) *Metrics { m := &Metrics{} // TODO the namespace "jaeger" should be configurable metrics.MustInit(m, factory.Namespace(metrics.NSOptions{Name: "jaeger"}).Namespace(metrics.NSOptions{Name: "tracer"}), globalTags) return m }
go
func NewMetrics(factory metrics.Factory, globalTags map[string]string) *Metrics { m := &Metrics{} // TODO the namespace "jaeger" should be configurable metrics.MustInit(m, factory.Namespace(metrics.NSOptions{Name: "jaeger"}).Namespace(metrics.NSOptions{Name: "tracer"}), globalTags) return m }
[ "func", "NewMetrics", "(", "factory", "metrics", ".", "Factory", ",", "globalTags", "map", "[", "string", "]", "string", ")", "*", "Metrics", "{", "m", ":=", "&", "Metrics", "{", "}", "\n", "metrics", ".", "MustInit", "(", "m", ",", "factory", ".", "...
// NewMetrics creates a new Metrics struct and initializes it.
[ "NewMetrics", "creates", "a", "new", "Metrics", "struct", "and", "initializes", "it", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/metrics.go#L97-L102
train
jaegertracing/jaeger-client-go
rpcmetrics/metrics.go
getWithWriteLock
func (m *MetricsByEndpoint) getWithWriteLock(safeName string) *Metrics { m.mux.Lock() defer m.mux.Unlock() // it is possible that the name has been already registered after we released // the read lock and before we grabbed the write lock, so check for that. if met, ok := m.metricsByEndpoint[safeName]; ok { return met } // it would be nice to create the struct before locking, since Init() is somewhat // expensive, however some metrics backends (e.g. expvar) may not like duplicate metrics. met := &Metrics{} tags := map[string]string{endpointNameMetricTag: safeName} metrics.Init(met, m.metricsFactory, tags) m.metricsByEndpoint[safeName] = met return met }
go
func (m *MetricsByEndpoint) getWithWriteLock(safeName string) *Metrics { m.mux.Lock() defer m.mux.Unlock() // it is possible that the name has been already registered after we released // the read lock and before we grabbed the write lock, so check for that. if met, ok := m.metricsByEndpoint[safeName]; ok { return met } // it would be nice to create the struct before locking, since Init() is somewhat // expensive, however some metrics backends (e.g. expvar) may not like duplicate metrics. met := &Metrics{} tags := map[string]string{endpointNameMetricTag: safeName} metrics.Init(met, m.metricsFactory, tags) m.metricsByEndpoint[safeName] = met return met }
[ "func", "(", "m", "*", "MetricsByEndpoint", ")", "getWithWriteLock", "(", "safeName", "string", ")", "*", "Metrics", "{", "m", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "mux", ".", "Unlock", "(", ")", "\n", "if", "met", ",", "ok",...
// split to make easier to test
[ "split", "to", "make", "easier", "to", "test" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/rpcmetrics/metrics.go#L106-L124
train
jaegertracing/jaeger-client-go
internal/baggage/remote/restriction_manager.go
NewRestrictionManager
func NewRestrictionManager(serviceName string, options ...Option) *RestrictionManager { // TODO there is a developing use case where a single tracer can generate traces on behalf of many services. // restrictionsMap will need to exist per service opts := applyOptions(options...) m := &RestrictionManager{ serviceName: serviceName, options: opts, restrictions: make(map[string]*baggage.Restriction), thriftProxy: newHTTPBaggageRestrictionManagerProxy(opts.hostPort, serviceName), stopPoll: make(chan struct{}), invalidRestriction: baggage.NewRestriction(false, 0), validRestriction: baggage.NewRestriction(true, defaultMaxValueLength), } m.pollStopped.Add(1) go m.pollManager() return m }
go
func NewRestrictionManager(serviceName string, options ...Option) *RestrictionManager { // TODO there is a developing use case where a single tracer can generate traces on behalf of many services. // restrictionsMap will need to exist per service opts := applyOptions(options...) m := &RestrictionManager{ serviceName: serviceName, options: opts, restrictions: make(map[string]*baggage.Restriction), thriftProxy: newHTTPBaggageRestrictionManagerProxy(opts.hostPort, serviceName), stopPoll: make(chan struct{}), invalidRestriction: baggage.NewRestriction(false, 0), validRestriction: baggage.NewRestriction(true, defaultMaxValueLength), } m.pollStopped.Add(1) go m.pollManager() return m }
[ "func", "NewRestrictionManager", "(", "serviceName", "string", ",", "options", "...", "Option", ")", "*", "RestrictionManager", "{", "opts", ":=", "applyOptions", "(", "options", "...", ")", "\n", "m", ":=", "&", "RestrictionManager", "{", "serviceName", ":", ...
// NewRestrictionManager returns a BaggageRestrictionManager that polls the agent for the latest // baggage restrictions.
[ "NewRestrictionManager", "returns", "a", "BaggageRestrictionManager", "that", "polls", "the", "agent", "for", "the", "latest", "baggage", "restrictions", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/baggage/remote/restriction_manager.go#L67-L83
train
jaegertracing/jaeger-client-go
internal/baggage/remote/restriction_manager.go
isReady
func (m *RestrictionManager) isReady() bool { m.mux.RLock() defer m.mux.RUnlock() return m.initialized }
go
func (m *RestrictionManager) isReady() bool { m.mux.RLock() defer m.mux.RUnlock() return m.initialized }
[ "func", "(", "m", "*", "RestrictionManager", ")", "isReady", "(", ")", "bool", "{", "m", ".", "mux", ".", "RLock", "(", ")", "\n", "defer", "m", ".", "mux", ".", "RUnlock", "(", ")", "\n", "return", "m", ".", "initialized", "\n", "}" ]
// isReady returns true if the manager has retrieved baggage restrictions from the remote source.
[ "isReady", "returns", "true", "if", "the", "manager", "has", "retrieved", "baggage", "restrictions", "from", "the", "remote", "source", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/baggage/remote/restriction_manager.go#L86-L90
train
jaegertracing/jaeger-client-go
internal/baggage/remote/restriction_manager.go
Close
func (m *RestrictionManager) Close() error { close(m.stopPoll) m.pollStopped.Wait() return nil }
go
func (m *RestrictionManager) Close() error { close(m.stopPoll) m.pollStopped.Wait() return nil }
[ "func", "(", "m", "*", "RestrictionManager", ")", "Close", "(", ")", "error", "{", "close", "(", "m", ".", "stopPoll", ")", "\n", "m", ".", "pollStopped", ".", "Wait", "(", ")", "\n", "return", "nil", "\n", "}" ]
// Close stops remote polling and closes the RemoteRestrictionManager.
[ "Close", "stops", "remote", "polling", "and", "closes", "the", "RemoteRestrictionManager", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/baggage/remote/restriction_manager.go#L109-L113
train
jaegertracing/jaeger-client-go
transport_udp.go
NewUDPTransport
func NewUDPTransport(hostPort string, maxPacketSize int) (Transport, error) { if len(hostPort) == 0 { hostPort = fmt.Sprintf("%s:%d", DefaultUDPSpanServerHost, DefaultUDPSpanServerPort) } if maxPacketSize == 0 { maxPacketSize = utils.UDPPacketMaxLength } protocolFactory := thrift.NewTCompactProtocolFactory() // Each span is first written to thriftBuffer to determine its size in bytes. thriftBuffer := thrift.NewTMemoryBufferLen(maxPacketSize) thriftProtocol := protocolFactory.GetProtocol(thriftBuffer) client, err := utils.NewAgentClientUDP(hostPort, maxPacketSize) if err != nil { return nil, err } sender := &udpSender{ client: client, maxSpanBytes: maxPacketSize - emitBatchOverhead, thriftBuffer: thriftBuffer, thriftProtocol: thriftProtocol} return sender, nil }
go
func NewUDPTransport(hostPort string, maxPacketSize int) (Transport, error) { if len(hostPort) == 0 { hostPort = fmt.Sprintf("%s:%d", DefaultUDPSpanServerHost, DefaultUDPSpanServerPort) } if maxPacketSize == 0 { maxPacketSize = utils.UDPPacketMaxLength } protocolFactory := thrift.NewTCompactProtocolFactory() // Each span is first written to thriftBuffer to determine its size in bytes. thriftBuffer := thrift.NewTMemoryBufferLen(maxPacketSize) thriftProtocol := protocolFactory.GetProtocol(thriftBuffer) client, err := utils.NewAgentClientUDP(hostPort, maxPacketSize) if err != nil { return nil, err } sender := &udpSender{ client: client, maxSpanBytes: maxPacketSize - emitBatchOverhead, thriftBuffer: thriftBuffer, thriftProtocol: thriftProtocol} return sender, nil }
[ "func", "NewUDPTransport", "(", "hostPort", "string", ",", "maxPacketSize", "int", ")", "(", "Transport", ",", "error", ")", "{", "if", "len", "(", "hostPort", ")", "==", "0", "{", "hostPort", "=", "fmt", ".", "Sprintf", "(", "\"%s:%d\"", ",", "DefaultUD...
// NewUDPTransport creates a reporter that submits spans to jaeger-agent
[ "NewUDPTransport", "creates", "a", "reporter", "that", "submits", "spans", "to", "jaeger", "-", "agent" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/transport_udp.go#L50-L75
train
jaegertracing/jaeger-client-go
internal/baggage/restriction_manager.go
NewRestriction
func NewRestriction(keyAllowed bool, maxValueLength int) *Restriction { return &Restriction{ keyAllowed: keyAllowed, maxValueLength: maxValueLength, } }
go
func NewRestriction(keyAllowed bool, maxValueLength int) *Restriction { return &Restriction{ keyAllowed: keyAllowed, maxValueLength: maxValueLength, } }
[ "func", "NewRestriction", "(", "keyAllowed", "bool", ",", "maxValueLength", "int", ")", "*", "Restriction", "{", "return", "&", "Restriction", "{", "keyAllowed", ":", "keyAllowed", ",", "maxValueLength", ":", "maxValueLength", ",", "}", "\n", "}" ]
// NewRestriction returns a new Restriction.
[ "NewRestriction", "returns", "a", "new", "Restriction", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/baggage/restriction_manager.go#L28-L33
train
jaegertracing/jaeger-client-go
internal/baggage/restriction_manager.go
NewDefaultRestrictionManager
func NewDefaultRestrictionManager(maxValueLength int) *DefaultRestrictionManager { if maxValueLength == 0 { maxValueLength = defaultMaxValueLength } return &DefaultRestrictionManager{ defaultRestriction: &Restriction{keyAllowed: true, maxValueLength: maxValueLength}, } }
go
func NewDefaultRestrictionManager(maxValueLength int) *DefaultRestrictionManager { if maxValueLength == 0 { maxValueLength = defaultMaxValueLength } return &DefaultRestrictionManager{ defaultRestriction: &Restriction{keyAllowed: true, maxValueLength: maxValueLength}, } }
[ "func", "NewDefaultRestrictionManager", "(", "maxValueLength", "int", ")", "*", "DefaultRestrictionManager", "{", "if", "maxValueLength", "==", "0", "{", "maxValueLength", "=", "defaultMaxValueLength", "\n", "}", "\n", "return", "&", "DefaultRestrictionManager", "{", ...
// NewDefaultRestrictionManager returns a DefaultRestrictionManager.
[ "NewDefaultRestrictionManager", "returns", "a", "DefaultRestrictionManager", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/baggage/restriction_manager.go#L59-L66
train
jaegertracing/jaeger-client-go
transport/http.go
HTTPBasicAuth
func HTTPBasicAuth(username string, password string) HTTPOption { return func(c *HTTPTransport) { c.httpCredentials = &HTTPBasicAuthCredentials{username: username, password: password} } }
go
func HTTPBasicAuth(username string, password string) HTTPOption { return func(c *HTTPTransport) { c.httpCredentials = &HTTPBasicAuthCredentials{username: username, password: password} } }
[ "func", "HTTPBasicAuth", "(", "username", "string", ",", "password", "string", ")", "HTTPOption", "{", "return", "func", "(", "c", "*", "HTTPTransport", ")", "{", "c", ".", "httpCredentials", "=", "&", "HTTPBasicAuthCredentials", "{", "username", ":", "usernam...
// HTTPBasicAuth sets the credentials required to perform HTTP basic auth
[ "HTTPBasicAuth", "sets", "the", "credentials", "required", "to", "perform", "HTTP", "basic", "auth" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/transport/http.go#L65-L69
train
jaegertracing/jaeger-client-go
context.go
ContextFromString
func ContextFromString(value string) (SpanContext, error) { var context SpanContext if value == "" { return emptyContext, errEmptyTracerStateString } parts := strings.Split(value, ":") if len(parts) != 4 { return emptyContext, errMalformedTracerStateString } var err error if context.traceID, err = TraceIDFromString(parts[0]); err != nil { return emptyContext, err } if context.spanID, err = SpanIDFromString(parts[1]); err != nil { return emptyContext, err } if context.parentID, err = SpanIDFromString(parts[2]); err != nil { return emptyContext, err } flags, err := strconv.ParseUint(parts[3], 10, 8) if err != nil { return emptyContext, err } context.flags = byte(flags) return context, nil }
go
func ContextFromString(value string) (SpanContext, error) { var context SpanContext if value == "" { return emptyContext, errEmptyTracerStateString } parts := strings.Split(value, ":") if len(parts) != 4 { return emptyContext, errMalformedTracerStateString } var err error if context.traceID, err = TraceIDFromString(parts[0]); err != nil { return emptyContext, err } if context.spanID, err = SpanIDFromString(parts[1]); err != nil { return emptyContext, err } if context.parentID, err = SpanIDFromString(parts[2]); err != nil { return emptyContext, err } flags, err := strconv.ParseUint(parts[3], 10, 8) if err != nil { return emptyContext, err } context.flags = byte(flags) return context, nil }
[ "func", "ContextFromString", "(", "value", "string", ")", "(", "SpanContext", ",", "error", ")", "{", "var", "context", "SpanContext", "\n", "if", "value", "==", "\"\"", "{", "return", "emptyContext", ",", "errEmptyTracerStateString", "\n", "}", "\n", "parts",...
// ContextFromString reconstructs the Context encoded in a string
[ "ContextFromString", "reconstructs", "the", "Context", "encoded", "in", "a", "string" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/context.go#L104-L129
train
jaegertracing/jaeger-client-go
context.go
NewSpanContext
func NewSpanContext(traceID TraceID, spanID, parentID SpanID, sampled bool, baggage map[string]string) SpanContext { flags := byte(0) if sampled { flags = flagSampled } return SpanContext{ traceID: traceID, spanID: spanID, parentID: parentID, flags: flags, baggage: baggage} }
go
func NewSpanContext(traceID TraceID, spanID, parentID SpanID, sampled bool, baggage map[string]string) SpanContext { flags := byte(0) if sampled { flags = flagSampled } return SpanContext{ traceID: traceID, spanID: spanID, parentID: parentID, flags: flags, baggage: baggage} }
[ "func", "NewSpanContext", "(", "traceID", "TraceID", ",", "spanID", ",", "parentID", "SpanID", ",", "sampled", "bool", ",", "baggage", "map", "[", "string", "]", "string", ")", "SpanContext", "{", "flags", ":=", "byte", "(", "0", ")", "\n", "if", "sample...
// NewSpanContext creates a new instance of SpanContext
[ "NewSpanContext", "creates", "a", "new", "instance", "of", "SpanContext" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/context.go#L147-L158
train
jaegertracing/jaeger-client-go
context.go
WithBaggageItem
func (c SpanContext) WithBaggageItem(key, value string) SpanContext { var newBaggage map[string]string if c.baggage == nil { newBaggage = map[string]string{key: value} } else { newBaggage = make(map[string]string, len(c.baggage)+1) for k, v := range c.baggage { newBaggage[k] = v } newBaggage[key] = value } // Use positional parameters so the compiler will help catch new fields. return SpanContext{c.traceID, c.spanID, c.parentID, c.flags, newBaggage, ""} }
go
func (c SpanContext) WithBaggageItem(key, value string) SpanContext { var newBaggage map[string]string if c.baggage == nil { newBaggage = map[string]string{key: value} } else { newBaggage = make(map[string]string, len(c.baggage)+1) for k, v := range c.baggage { newBaggage[k] = v } newBaggage[key] = value } // Use positional parameters so the compiler will help catch new fields. return SpanContext{c.traceID, c.spanID, c.parentID, c.flags, newBaggage, ""} }
[ "func", "(", "c", "SpanContext", ")", "WithBaggageItem", "(", "key", ",", "value", "string", ")", "SpanContext", "{", "var", "newBaggage", "map", "[", "string", "]", "string", "\n", "if", "c", ".", "baggage", "==", "nil", "{", "newBaggage", "=", "map", ...
// WithBaggageItem creates a new context with an extra baggage item.
[ "WithBaggageItem", "creates", "a", "new", "context", "with", "an", "extra", "baggage", "item", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/context.go#L178-L191
train
jaegertracing/jaeger-client-go
context.go
SpanIDFromString
func SpanIDFromString(s string) (SpanID, error) { if len(s) > 16 { return SpanID(0), fmt.Errorf("SpanID cannot be longer than 16 hex characters: %s", s) } id, err := strconv.ParseUint(s, 16, 64) if err != nil { return SpanID(0), err } return SpanID(id), nil }
go
func SpanIDFromString(s string) (SpanID, error) { if len(s) > 16 { return SpanID(0), fmt.Errorf("SpanID cannot be longer than 16 hex characters: %s", s) } id, err := strconv.ParseUint(s, 16, 64) if err != nil { return SpanID(0), err } return SpanID(id), nil }
[ "func", "SpanIDFromString", "(", "s", "string", ")", "(", "SpanID", ",", "error", ")", "{", "if", "len", "(", "s", ")", ">", "16", "{", "return", "SpanID", "(", "0", ")", ",", "fmt", ".", "Errorf", "(", "\"SpanID cannot be longer than 16 hex characters: %s...
// SpanIDFromString creates a SpanID from a hexadecimal string
[ "SpanIDFromString", "creates", "a", "SpanID", "from", "a", "hexadecimal", "string" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/context.go#L249-L258
train
jaegertracing/jaeger-client-go
utils/utils.go
ParsePort
func ParsePort(portString string) (uint16, error) { port, err := strconv.ParseUint(portString, 10, 16) return uint16(port), err }
go
func ParsePort(portString string) (uint16, error) { port, err := strconv.ParseUint(portString, 10, 16) return uint16(port), err }
[ "func", "ParsePort", "(", "portString", "string", ")", "(", "uint16", ",", "error", ")", "{", "port", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "portString", ",", "10", ",", "16", ")", "\n", "return", "uint16", "(", "port", ")", ",", "err",...
// ParsePort converts port number from string to uin16
[ "ParsePort", "converts", "port", "number", "from", "string", "to", "uin16" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/utils/utils.go#L65-L68
train
jaegertracing/jaeger-client-go
utils/utils.go
PackIPAsUint32
func PackIPAsUint32(ip net.IP) uint32 { if ipv4 := ip.To4(); ipv4 != nil { return binary.BigEndian.Uint32(ipv4) } return 0 }
go
func PackIPAsUint32(ip net.IP) uint32 { if ipv4 := ip.To4(); ipv4 != nil { return binary.BigEndian.Uint32(ipv4) } return 0 }
[ "func", "PackIPAsUint32", "(", "ip", "net", ".", "IP", ")", "uint32", "{", "if", "ipv4", ":=", "ip", ".", "To4", "(", ")", ";", "ipv4", "!=", "nil", "{", "return", "binary", ".", "BigEndian", ".", "Uint32", "(", "ipv4", ")", "\n", "}", "\n", "ret...
// PackIPAsUint32 packs an IPv4 as uint32
[ "PackIPAsUint32", "packs", "an", "IPv4", "as", "uint32" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/utils/utils.go#L71-L76
train
jaegertracing/jaeger-client-go
jaeger_tag.go
ConvertLogsToJaegerTags
func ConvertLogsToJaegerTags(logFields []log.Field) []*j.Tag { fields := tags(make([]*j.Tag, 0, len(logFields))) for _, field := range logFields { field.Marshal(&fields) } return fields }
go
func ConvertLogsToJaegerTags(logFields []log.Field) []*j.Tag { fields := tags(make([]*j.Tag, 0, len(logFields))) for _, field := range logFields { field.Marshal(&fields) } return fields }
[ "func", "ConvertLogsToJaegerTags", "(", "logFields", "[", "]", "log", ".", "Field", ")", "[", "]", "*", "j", ".", "Tag", "{", "fields", ":=", "tags", "(", "make", "(", "[", "]", "*", "j", ".", "Tag", ",", "0", ",", "len", "(", "logFields", ")", ...
// ConvertLogsToJaegerTags converts log Fields into jaeger tags.
[ "ConvertLogsToJaegerTags", "converts", "log", "Fields", "into", "jaeger", "tags", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/jaeger_tag.go#L28-L34
train
jaegertracing/jaeger-client-go
internal/throttler/remote/throttler.go
FetchCredits
func (m *httpCreditManagerProxy) FetchCredits(uuid, serviceName string, operations []string) (*creditResponse, error) { params := url.Values{} params.Set("service", serviceName) params.Set("uuid", uuid) for _, op := range operations { params.Add("operations", op) } var resp creditResponse if err := utils.GetJSON(fmt.Sprintf("http://%s/credits?%s", m.hostPort, params.Encode()), &resp); err != nil { return nil, errors.Wrap(err, "Failed to receive credits from agent") } return &resp, nil }
go
func (m *httpCreditManagerProxy) FetchCredits(uuid, serviceName string, operations []string) (*creditResponse, error) { params := url.Values{} params.Set("service", serviceName) params.Set("uuid", uuid) for _, op := range operations { params.Add("operations", op) } var resp creditResponse if err := utils.GetJSON(fmt.Sprintf("http://%s/credits?%s", m.hostPort, params.Encode()), &resp); err != nil { return nil, errors.Wrap(err, "Failed to receive credits from agent") } return &resp, nil }
[ "func", "(", "m", "*", "httpCreditManagerProxy", ")", "FetchCredits", "(", "uuid", ",", "serviceName", "string", ",", "operations", "[", "]", "string", ")", "(", "*", "creditResponse", ",", "error", ")", "{", "params", ":=", "url", ".", "Values", "{", "}...
// N.B. Operations list must not be empty.
[ "N", ".", "B", ".", "Operations", "list", "must", "not", "be", "empty", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/throttler/remote/throttler.go#L60-L72
train
jaegertracing/jaeger-client-go
internal/throttler/remote/throttler.go
NewThrottler
func NewThrottler(service string, options ...Option) *Throttler { opts := applyOptions(options...) creditManager := newHTTPCreditManagerProxy(opts.hostPort) t := &Throttler{ options: opts, creditManager: creditManager, service: service, credits: make(map[string]float64), close: make(chan struct{}), } t.stopped.Add(1) go t.pollManager() return t }
go
func NewThrottler(service string, options ...Option) *Throttler { opts := applyOptions(options...) creditManager := newHTTPCreditManagerProxy(opts.hostPort) t := &Throttler{ options: opts, creditManager: creditManager, service: service, credits: make(map[string]float64), close: make(chan struct{}), } t.stopped.Add(1) go t.pollManager() return t }
[ "func", "NewThrottler", "(", "service", "string", ",", "options", "...", "Option", ")", "*", "Throttler", "{", "opts", ":=", "applyOptions", "(", "options", "...", ")", "\n", "creditManager", ":=", "newHTTPCreditManagerProxy", "(", "opts", ".", "hostPort", ")"...
// NewThrottler returns a Throttler that polls agent for credits and uses them to throttle // the service.
[ "NewThrottler", "returns", "a", "Throttler", "that", "polls", "agent", "for", "credits", "and", "uses", "them", "to", "throttle", "the", "service", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/throttler/remote/throttler.go#L89-L102
train
jaegertracing/jaeger-client-go
internal/throttler/remote/throttler.go
Close
func (t *Throttler) Close() error { close(t.close) t.stopped.Wait() return nil }
go
func (t *Throttler) Close() error { close(t.close) t.stopped.Wait() return nil }
[ "func", "(", "t", "*", "Throttler", ")", "Close", "(", ")", "error", "{", "close", "(", "t", ".", "close", ")", "\n", "t", ".", "stopped", ".", "Wait", "(", ")", "\n", "return", "nil", "\n", "}" ]
// Close stops the throttler from fetching credits from remote.
[ "Close", "stops", "the", "throttler", "from", "fetching", "credits", "from", "remote", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/throttler/remote/throttler.go#L140-L144
train
jaegertracing/jaeger-client-go
internal/throttler/remote/throttler.go
isAllowed
func (t *Throttler) isAllowed(operation string) bool { credits := t.credits[operation] if credits < minimumCredits { t.metrics.ThrottledDebugSpans.Inc(1) return false } t.credits[operation] = credits - minimumCredits return true }
go
func (t *Throttler) isAllowed(operation string) bool { credits := t.credits[operation] if credits < minimumCredits { t.metrics.ThrottledDebugSpans.Inc(1) return false } t.credits[operation] = credits - minimumCredits return true }
[ "func", "(", "t", "*", "Throttler", ")", "isAllowed", "(", "operation", "string", ")", "bool", "{", "credits", ":=", "t", ".", "credits", "[", "operation", "]", "\n", "if", "credits", "<", "minimumCredits", "{", "t", ".", "metrics", ".", "ThrottledDebugS...
// N.B. This function must be called with the Write Lock
[ "N", ".", "B", ".", "This", "function", "must", "be", "called", "with", "the", "Write", "Lock" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/throttler/remote/throttler.go#L155-L163
train
jaegertracing/jaeger-client-go
internal/baggage/remote/options.go
DenyBaggageOnInitializationFailure
func (options) DenyBaggageOnInitializationFailure(b bool) Option { return func(o *options) { o.denyBaggageOnInitializationFailure = b } }
go
func (options) DenyBaggageOnInitializationFailure(b bool) Option { return func(o *options) { o.denyBaggageOnInitializationFailure = b } }
[ "func", "(", "options", ")", "DenyBaggageOnInitializationFailure", "(", "b", "bool", ")", "Option", "{", "return", "func", "(", "o", "*", "options", ")", "{", "o", ".", "denyBaggageOnInitializationFailure", "=", "b", "\n", "}", "\n", "}" ]
// DenyBaggageOnInitializationFailure creates an Option that determines the startup failure mode of RestrictionManager. // If DenyBaggageOnInitializationFailure is true, RestrictionManager will not allow any baggage to be written until baggage // restrictions have been retrieved from agent. // If DenyBaggageOnInitializationFailure is false, RestrictionManager will allow any baggage to be written until baggage // restrictions have been retrieved from agent.
[ "DenyBaggageOnInitializationFailure", "creates", "an", "Option", "that", "determines", "the", "startup", "failure", "mode", "of", "RestrictionManager", ".", "If", "DenyBaggageOnInitializationFailure", "is", "true", "RestrictionManager", "will", "not", "allow", "any", "bag...
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/baggage/remote/options.go#L48-L52
train
jaegertracing/jaeger-client-go
internal/baggage/remote/options.go
Metrics
func (options) Metrics(m *jaeger.Metrics) Option { return func(o *options) { o.metrics = m } }
go
func (options) Metrics(m *jaeger.Metrics) Option { return func(o *options) { o.metrics = m } }
[ "func", "(", "options", ")", "Metrics", "(", "m", "*", "jaeger", ".", "Metrics", ")", "Option", "{", "return", "func", "(", "o", "*", "options", ")", "{", "o", ".", "metrics", "=", "m", "\n", "}", "\n", "}" ]
// Metrics creates an Option that initializes Metrics on the RestrictionManager, which is used to emit statistics.
[ "Metrics", "creates", "an", "Option", "that", "initializes", "Metrics", "on", "the", "RestrictionManager", "which", "is", "used", "to", "emit", "statistics", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/baggage/remote/options.go#L55-L59
train
jaegertracing/jaeger-client-go
internal/baggage/remote/options.go
Logger
func (options) Logger(logger jaeger.Logger) Option { return func(o *options) { o.logger = logger } }
go
func (options) Logger(logger jaeger.Logger) Option { return func(o *options) { o.logger = logger } }
[ "func", "(", "options", ")", "Logger", "(", "logger", "jaeger", ".", "Logger", ")", "Option", "{", "return", "func", "(", "o", "*", "options", ")", "{", "o", ".", "logger", "=", "logger", "\n", "}", "\n", "}" ]
// Logger creates an Option that sets the logger used by the RestrictionManager.
[ "Logger", "creates", "an", "Option", "that", "sets", "the", "logger", "used", "by", "the", "RestrictionManager", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/baggage/remote/options.go#L62-L66
train
jaegertracing/jaeger-client-go
internal/baggage/remote/options.go
HostPort
func (options) HostPort(hostPort string) Option { return func(o *options) { o.hostPort = hostPort } }
go
func (options) HostPort(hostPort string) Option { return func(o *options) { o.hostPort = hostPort } }
[ "func", "(", "options", ")", "HostPort", "(", "hostPort", "string", ")", "Option", "{", "return", "func", "(", "o", "*", "options", ")", "{", "o", ".", "hostPort", "=", "hostPort", "\n", "}", "\n", "}" ]
// HostPort creates an Option that sets the hostPort of the local agent that contains the baggage restrictions.
[ "HostPort", "creates", "an", "Option", "that", "sets", "the", "hostPort", "of", "the", "local", "agent", "that", "contains", "the", "baggage", "restrictions", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/baggage/remote/options.go#L69-L73
train
jaegertracing/jaeger-client-go
internal/baggage/remote/options.go
RefreshInterval
func (options) RefreshInterval(refreshInterval time.Duration) Option { return func(o *options) { o.refreshInterval = refreshInterval } }
go
func (options) RefreshInterval(refreshInterval time.Duration) Option { return func(o *options) { o.refreshInterval = refreshInterval } }
[ "func", "(", "options", ")", "RefreshInterval", "(", "refreshInterval", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "o", "*", "options", ")", "{", "o", ".", "refreshInterval", "=", "refreshInterval", "\n", "}", "\n", "}" ]
// RefreshInterval creates an Option that sets how often the RestrictionManager will poll local agent for // the baggage restrictions.
[ "RefreshInterval", "creates", "an", "Option", "that", "sets", "how", "often", "the", "RestrictionManager", "will", "poll", "local", "agent", "for", "the", "baggage", "restrictions", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/internal/baggage/remote/options.go#L77-L81
train
jaegertracing/jaeger-client-go
rpcmetrics/observer.go
NewObserver
func NewObserver(metricsFactory metrics.Factory, normalizer NameNormalizer) *Observer { return &Observer{ metricsByEndpoint: newMetricsByEndpoint( metricsFactory, normalizer, defaultMaxNumberOfEndpoints, ), } }
go
func NewObserver(metricsFactory metrics.Factory, normalizer NameNormalizer) *Observer { return &Observer{ metricsByEndpoint: newMetricsByEndpoint( metricsFactory, normalizer, defaultMaxNumberOfEndpoints, ), } }
[ "func", "NewObserver", "(", "metricsFactory", "metrics", ".", "Factory", ",", "normalizer", "NameNormalizer", ")", "*", "Observer", "{", "return", "&", "Observer", "{", "metricsByEndpoint", ":", "newMetricsByEndpoint", "(", "metricsFactory", ",", "normalizer", ",", ...
// NewObserver creates a new observer that can emit RPC metrics.
[ "NewObserver", "creates", "a", "new", "observer", "that", "can", "emit", "RPC", "metrics", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/rpcmetrics/observer.go#L37-L45
train
jaegertracing/jaeger-client-go
rpcmetrics/observer.go
OnStartSpan
func (o *Observer) OnStartSpan( operationName string, options opentracing.StartSpanOptions, ) jaeger.SpanObserver { return NewSpanObserver(o.metricsByEndpoint, operationName, options) }
go
func (o *Observer) OnStartSpan( operationName string, options opentracing.StartSpanOptions, ) jaeger.SpanObserver { return NewSpanObserver(o.metricsByEndpoint, operationName, options) }
[ "func", "(", "o", "*", "Observer", ")", "OnStartSpan", "(", "operationName", "string", ",", "options", "opentracing", ".", "StartSpanOptions", ",", ")", "jaeger", ".", "SpanObserver", "{", "return", "NewSpanObserver", "(", "o", ".", "metricsByEndpoint", ",", "...
// OnStartSpan creates a new Observer for the span.
[ "OnStartSpan", "creates", "a", "new", "Observer", "for", "the", "span", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/rpcmetrics/observer.go#L48-L53
train
jaegertracing/jaeger-client-go
rpcmetrics/observer.go
NewSpanObserver
func NewSpanObserver( metricsByEndpoint *MetricsByEndpoint, operationName string, options opentracing.StartSpanOptions, ) *SpanObserver { so := &SpanObserver{ metricsByEndpoint: metricsByEndpoint, operationName: operationName, startTime: options.StartTime, } for k, v := range options.Tags { so.handleTagInLock(k, v) } return so }
go
func NewSpanObserver( metricsByEndpoint *MetricsByEndpoint, operationName string, options opentracing.StartSpanOptions, ) *SpanObserver { so := &SpanObserver{ metricsByEndpoint: metricsByEndpoint, operationName: operationName, startTime: options.StartTime, } for k, v := range options.Tags { so.handleTagInLock(k, v) } return so }
[ "func", "NewSpanObserver", "(", "metricsByEndpoint", "*", "MetricsByEndpoint", ",", "operationName", "string", ",", "options", "opentracing", ".", "StartSpanOptions", ",", ")", "*", "SpanObserver", "{", "so", ":=", "&", "SpanObserver", "{", "metricsByEndpoint", ":",...
// NewSpanObserver creates a new SpanObserver that can emit RPC metrics.
[ "NewSpanObserver", "creates", "a", "new", "SpanObserver", "that", "can", "emit", "RPC", "metrics", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/rpcmetrics/observer.go#L79-L93
train
jaegertracing/jaeger-client-go
rpcmetrics/observer.go
handleTagInLock
func (so *SpanObserver) handleTagInLock(key string, value interface{}) { if key == string(ext.SpanKind) { if v, ok := value.(ext.SpanKindEnum); ok { value = string(v) } if v, ok := value.(string); ok { if v == string(ext.SpanKindRPCClientEnum) { so.kind = Outbound } else if v == string(ext.SpanKindRPCServerEnum) { so.kind = Inbound } } return } if key == string(ext.HTTPStatusCode) { if v, ok := value.(uint16); ok { so.httpStatusCode = v } else if v, ok := value.(int); ok { so.httpStatusCode = uint16(v) } else if v, ok := value.(string); ok { if vv, err := strconv.Atoi(v); err == nil { so.httpStatusCode = uint16(vv) } } return } if key == string(ext.Error) { if v, ok := value.(bool); ok { so.err = v } else if v, ok := value.(string); ok { if vv, err := strconv.ParseBool(v); err == nil { so.err = vv } } return } }
go
func (so *SpanObserver) handleTagInLock(key string, value interface{}) { if key == string(ext.SpanKind) { if v, ok := value.(ext.SpanKindEnum); ok { value = string(v) } if v, ok := value.(string); ok { if v == string(ext.SpanKindRPCClientEnum) { so.kind = Outbound } else if v == string(ext.SpanKindRPCServerEnum) { so.kind = Inbound } } return } if key == string(ext.HTTPStatusCode) { if v, ok := value.(uint16); ok { so.httpStatusCode = v } else if v, ok := value.(int); ok { so.httpStatusCode = uint16(v) } else if v, ok := value.(string); ok { if vv, err := strconv.Atoi(v); err == nil { so.httpStatusCode = uint16(vv) } } return } if key == string(ext.Error) { if v, ok := value.(bool); ok { so.err = v } else if v, ok := value.(string); ok { if vv, err := strconv.ParseBool(v); err == nil { so.err = vv } } return } }
[ "func", "(", "so", "*", "SpanObserver", ")", "handleTagInLock", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "{", "if", "key", "==", "string", "(", "ext", ".", "SpanKind", ")", "{", "if", "v", ",", "ok", ":=", "value", ".", "(", ...
// handleTags watches for special tags // - SpanKind // - HttpStatusCode // - Error
[ "handleTags", "watches", "for", "special", "tags", "-", "SpanKind", "-", "HttpStatusCode", "-", "Error" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/rpcmetrics/observer.go#L99-L135
train
jaegertracing/jaeger-client-go
rpcmetrics/observer.go
OnFinish
func (so *SpanObserver) OnFinish(options opentracing.FinishOptions) { so.mux.Lock() defer so.mux.Unlock() if so.operationName == "" || so.kind != Inbound { return } mets := so.metricsByEndpoint.get(so.operationName) latency := options.FinishTime.Sub(so.startTime) if so.err { mets.RequestCountFailures.Inc(1) mets.RequestLatencyFailures.Record(latency) } else { mets.RequestCountSuccess.Inc(1) mets.RequestLatencySuccess.Record(latency) } mets.recordHTTPStatusCode(so.httpStatusCode) }
go
func (so *SpanObserver) OnFinish(options opentracing.FinishOptions) { so.mux.Lock() defer so.mux.Unlock() if so.operationName == "" || so.kind != Inbound { return } mets := so.metricsByEndpoint.get(so.operationName) latency := options.FinishTime.Sub(so.startTime) if so.err { mets.RequestCountFailures.Inc(1) mets.RequestLatencyFailures.Record(latency) } else { mets.RequestCountSuccess.Inc(1) mets.RequestLatencySuccess.Record(latency) } mets.recordHTTPStatusCode(so.httpStatusCode) }
[ "func", "(", "so", "*", "SpanObserver", ")", "OnFinish", "(", "options", "opentracing", ".", "FinishOptions", ")", "{", "so", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "so", ".", "mux", ".", "Unlock", "(", ")", "\n", "if", "so", ".", "opera...
// OnFinish emits the RPC metrics. It only has an effect when operation name // is not blank, and the span kind is an RPC server.
[ "OnFinish", "emits", "the", "RPC", "metrics", ".", "It", "only", "has", "an", "effect", "when", "operation", "name", "is", "not", "blank", "and", "the", "span", "kind", "is", "an", "RPC", "server", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/rpcmetrics/observer.go#L139-L157
train
jaegertracing/jaeger-client-go
rpcmetrics/observer.go
OnSetOperationName
func (so *SpanObserver) OnSetOperationName(operationName string) { so.mux.Lock() so.operationName = operationName so.mux.Unlock() }
go
func (so *SpanObserver) OnSetOperationName(operationName string) { so.mux.Lock() so.operationName = operationName so.mux.Unlock() }
[ "func", "(", "so", "*", "SpanObserver", ")", "OnSetOperationName", "(", "operationName", "string", ")", "{", "so", ".", "mux", ".", "Lock", "(", ")", "\n", "so", ".", "operationName", "=", "operationName", "\n", "so", ".", "mux", ".", "Unlock", "(", ")...
// OnSetOperationName records new operation name.
[ "OnSetOperationName", "records", "new", "operation", "name", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/rpcmetrics/observer.go#L160-L164
train
jaegertracing/jaeger-client-go
rpcmetrics/observer.go
OnSetTag
func (so *SpanObserver) OnSetTag(key string, value interface{}) { so.mux.Lock() so.handleTagInLock(key, value) so.mux.Unlock() }
go
func (so *SpanObserver) OnSetTag(key string, value interface{}) { so.mux.Lock() so.handleTagInLock(key, value) so.mux.Unlock() }
[ "func", "(", "so", "*", "SpanObserver", ")", "OnSetTag", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "{", "so", ".", "mux", ".", "Lock", "(", ")", "\n", "so", ".", "handleTagInLock", "(", "key", ",", "value", ")", "\n", "so", ...
// OnSetTag implements SpanObserver
[ "OnSetTag", "implements", "SpanObserver" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/rpcmetrics/observer.go#L167-L171
train
jaegertracing/jaeger-client-go
sampler_options.go
Metrics
func (samplerOptions) Metrics(m *Metrics) SamplerOption { return func(o *samplerOptions) { o.metrics = m } }
go
func (samplerOptions) Metrics(m *Metrics) SamplerOption { return func(o *samplerOptions) { o.metrics = m } }
[ "func", "(", "samplerOptions", ")", "Metrics", "(", "m", "*", "Metrics", ")", "SamplerOption", "{", "return", "func", "(", "o", "*", "samplerOptions", ")", "{", "o", ".", "metrics", "=", "m", "\n", "}", "\n", "}" ]
// Metrics creates a SamplerOption that initializes Metrics on the sampler, // which is used to emit statistics.
[ "Metrics", "creates", "a", "SamplerOption", "that", "initializes", "Metrics", "on", "the", "sampler", "which", "is", "used", "to", "emit", "statistics", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/sampler_options.go#L38-L42
train
jaegertracing/jaeger-client-go
sampler_options.go
MaxOperations
func (samplerOptions) MaxOperations(maxOperations int) SamplerOption { return func(o *samplerOptions) { o.maxOperations = maxOperations } }
go
func (samplerOptions) MaxOperations(maxOperations int) SamplerOption { return func(o *samplerOptions) { o.maxOperations = maxOperations } }
[ "func", "(", "samplerOptions", ")", "MaxOperations", "(", "maxOperations", "int", ")", "SamplerOption", "{", "return", "func", "(", "o", "*", "samplerOptions", ")", "{", "o", ".", "maxOperations", "=", "maxOperations", "\n", "}", "\n", "}" ]
// MaxOperations creates a SamplerOption that sets the maximum number of // operations the sampler will keep track of.
[ "MaxOperations", "creates", "a", "SamplerOption", "that", "sets", "the", "maximum", "number", "of", "operations", "the", "sampler", "will", "keep", "track", "of", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/sampler_options.go#L46-L50
train
jaegertracing/jaeger-client-go
sampler_options.go
InitialSampler
func (samplerOptions) InitialSampler(sampler Sampler) SamplerOption { return func(o *samplerOptions) { o.sampler = sampler } }
go
func (samplerOptions) InitialSampler(sampler Sampler) SamplerOption { return func(o *samplerOptions) { o.sampler = sampler } }
[ "func", "(", "samplerOptions", ")", "InitialSampler", "(", "sampler", "Sampler", ")", "SamplerOption", "{", "return", "func", "(", "o", "*", "samplerOptions", ")", "{", "o", ".", "sampler", "=", "sampler", "\n", "}", "\n", "}" ]
// InitialSampler creates a SamplerOption that sets the initial sampler // to use before a remote sampler is created and used.
[ "InitialSampler", "creates", "a", "SamplerOption", "that", "sets", "the", "initial", "sampler", "to", "use", "before", "a", "remote", "sampler", "is", "created", "and", "used", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/sampler_options.go#L54-L58
train
jaegertracing/jaeger-client-go
sampler_options.go
Logger
func (samplerOptions) Logger(logger Logger) SamplerOption { return func(o *samplerOptions) { o.logger = logger } }
go
func (samplerOptions) Logger(logger Logger) SamplerOption { return func(o *samplerOptions) { o.logger = logger } }
[ "func", "(", "samplerOptions", ")", "Logger", "(", "logger", "Logger", ")", "SamplerOption", "{", "return", "func", "(", "o", "*", "samplerOptions", ")", "{", "o", ".", "logger", "=", "logger", "\n", "}", "\n", "}" ]
// Logger creates a SamplerOption that sets the logger used by the sampler.
[ "Logger", "creates", "a", "SamplerOption", "that", "sets", "the", "logger", "used", "by", "the", "sampler", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/sampler_options.go#L61-L65
train
jaegertracing/jaeger-client-go
sampler_options.go
SamplingServerURL
func (samplerOptions) SamplingServerURL(samplingServerURL string) SamplerOption { return func(o *samplerOptions) { o.samplingServerURL = samplingServerURL } }
go
func (samplerOptions) SamplingServerURL(samplingServerURL string) SamplerOption { return func(o *samplerOptions) { o.samplingServerURL = samplingServerURL } }
[ "func", "(", "samplerOptions", ")", "SamplingServerURL", "(", "samplingServerURL", "string", ")", "SamplerOption", "{", "return", "func", "(", "o", "*", "samplerOptions", ")", "{", "o", ".", "samplingServerURL", "=", "samplingServerURL", "\n", "}", "\n", "}" ]
// SamplingServerURL creates a SamplerOption that sets the sampling server url // of the local agent that contains the sampling strategies.
[ "SamplingServerURL", "creates", "a", "SamplerOption", "that", "sets", "the", "sampling", "server", "url", "of", "the", "local", "agent", "that", "contains", "the", "sampling", "strategies", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/sampler_options.go#L69-L73
train
jaegertracing/jaeger-client-go
sampler_options.go
SamplingRefreshInterval
func (samplerOptions) SamplingRefreshInterval(samplingRefreshInterval time.Duration) SamplerOption { return func(o *samplerOptions) { o.samplingRefreshInterval = samplingRefreshInterval } }
go
func (samplerOptions) SamplingRefreshInterval(samplingRefreshInterval time.Duration) SamplerOption { return func(o *samplerOptions) { o.samplingRefreshInterval = samplingRefreshInterval } }
[ "func", "(", "samplerOptions", ")", "SamplingRefreshInterval", "(", "samplingRefreshInterval", "time", ".", "Duration", ")", "SamplerOption", "{", "return", "func", "(", "o", "*", "samplerOptions", ")", "{", "o", ".", "samplingRefreshInterval", "=", "samplingRefresh...
// SamplingRefreshInterval creates a SamplerOption that sets how often the // sampler will poll local agent for the appropriate sampling strategy.
[ "SamplingRefreshInterval", "creates", "a", "SamplerOption", "that", "sets", "how", "often", "the", "sampler", "will", "poll", "local", "agent", "for", "the", "appropriate", "sampling", "strategy", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/sampler_options.go#L77-L81
train
jaegertracing/jaeger-client-go
utils/udp_client.go
NewAgentClientUDP
func NewAgentClientUDP(hostPort string, maxPacketSize int) (*AgentClientUDP, error) { if maxPacketSize == 0 { maxPacketSize = UDPPacketMaxLength } thriftBuffer := thrift.NewTMemoryBufferLen(maxPacketSize) protocolFactory := thrift.NewTCompactProtocolFactory() client := agent.NewAgentClientFactory(thriftBuffer, protocolFactory) destAddr, err := net.ResolveUDPAddr("udp", hostPort) if err != nil { return nil, err } connUDP, err := net.DialUDP(destAddr.Network(), nil, destAddr) if err != nil { return nil, err } if err := connUDP.SetWriteBuffer(maxPacketSize); err != nil { return nil, err } clientUDP := &AgentClientUDP{ connUDP: connUDP, client: client, maxPacketSize: maxPacketSize, thriftBuffer: thriftBuffer} return clientUDP, nil }
go
func NewAgentClientUDP(hostPort string, maxPacketSize int) (*AgentClientUDP, error) { if maxPacketSize == 0 { maxPacketSize = UDPPacketMaxLength } thriftBuffer := thrift.NewTMemoryBufferLen(maxPacketSize) protocolFactory := thrift.NewTCompactProtocolFactory() client := agent.NewAgentClientFactory(thriftBuffer, protocolFactory) destAddr, err := net.ResolveUDPAddr("udp", hostPort) if err != nil { return nil, err } connUDP, err := net.DialUDP(destAddr.Network(), nil, destAddr) if err != nil { return nil, err } if err := connUDP.SetWriteBuffer(maxPacketSize); err != nil { return nil, err } clientUDP := &AgentClientUDP{ connUDP: connUDP, client: client, maxPacketSize: maxPacketSize, thriftBuffer: thriftBuffer} return clientUDP, nil }
[ "func", "NewAgentClientUDP", "(", "hostPort", "string", ",", "maxPacketSize", "int", ")", "(", "*", "AgentClientUDP", ",", "error", ")", "{", "if", "maxPacketSize", "==", "0", "{", "maxPacketSize", "=", "UDPPacketMaxLength", "\n", "}", "\n", "thriftBuffer", ":...
// NewAgentClientUDP creates a client that sends spans to Jaeger Agent over UDP.
[ "NewAgentClientUDP", "creates", "a", "client", "that", "sends", "spans", "to", "Jaeger", "Agent", "over", "UDP", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/utils/udp_client.go#L45-L73
train
jaegertracing/jaeger-client-go
crossdock/client/client.go
AsyncStart
func (c *Client) AsyncStart() error { if err := c.Listen(); err != nil { return err } var started sync.WaitGroup started.Add(1) go func() { started.Done() c.Serve() }() started.Wait() return nil }
go
func (c *Client) AsyncStart() error { if err := c.Listen(); err != nil { return err } var started sync.WaitGroup started.Add(1) go func() { started.Done() c.Serve() }() started.Wait() return nil }
[ "func", "(", "c", "*", "Client", ")", "AsyncStart", "(", ")", "error", "{", "if", "err", ":=", "c", ".", "Listen", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "var", "started", "sync", ".", "WaitGroup", "\n", "starte...
// AsyncStart begins a Crossdock client in the background, // but does not return until it started serving.
[ "AsyncStart", "begins", "a", "Crossdock", "client", "in", "the", "background", "but", "does", "not", "return", "until", "it", "started", "serving", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/crossdock/client/client.go#L46-L58
train
jaegertracing/jaeger-client-go
crossdock/client/client.go
Listen
func (c *Client) Listen() error { c.setDefaultPort(&c.ClientHostPort, ":"+common.DefaultClientPortHTTP) c.setDefaultPort(&c.ServerPortHTTP, common.DefaultServerPortHTTP) behaviors := crossdock.Behaviors{ behaviorTrace: c.trace, } http.Handle("/", crossdock.Handler(behaviors, true)) listener, err := net.Listen("tcp", c.ClientHostPort) if err != nil { return err } c.listener = listener c.ClientHostPort = listener.Addr().String() return nil }
go
func (c *Client) Listen() error { c.setDefaultPort(&c.ClientHostPort, ":"+common.DefaultClientPortHTTP) c.setDefaultPort(&c.ServerPortHTTP, common.DefaultServerPortHTTP) behaviors := crossdock.Behaviors{ behaviorTrace: c.trace, } http.Handle("/", crossdock.Handler(behaviors, true)) listener, err := net.Listen("tcp", c.ClientHostPort) if err != nil { return err } c.listener = listener c.ClientHostPort = listener.Addr().String() return nil }
[ "func", "(", "c", "*", "Client", ")", "Listen", "(", ")", "error", "{", "c", ".", "setDefaultPort", "(", "&", "c", ".", "ClientHostPort", ",", "\":\"", "+", "common", ".", "DefaultClientPortHTTP", ")", "\n", "c", ".", "setDefaultPort", "(", "&", "c", ...
// Listen initializes the server
[ "Listen", "initializes", "the", "server" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/crossdock/client/client.go#L61-L78
train
jaegertracing/jaeger-client-go
zipkin_thrift_span.go
BuildZipkinThrift
func BuildZipkinThrift(s *Span) *z.Span { span := &zipkinSpan{Span: s} span.handleSpecialTags() parentID := int64(span.context.parentID) var ptrParentID *int64 if parentID != 0 { ptrParentID = &parentID } traceIDHigh := int64(span.context.traceID.High) var ptrTraceIDHigh *int64 if traceIDHigh != 0 { ptrTraceIDHigh = &traceIDHigh } timestamp := utils.TimeToMicrosecondsSinceEpochInt64(span.startTime) duration := span.duration.Nanoseconds() / int64(time.Microsecond) endpoint := &z.Endpoint{ ServiceName: span.tracer.serviceName, Ipv4: int32(span.tracer.hostIPv4)} thriftSpan := &z.Span{ TraceID: int64(span.context.traceID.Low), TraceIDHigh: ptrTraceIDHigh, ID: int64(span.context.spanID), ParentID: ptrParentID, Name: span.operationName, Timestamp: &timestamp, Duration: &duration, Debug: span.context.IsDebug(), Annotations: buildAnnotations(span, endpoint), BinaryAnnotations: buildBinaryAnnotations(span, endpoint)} return thriftSpan }
go
func BuildZipkinThrift(s *Span) *z.Span { span := &zipkinSpan{Span: s} span.handleSpecialTags() parentID := int64(span.context.parentID) var ptrParentID *int64 if parentID != 0 { ptrParentID = &parentID } traceIDHigh := int64(span.context.traceID.High) var ptrTraceIDHigh *int64 if traceIDHigh != 0 { ptrTraceIDHigh = &traceIDHigh } timestamp := utils.TimeToMicrosecondsSinceEpochInt64(span.startTime) duration := span.duration.Nanoseconds() / int64(time.Microsecond) endpoint := &z.Endpoint{ ServiceName: span.tracer.serviceName, Ipv4: int32(span.tracer.hostIPv4)} thriftSpan := &z.Span{ TraceID: int64(span.context.traceID.Low), TraceIDHigh: ptrTraceIDHigh, ID: int64(span.context.spanID), ParentID: ptrParentID, Name: span.operationName, Timestamp: &timestamp, Duration: &duration, Debug: span.context.IsDebug(), Annotations: buildAnnotations(span, endpoint), BinaryAnnotations: buildBinaryAnnotations(span, endpoint)} return thriftSpan }
[ "func", "BuildZipkinThrift", "(", "s", "*", "Span", ")", "*", "z", ".", "Span", "{", "span", ":=", "&", "zipkinSpan", "{", "Span", ":", "s", "}", "\n", "span", ".", "handleSpecialTags", "(", ")", "\n", "parentID", ":=", "int64", "(", "span", ".", "...
// BuildZipkinThrift builds thrift span based on internal span.
[ "BuildZipkinThrift", "builds", "thrift", "span", "based", "on", "internal", "span", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/zipkin_thrift_span.go#L43-L73
train
jaegertracing/jaeger-client-go
zipkin_thrift_span.go
int32ToBytes
func int32ToBytes(i int32) []byte { buf := make([]byte, 4) binary.BigEndian.PutUint32(buf, uint32(i)) return buf }
go
func int32ToBytes(i int32) []byte { buf := make([]byte, 4) binary.BigEndian.PutUint32(buf, uint32(i)) return buf }
[ "func", "int32ToBytes", "(", "i", "int32", ")", "[", "]", "byte", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "4", ")", "\n", "binary", ".", "BigEndian", ".", "PutUint32", "(", "buf", ",", "uint32", "(", "i", ")", ")", "\n", "return", ...
// int32ToBytes converts int32 to bytes.
[ "int32ToBytes", "converts", "int32", "to", "bytes", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/zipkin_thrift_span.go#L217-L221
train
jaegertracing/jaeger-client-go
zipkin_thrift_span.go
int64ToBytes
func int64ToBytes(i int64) []byte { buf := make([]byte, 8) binary.BigEndian.PutUint64(buf, uint64(i)) return buf }
go
func int64ToBytes(i int64) []byte { buf := make([]byte, 8) binary.BigEndian.PutUint64(buf, uint64(i)) return buf }
[ "func", "int64ToBytes", "(", "i", "int64", ")", "[", "]", "byte", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "8", ")", "\n", "binary", ".", "BigEndian", ".", "PutUint64", "(", "buf", ",", "uint64", "(", "i", ")", ")", "\n", "return", ...
// int64ToBytes converts int64 to bytes.
[ "int64ToBytes", "converts", "int64", "to", "bytes", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/zipkin_thrift_span.go#L224-L228
train
jaegertracing/jaeger-client-go
propagation.go
NewTextMapPropagator
func NewTextMapPropagator(headerKeys *HeadersConfig, metrics Metrics) *TextMapPropagator { return &TextMapPropagator{ headerKeys: headerKeys, metrics: metrics, encodeValue: func(val string) string { return val }, decodeValue: func(val string) string { return val }, } }
go
func NewTextMapPropagator(headerKeys *HeadersConfig, metrics Metrics) *TextMapPropagator { return &TextMapPropagator{ headerKeys: headerKeys, metrics: metrics, encodeValue: func(val string) string { return val }, decodeValue: func(val string) string { return val }, } }
[ "func", "NewTextMapPropagator", "(", "headerKeys", "*", "HeadersConfig", ",", "metrics", "Metrics", ")", "*", "TextMapPropagator", "{", "return", "&", "TextMapPropagator", "{", "headerKeys", ":", "headerKeys", ",", "metrics", ":", "metrics", ",", "encodeValue", ":...
// NewTextMapPropagator creates a combined Injector and Extractor for TextMap format
[ "NewTextMapPropagator", "creates", "a", "combined", "Injector", "and", "Extractor", "for", "TextMap", "format" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/propagation.go#L63-L74
train
jaegertracing/jaeger-client-go
propagation.go
NewHTTPHeaderPropagator
func NewHTTPHeaderPropagator(headerKeys *HeadersConfig, metrics Metrics) *TextMapPropagator { return &TextMapPropagator{ headerKeys: headerKeys, metrics: metrics, encodeValue: func(val string) string { return url.QueryEscape(val) }, decodeValue: func(val string) string { // ignore decoding errors, cannot do anything about them if v, err := url.QueryUnescape(val); err == nil { return v } return val }, } }
go
func NewHTTPHeaderPropagator(headerKeys *HeadersConfig, metrics Metrics) *TextMapPropagator { return &TextMapPropagator{ headerKeys: headerKeys, metrics: metrics, encodeValue: func(val string) string { return url.QueryEscape(val) }, decodeValue: func(val string) string { // ignore decoding errors, cannot do anything about them if v, err := url.QueryUnescape(val); err == nil { return v } return val }, } }
[ "func", "NewHTTPHeaderPropagator", "(", "headerKeys", "*", "HeadersConfig", ",", "metrics", "Metrics", ")", "*", "TextMapPropagator", "{", "return", "&", "TextMapPropagator", "{", "headerKeys", ":", "headerKeys", ",", "metrics", ":", "metrics", ",", "encodeValue", ...
// NewHTTPHeaderPropagator creates a combined Injector and Extractor for HTTPHeaders format
[ "NewHTTPHeaderPropagator", "creates", "a", "combined", "Injector", "and", "Extractor", "for", "HTTPHeaders", "format" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/propagation.go#L77-L92
train
jaegertracing/jaeger-client-go
propagation.go
NewBinaryPropagator
func NewBinaryPropagator(tracer *Tracer) *BinaryPropagator { return &BinaryPropagator{ tracer: tracer, buffers: sync.Pool{New: func() interface{} { return &bytes.Buffer{} }}, } }
go
func NewBinaryPropagator(tracer *Tracer) *BinaryPropagator { return &BinaryPropagator{ tracer: tracer, buffers: sync.Pool{New: func() interface{} { return &bytes.Buffer{} }}, } }
[ "func", "NewBinaryPropagator", "(", "tracer", "*", "Tracer", ")", "*", "BinaryPropagator", "{", "return", "&", "BinaryPropagator", "{", "tracer", ":", "tracer", ",", "buffers", ":", "sync", ".", "Pool", "{", "New", ":", "func", "(", ")", "interface", "{", ...
// NewBinaryPropagator creates a combined Injector and Extractor for Binary format
[ "NewBinaryPropagator", "creates", "a", "combined", "Injector", "and", "Extractor", "for", "Binary", "format" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/propagation.go#L101-L106
train
jaegertracing/jaeger-client-go
propagation.go
Inject
func (p *TextMapPropagator) Inject( sc SpanContext, abstractCarrier interface{}, ) error { textMapWriter, ok := abstractCarrier.(opentracing.TextMapWriter) if !ok { return opentracing.ErrInvalidCarrier } // Do not encode the string with trace context to avoid accidental double-encoding // if people are using opentracing < 0.10.0. Our colon-separated representation // of the trace context is already safe for HTTP headers. textMapWriter.Set(p.headerKeys.TraceContextHeaderName, sc.String()) for k, v := range sc.baggage { safeKey := p.addBaggageKeyPrefix(k) safeVal := p.encodeValue(v) textMapWriter.Set(safeKey, safeVal) } return nil }
go
func (p *TextMapPropagator) Inject( sc SpanContext, abstractCarrier interface{}, ) error { textMapWriter, ok := abstractCarrier.(opentracing.TextMapWriter) if !ok { return opentracing.ErrInvalidCarrier } // Do not encode the string with trace context to avoid accidental double-encoding // if people are using opentracing < 0.10.0. Our colon-separated representation // of the trace context is already safe for HTTP headers. textMapWriter.Set(p.headerKeys.TraceContextHeaderName, sc.String()) for k, v := range sc.baggage { safeKey := p.addBaggageKeyPrefix(k) safeVal := p.encodeValue(v) textMapWriter.Set(safeKey, safeVal) } return nil }
[ "func", "(", "p", "*", "TextMapPropagator", ")", "Inject", "(", "sc", "SpanContext", ",", "abstractCarrier", "interface", "{", "}", ",", ")", "error", "{", "textMapWriter", ",", "ok", ":=", "abstractCarrier", ".", "(", "opentracing", ".", "TextMapWriter", ")...
// Inject implements Injector of TextMapPropagator
[ "Inject", "implements", "Injector", "of", "TextMapPropagator" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/propagation.go#L109-L128
train
jaegertracing/jaeger-client-go
propagation.go
Extract
func (p *TextMapPropagator) Extract(abstractCarrier interface{}) (SpanContext, error) { textMapReader, ok := abstractCarrier.(opentracing.TextMapReader) if !ok { return emptyContext, opentracing.ErrInvalidCarrier } var ctx SpanContext var baggage map[string]string err := textMapReader.ForeachKey(func(rawKey, value string) error { key := strings.ToLower(rawKey) // TODO not necessary for plain TextMap if key == p.headerKeys.TraceContextHeaderName { var err error safeVal := p.decodeValue(value) if ctx, err = ContextFromString(safeVal); err != nil { return err } } else if key == p.headerKeys.JaegerDebugHeader { ctx.debugID = p.decodeValue(value) } else if key == p.headerKeys.JaegerBaggageHeader { if baggage == nil { baggage = make(map[string]string) } for k, v := range p.parseCommaSeparatedMap(value) { baggage[k] = v } } else if strings.HasPrefix(key, p.headerKeys.TraceBaggageHeaderPrefix) { if baggage == nil { baggage = make(map[string]string) } safeKey := p.removeBaggageKeyPrefix(key) safeVal := p.decodeValue(value) baggage[safeKey] = safeVal } return nil }) if err != nil { p.metrics.DecodingErrors.Inc(1) return emptyContext, err } if !ctx.traceID.IsValid() && ctx.debugID == "" && len(baggage) == 0 { return emptyContext, opentracing.ErrSpanContextNotFound } ctx.baggage = baggage return ctx, nil }
go
func (p *TextMapPropagator) Extract(abstractCarrier interface{}) (SpanContext, error) { textMapReader, ok := abstractCarrier.(opentracing.TextMapReader) if !ok { return emptyContext, opentracing.ErrInvalidCarrier } var ctx SpanContext var baggage map[string]string err := textMapReader.ForeachKey(func(rawKey, value string) error { key := strings.ToLower(rawKey) // TODO not necessary for plain TextMap if key == p.headerKeys.TraceContextHeaderName { var err error safeVal := p.decodeValue(value) if ctx, err = ContextFromString(safeVal); err != nil { return err } } else if key == p.headerKeys.JaegerDebugHeader { ctx.debugID = p.decodeValue(value) } else if key == p.headerKeys.JaegerBaggageHeader { if baggage == nil { baggage = make(map[string]string) } for k, v := range p.parseCommaSeparatedMap(value) { baggage[k] = v } } else if strings.HasPrefix(key, p.headerKeys.TraceBaggageHeaderPrefix) { if baggage == nil { baggage = make(map[string]string) } safeKey := p.removeBaggageKeyPrefix(key) safeVal := p.decodeValue(value) baggage[safeKey] = safeVal } return nil }) if err != nil { p.metrics.DecodingErrors.Inc(1) return emptyContext, err } if !ctx.traceID.IsValid() && ctx.debugID == "" && len(baggage) == 0 { return emptyContext, opentracing.ErrSpanContextNotFound } ctx.baggage = baggage return ctx, nil }
[ "func", "(", "p", "*", "TextMapPropagator", ")", "Extract", "(", "abstractCarrier", "interface", "{", "}", ")", "(", "SpanContext", ",", "error", ")", "{", "textMapReader", ",", "ok", ":=", "abstractCarrier", ".", "(", "opentracing", ".", "TextMapReader", ")...
// Extract implements Extractor of TextMapPropagator
[ "Extract", "implements", "Extractor", "of", "TextMapPropagator" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/propagation.go#L131-L174
train
jaegertracing/jaeger-client-go
propagation.go
Inject
func (p *BinaryPropagator) Inject( sc SpanContext, abstractCarrier interface{}, ) error { carrier, ok := abstractCarrier.(io.Writer) if !ok { return opentracing.ErrInvalidCarrier } // Handle the tracer context if err := binary.Write(carrier, binary.BigEndian, sc.traceID); err != nil { return err } if err := binary.Write(carrier, binary.BigEndian, sc.spanID); err != nil { return err } if err := binary.Write(carrier, binary.BigEndian, sc.parentID); err != nil { return err } if err := binary.Write(carrier, binary.BigEndian, sc.flags); err != nil { return err } // Handle the baggage items if err := binary.Write(carrier, binary.BigEndian, int32(len(sc.baggage))); err != nil { return err } for k, v := range sc.baggage { if err := binary.Write(carrier, binary.BigEndian, int32(len(k))); err != nil { return err } io.WriteString(carrier, k) if err := binary.Write(carrier, binary.BigEndian, int32(len(v))); err != nil { return err } io.WriteString(carrier, v) } return nil }
go
func (p *BinaryPropagator) Inject( sc SpanContext, abstractCarrier interface{}, ) error { carrier, ok := abstractCarrier.(io.Writer) if !ok { return opentracing.ErrInvalidCarrier } // Handle the tracer context if err := binary.Write(carrier, binary.BigEndian, sc.traceID); err != nil { return err } if err := binary.Write(carrier, binary.BigEndian, sc.spanID); err != nil { return err } if err := binary.Write(carrier, binary.BigEndian, sc.parentID); err != nil { return err } if err := binary.Write(carrier, binary.BigEndian, sc.flags); err != nil { return err } // Handle the baggage items if err := binary.Write(carrier, binary.BigEndian, int32(len(sc.baggage))); err != nil { return err } for k, v := range sc.baggage { if err := binary.Write(carrier, binary.BigEndian, int32(len(k))); err != nil { return err } io.WriteString(carrier, k) if err := binary.Write(carrier, binary.BigEndian, int32(len(v))); err != nil { return err } io.WriteString(carrier, v) } return nil }
[ "func", "(", "p", "*", "BinaryPropagator", ")", "Inject", "(", "sc", "SpanContext", ",", "abstractCarrier", "interface", "{", "}", ",", ")", "error", "{", "carrier", ",", "ok", ":=", "abstractCarrier", ".", "(", "io", ".", "Writer", ")", "\n", "if", "!...
// Inject implements Injector of BinaryPropagator
[ "Inject", "implements", "Injector", "of", "BinaryPropagator" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/propagation.go#L177-L216
train
jaegertracing/jaeger-client-go
propagation.go
Extract
func (p *BinaryPropagator) Extract(abstractCarrier interface{}) (SpanContext, error) { carrier, ok := abstractCarrier.(io.Reader) if !ok { return emptyContext, opentracing.ErrInvalidCarrier } var ctx SpanContext if err := binary.Read(carrier, binary.BigEndian, &ctx.traceID); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } if err := binary.Read(carrier, binary.BigEndian, &ctx.spanID); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } if err := binary.Read(carrier, binary.BigEndian, &ctx.parentID); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } if err := binary.Read(carrier, binary.BigEndian, &ctx.flags); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } // Handle the baggage items var numBaggage int32 if err := binary.Read(carrier, binary.BigEndian, &numBaggage); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } if iNumBaggage := int(numBaggage); iNumBaggage > 0 { ctx.baggage = make(map[string]string, iNumBaggage) buf := p.buffers.Get().(*bytes.Buffer) defer p.buffers.Put(buf) var keyLen, valLen int32 for i := 0; i < iNumBaggage; i++ { if err := binary.Read(carrier, binary.BigEndian, &keyLen); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } buf.Reset() buf.Grow(int(keyLen)) if n, err := io.CopyN(buf, carrier, int64(keyLen)); err != nil || int32(n) != keyLen { return emptyContext, opentracing.ErrSpanContextCorrupted } key := buf.String() if err := binary.Read(carrier, binary.BigEndian, &valLen); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } buf.Reset() buf.Grow(int(valLen)) if n, err := io.CopyN(buf, carrier, int64(valLen)); err != nil || int32(n) != valLen { return emptyContext, opentracing.ErrSpanContextCorrupted } ctx.baggage[key] = buf.String() } } return ctx, nil }
go
func (p *BinaryPropagator) Extract(abstractCarrier interface{}) (SpanContext, error) { carrier, ok := abstractCarrier.(io.Reader) if !ok { return emptyContext, opentracing.ErrInvalidCarrier } var ctx SpanContext if err := binary.Read(carrier, binary.BigEndian, &ctx.traceID); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } if err := binary.Read(carrier, binary.BigEndian, &ctx.spanID); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } if err := binary.Read(carrier, binary.BigEndian, &ctx.parentID); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } if err := binary.Read(carrier, binary.BigEndian, &ctx.flags); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } // Handle the baggage items var numBaggage int32 if err := binary.Read(carrier, binary.BigEndian, &numBaggage); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } if iNumBaggage := int(numBaggage); iNumBaggage > 0 { ctx.baggage = make(map[string]string, iNumBaggage) buf := p.buffers.Get().(*bytes.Buffer) defer p.buffers.Put(buf) var keyLen, valLen int32 for i := 0; i < iNumBaggage; i++ { if err := binary.Read(carrier, binary.BigEndian, &keyLen); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } buf.Reset() buf.Grow(int(keyLen)) if n, err := io.CopyN(buf, carrier, int64(keyLen)); err != nil || int32(n) != keyLen { return emptyContext, opentracing.ErrSpanContextCorrupted } key := buf.String() if err := binary.Read(carrier, binary.BigEndian, &valLen); err != nil { return emptyContext, opentracing.ErrSpanContextCorrupted } buf.Reset() buf.Grow(int(valLen)) if n, err := io.CopyN(buf, carrier, int64(valLen)); err != nil || int32(n) != valLen { return emptyContext, opentracing.ErrSpanContextCorrupted } ctx.baggage[key] = buf.String() } } return ctx, nil }
[ "func", "(", "p", "*", "BinaryPropagator", ")", "Extract", "(", "abstractCarrier", "interface", "{", "}", ")", "(", "SpanContext", ",", "error", ")", "{", "carrier", ",", "ok", ":=", "abstractCarrier", ".", "(", "io", ".", "Reader", ")", "\n", "if", "!...
// Extract implements Extractor of BinaryPropagator
[ "Extract", "implements", "Extractor", "of", "BinaryPropagator" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/propagation.go#L219-L274
train
jaegertracing/jaeger-client-go
propagation.go
addBaggageKeyPrefix
func (p *TextMapPropagator) addBaggageKeyPrefix(key string) string { // TODO encodeBaggageKeyAsHeader add caching and escaping return fmt.Sprintf("%v%v", p.headerKeys.TraceBaggageHeaderPrefix, key) }
go
func (p *TextMapPropagator) addBaggageKeyPrefix(key string) string { // TODO encodeBaggageKeyAsHeader add caching and escaping return fmt.Sprintf("%v%v", p.headerKeys.TraceBaggageHeaderPrefix, key) }
[ "func", "(", "p", "*", "TextMapPropagator", ")", "addBaggageKeyPrefix", "(", "key", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"%v%v\"", ",", "p", ".", "headerKeys", ".", "TraceBaggageHeaderPrefix", ",", "key", ")", "\n", "}" ]
// Converts a baggage item key into an http header format, // by prepending TraceBaggageHeaderPrefix and encoding the key string
[ "Converts", "a", "baggage", "item", "key", "into", "an", "http", "header", "format", "by", "prepending", "TraceBaggageHeaderPrefix", "and", "encoding", "the", "key", "string" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/propagation.go#L301-L304
train
jaegertracing/jaeger-client-go
config/options.go
Metrics
func Metrics(factory metrics.Factory) Option { return func(c *Options) { c.metrics = factory } }
go
func Metrics(factory metrics.Factory) Option { return func(c *Options) { c.metrics = factory } }
[ "func", "Metrics", "(", "factory", "metrics", ".", "Factory", ")", "Option", "{", "return", "func", "(", "c", "*", "Options", ")", "{", "c", ".", "metrics", "=", "factory", "\n", "}", "\n", "}" ]
// Metrics creates an Option that initializes Metrics in the tracer, // which is used to emit statistics about spans.
[ "Metrics", "creates", "an", "Option", "that", "initializes", "Metrics", "in", "the", "tracer", "which", "is", "used", "to", "emit", "statistics", "about", "spans", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/config/options.go#L46-L50
train
jaegertracing/jaeger-client-go
config/options.go
Logger
func Logger(logger jaeger.Logger) Option { return func(c *Options) { c.logger = logger } }
go
func Logger(logger jaeger.Logger) Option { return func(c *Options) { c.logger = logger } }
[ "func", "Logger", "(", "logger", "jaeger", ".", "Logger", ")", "Option", "{", "return", "func", "(", "c", "*", "Options", ")", "{", "c", ".", "logger", "=", "logger", "\n", "}", "\n", "}" ]
// Logger can be provided to log Reporter errors, as well as to log spans // if Reporter.LogSpans is set to true.
[ "Logger", "can", "be", "provided", "to", "log", "Reporter", "errors", "as", "well", "as", "to", "log", "spans", "if", "Reporter", ".", "LogSpans", "is", "set", "to", "true", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/config/options.go#L54-L58
train
jaegertracing/jaeger-client-go
config/options.go
Sampler
func Sampler(sampler jaeger.Sampler) Option { return func(c *Options) { c.sampler = sampler } }
go
func Sampler(sampler jaeger.Sampler) Option { return func(c *Options) { c.sampler = sampler } }
[ "func", "Sampler", "(", "sampler", "jaeger", ".", "Sampler", ")", "Option", "{", "return", "func", "(", "c", "*", "Options", ")", "{", "c", ".", "sampler", "=", "sampler", "\n", "}", "\n", "}" ]
// Sampler can be provided explicitly to override the configuration.
[ "Sampler", "can", "be", "provided", "explicitly", "to", "override", "the", "configuration", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/config/options.go#L69-L73
train
jaegertracing/jaeger-client-go
config/options.go
Observer
func Observer(observer jaeger.Observer) Option { return func(c *Options) { c.observers = append(c.observers, observer) } }
go
func Observer(observer jaeger.Observer) Option { return func(c *Options) { c.observers = append(c.observers, observer) } }
[ "func", "Observer", "(", "observer", "jaeger", ".", "Observer", ")", "Option", "{", "return", "func", "(", "c", "*", "Options", ")", "{", "c", ".", "observers", "=", "append", "(", "c", ".", "observers", ",", "observer", ")", "\n", "}", "\n", "}" ]
// Observer can be registered with the Tracer to receive notifications about new Spans.
[ "Observer", "can", "be", "registered", "with", "the", "Tracer", "to", "receive", "notifications", "about", "new", "Spans", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/config/options.go#L76-L80
train
jaegertracing/jaeger-client-go
config/options.go
ContribObserver
func ContribObserver(observer jaeger.ContribObserver) Option { return func(c *Options) { c.contribObservers = append(c.contribObservers, observer) } }
go
func ContribObserver(observer jaeger.ContribObserver) Option { return func(c *Options) { c.contribObservers = append(c.contribObservers, observer) } }
[ "func", "ContribObserver", "(", "observer", "jaeger", ".", "ContribObserver", ")", "Option", "{", "return", "func", "(", "c", "*", "Options", ")", "{", "c", ".", "contribObservers", "=", "append", "(", "c", ".", "contribObservers", ",", "observer", ")", "\...
// ContribObserver can be registered with the Tracer to receive notifications // about new spans.
[ "ContribObserver", "can", "be", "registered", "with", "the", "Tracer", "to", "receive", "notifications", "about", "new", "spans", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/config/options.go#L84-L88
train
jaegertracing/jaeger-client-go
config/options.go
Tag
func Tag(key string, value interface{}) Option { return func(c *Options) { c.tags = append(c.tags, opentracing.Tag{Key: key, Value: value}) } }
go
func Tag(key string, value interface{}) Option { return func(c *Options) { c.tags = append(c.tags, opentracing.Tag{Key: key, Value: value}) } }
[ "func", "Tag", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "Option", "{", "return", "func", "(", "c", "*", "Options", ")", "{", "c", ".", "tags", "=", "append", "(", "c", ".", "tags", ",", "opentracing", ".", "Tag", "{", "Key"...
// Tag creates an option that adds a tracer-level tag.
[ "Tag", "creates", "an", "option", "that", "adds", "a", "tracer", "-", "level", "tag", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/config/options.go#L121-L125
train
jaegertracing/jaeger-client-go
config/options.go
Injector
func Injector(format interface{}, injector jaeger.Injector) Option { return func(c *Options) { c.injectors[format] = injector } }
go
func Injector(format interface{}, injector jaeger.Injector) Option { return func(c *Options) { c.injectors[format] = injector } }
[ "func", "Injector", "(", "format", "interface", "{", "}", ",", "injector", "jaeger", ".", "Injector", ")", "Option", "{", "return", "func", "(", "c", "*", "Options", ")", "{", "c", ".", "injectors", "[", "format", "]", "=", "injector", "\n", "}", "\n...
// Injector registers an Injector with the given format.
[ "Injector", "registers", "an", "Injector", "with", "the", "given", "format", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/config/options.go#L128-L132
train
jaegertracing/jaeger-client-go
config/options.go
Extractor
func Extractor(format interface{}, extractor jaeger.Extractor) Option { return func(c *Options) { c.extractors[format] = extractor } }
go
func Extractor(format interface{}, extractor jaeger.Extractor) Option { return func(c *Options) { c.extractors[format] = extractor } }
[ "func", "Extractor", "(", "format", "interface", "{", "}", ",", "extractor", "jaeger", ".", "Extractor", ")", "Option", "{", "return", "func", "(", "c", "*", "Options", ")", "{", "c", ".", "extractors", "[", "format", "]", "=", "extractor", "\n", "}", ...
// Extractor registers an Extractor with the given format.
[ "Extractor", "registers", "an", "Extractor", "with", "the", "given", "format", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/config/options.go#L135-L139
train
jaegertracing/jaeger-client-go
span.go
SetOperationName
func (s *Span) SetOperationName(operationName string) opentracing.Span { s.Lock() defer s.Unlock() if s.context.IsSampled() { s.operationName = operationName } s.observer.OnSetOperationName(operationName) return s }
go
func (s *Span) SetOperationName(operationName string) opentracing.Span { s.Lock() defer s.Unlock() if s.context.IsSampled() { s.operationName = operationName } s.observer.OnSetOperationName(operationName) return s }
[ "func", "(", "s", "*", "Span", ")", "SetOperationName", "(", "operationName", "string", ")", "opentracing", ".", "Span", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "if", "s", ".", "context", ".", "IsSampled", ...
// SetOperationName sets or changes the operation name.
[ "SetOperationName", "sets", "or", "changes", "the", "operation", "name", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/span.go#L75-L83
train
jaegertracing/jaeger-client-go
span.go
LogFields
func (s *Span) LogFields(fields ...log.Field) { s.Lock() defer s.Unlock() if !s.context.IsSampled() { return } s.logFieldsNoLocking(fields...) }
go
func (s *Span) LogFields(fields ...log.Field) { s.Lock() defer s.Unlock() if !s.context.IsSampled() { return } s.logFieldsNoLocking(fields...) }
[ "func", "(", "s", "*", "Span", ")", "LogFields", "(", "fields", "...", "log", ".", "Field", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "if", "!", "s", ".", "context", ".", "IsSampled", "(", ")", "...
// LogFields implements opentracing.Span API
[ "LogFields", "implements", "opentracing", ".", "Span", "API" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/span.go#L104-L111
train
jaegertracing/jaeger-client-go
span.go
LogKV
func (s *Span) LogKV(alternatingKeyValues ...interface{}) { s.RLock() sampled := s.context.IsSampled() s.RUnlock() if !sampled { return } fields, err := log.InterleavedKVToFields(alternatingKeyValues...) if err != nil { s.LogFields(log.Error(err), log.String("function", "LogKV")) return } s.LogFields(fields...) }
go
func (s *Span) LogKV(alternatingKeyValues ...interface{}) { s.RLock() sampled := s.context.IsSampled() s.RUnlock() if !sampled { return } fields, err := log.InterleavedKVToFields(alternatingKeyValues...) if err != nil { s.LogFields(log.Error(err), log.String("function", "LogKV")) return } s.LogFields(fields...) }
[ "func", "(", "s", "*", "Span", ")", "LogKV", "(", "alternatingKeyValues", "...", "interface", "{", "}", ")", "{", "s", ".", "RLock", "(", ")", "\n", "sampled", ":=", "s", ".", "context", ".", "IsSampled", "(", ")", "\n", "s", ".", "RUnlock", "(", ...
// LogKV implements opentracing.Span API
[ "LogKV", "implements", "opentracing", ".", "Span", "API" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/span.go#L123-L136
train
jaegertracing/jaeger-client-go
span.go
Log
func (s *Span) Log(ld opentracing.LogData) { s.Lock() defer s.Unlock() if s.context.IsSampled() { if ld.Timestamp.IsZero() { ld.Timestamp = s.tracer.timeNow() } s.appendLog(ld.ToLogRecord()) } }
go
func (s *Span) Log(ld opentracing.LogData) { s.Lock() defer s.Unlock() if s.context.IsSampled() { if ld.Timestamp.IsZero() { ld.Timestamp = s.tracer.timeNow() } s.appendLog(ld.ToLogRecord()) } }
[ "func", "(", "s", "*", "Span", ")", "Log", "(", "ld", "opentracing", ".", "LogData", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "if", "s", ".", "context", ".", "IsSampled", "(", ")", "{", "if", "l...
// Log implements opentracing.Span API
[ "Log", "implements", "opentracing", ".", "Span", "API" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/span.go#L149-L158
train
jaegertracing/jaeger-client-go
span.go
FinishWithOptions
func (s *Span) FinishWithOptions(options opentracing.FinishOptions) { if options.FinishTime.IsZero() { options.FinishTime = s.tracer.timeNow() } s.observer.OnFinish(options) s.Lock() if s.context.IsSampled() { s.duration = options.FinishTime.Sub(s.startTime) // Note: bulk logs are not subject to maxLogsPerSpan limit if options.LogRecords != nil { s.logs = append(s.logs, options.LogRecords...) } for _, ld := range options.BulkLogData { s.logs = append(s.logs, ld.ToLogRecord()) } } s.Unlock() // call reportSpan even for non-sampled traces, to return span to the pool // and update metrics counter s.tracer.reportSpan(s) }
go
func (s *Span) FinishWithOptions(options opentracing.FinishOptions) { if options.FinishTime.IsZero() { options.FinishTime = s.tracer.timeNow() } s.observer.OnFinish(options) s.Lock() if s.context.IsSampled() { s.duration = options.FinishTime.Sub(s.startTime) // Note: bulk logs are not subject to maxLogsPerSpan limit if options.LogRecords != nil { s.logs = append(s.logs, options.LogRecords...) } for _, ld := range options.BulkLogData { s.logs = append(s.logs, ld.ToLogRecord()) } } s.Unlock() // call reportSpan even for non-sampled traces, to return span to the pool // and update metrics counter s.tracer.reportSpan(s) }
[ "func", "(", "s", "*", "Span", ")", "FinishWithOptions", "(", "options", "opentracing", ".", "FinishOptions", ")", "{", "if", "options", ".", "FinishTime", ".", "IsZero", "(", ")", "{", "options", ".", "FinishTime", "=", "s", ".", "tracer", ".", "timeNow...
// FinishWithOptions implements opentracing.Span API
[ "FinishWithOptions", "implements", "opentracing", ".", "Span", "API" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/span.go#L189-L209
train
jaegertracing/jaeger-client-go
span.go
Context
func (s *Span) Context() opentracing.SpanContext { s.Lock() defer s.Unlock() return s.context }
go
func (s *Span) Context() opentracing.SpanContext { s.Lock() defer s.Unlock() return s.context }
[ "func", "(", "s", "*", "Span", ")", "Context", "(", ")", "opentracing", ".", "SpanContext", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "return", "s", ".", "context", "\n", "}" ]
// Context implements opentracing.Span API
[ "Context", "implements", "opentracing", ".", "Span", "API" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/span.go#L212-L216
train
jaegertracing/jaeger-client-go
span.go
OperationName
func (s *Span) OperationName() string { s.RLock() defer s.RUnlock() return s.operationName }
go
func (s *Span) OperationName() string { s.RLock() defer s.RUnlock() return s.operationName }
[ "func", "(", "s", "*", "Span", ")", "OperationName", "(", ")", "string", "{", "s", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "RUnlock", "(", ")", "\n", "return", "s", ".", "operationName", "\n", "}" ]
// OperationName allows retrieving current operation name.
[ "OperationName", "allows", "retrieving", "current", "operation", "name", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/span.go#L230-L234
train
jaegertracing/jaeger-client-go
span.go
Release
func (s *Span) Release() { if atomic.AddInt32(&s.referenceCounter, -1) == -1 { s.tracer.spanAllocator.Put(s) } }
go
func (s *Span) Release() { if atomic.AddInt32(&s.referenceCounter, -1) == -1 { s.tracer.spanAllocator.Put(s) } }
[ "func", "(", "s", "*", "Span", ")", "Release", "(", ")", "{", "if", "atomic", ".", "AddInt32", "(", "&", "s", ".", "referenceCounter", ",", "-", "1", ")", "==", "-", "1", "{", "s", ".", "tracer", ".", "spanAllocator", ".", "Put", "(", "s", ")",...
// Release decrements object counter and return to the // allocator manager when counter will below zero
[ "Release", "decrements", "object", "counter", "and", "return", "to", "the", "allocator", "manager", "when", "counter", "will", "below", "zero" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/span.go#L244-L248
train
jaegertracing/jaeger-client-go
span.go
reset
func (s *Span) reset() { s.firstInProcess = false s.context = emptyContext s.operationName = "" s.tracer = nil s.startTime = time.Time{} s.duration = 0 s.observer = nil atomic.StoreInt32(&s.referenceCounter, 0) // Note: To reuse memory we can save the pointers on the heap s.tags = s.tags[:0] s.logs = s.logs[:0] s.references = s.references[:0] }
go
func (s *Span) reset() { s.firstInProcess = false s.context = emptyContext s.operationName = "" s.tracer = nil s.startTime = time.Time{} s.duration = 0 s.observer = nil atomic.StoreInt32(&s.referenceCounter, 0) // Note: To reuse memory we can save the pointers on the heap s.tags = s.tags[:0] s.logs = s.logs[:0] s.references = s.references[:0] }
[ "func", "(", "s", "*", "Span", ")", "reset", "(", ")", "{", "s", ".", "firstInProcess", "=", "false", "\n", "s", ".", "context", "=", "emptyContext", "\n", "s", ".", "operationName", "=", "\"\"", "\n", "s", ".", "tracer", "=", "nil", "\n", "s", "...
// reset span state and release unused data
[ "reset", "span", "state", "and", "release", "unused", "data" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/span.go#L251-L265
train
jaegertracing/jaeger-client-go
span.go
setSamplingPriority
func setSamplingPriority(s *Span, value interface{}) bool { val, ok := value.(uint16) if !ok { return false } s.Lock() defer s.Unlock() if val == 0 { s.context.flags = s.context.flags & (^flagSampled) return true } if s.tracer.isDebugAllowed(s.operationName) { s.context.flags = s.context.flags | flagDebug | flagSampled return true } return false }
go
func setSamplingPriority(s *Span, value interface{}) bool { val, ok := value.(uint16) if !ok { return false } s.Lock() defer s.Unlock() if val == 0 { s.context.flags = s.context.flags & (^flagSampled) return true } if s.tracer.isDebugAllowed(s.operationName) { s.context.flags = s.context.flags | flagDebug | flagSampled return true } return false }
[ "func", "setSamplingPriority", "(", "s", "*", "Span", ",", "value", "interface", "{", "}", ")", "bool", "{", "val", ",", "ok", ":=", "value", ".", "(", "uint16", ")", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "s", ".", "Lock...
// setSamplingPriority returns true if the flag was updated successfully, false otherwise.
[ "setSamplingPriority", "returns", "true", "if", "the", "flag", "was", "updated", "successfully", "false", "otherwise", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/span.go#L272-L288
train
jaegertracing/jaeger-client-go
jaeger_thrift_span.go
BuildJaegerThrift
func BuildJaegerThrift(span *Span) *j.Span { span.Lock() defer span.Unlock() startTime := utils.TimeToMicrosecondsSinceEpochInt64(span.startTime) duration := span.duration.Nanoseconds() / int64(time.Microsecond) jaegerSpan := &j.Span{ TraceIdLow: int64(span.context.traceID.Low), TraceIdHigh: int64(span.context.traceID.High), SpanId: int64(span.context.spanID), ParentSpanId: int64(span.context.parentID), OperationName: span.operationName, Flags: int32(span.context.flags), StartTime: startTime, Duration: duration, Tags: buildTags(span.tags, span.tracer.options.maxTagValueLength), Logs: buildLogs(span.logs), References: buildReferences(span.references), } return jaegerSpan }
go
func BuildJaegerThrift(span *Span) *j.Span { span.Lock() defer span.Unlock() startTime := utils.TimeToMicrosecondsSinceEpochInt64(span.startTime) duration := span.duration.Nanoseconds() / int64(time.Microsecond) jaegerSpan := &j.Span{ TraceIdLow: int64(span.context.traceID.Low), TraceIdHigh: int64(span.context.traceID.High), SpanId: int64(span.context.spanID), ParentSpanId: int64(span.context.parentID), OperationName: span.operationName, Flags: int32(span.context.flags), StartTime: startTime, Duration: duration, Tags: buildTags(span.tags, span.tracer.options.maxTagValueLength), Logs: buildLogs(span.logs), References: buildReferences(span.references), } return jaegerSpan }
[ "func", "BuildJaegerThrift", "(", "span", "*", "Span", ")", "*", "j", ".", "Span", "{", "span", ".", "Lock", "(", ")", "\n", "defer", "span", ".", "Unlock", "(", ")", "\n", "startTime", ":=", "utils", ".", "TimeToMicrosecondsSinceEpochInt64", "(", "span"...
// BuildJaegerThrift builds jaeger span based on internal span.
[ "BuildJaegerThrift", "builds", "jaeger", "span", "based", "on", "internal", "span", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/jaeger_thrift_span.go#L27-L46
train
jaegertracing/jaeger-client-go
jaeger_thrift_span.go
BuildJaegerProcessThrift
func BuildJaegerProcessThrift(span *Span) *j.Process { span.Lock() defer span.Unlock() return buildJaegerProcessThrift(span.tracer) }
go
func BuildJaegerProcessThrift(span *Span) *j.Process { span.Lock() defer span.Unlock() return buildJaegerProcessThrift(span.tracer) }
[ "func", "BuildJaegerProcessThrift", "(", "span", "*", "Span", ")", "*", "j", ".", "Process", "{", "span", ".", "Lock", "(", ")", "\n", "defer", "span", ".", "Unlock", "(", ")", "\n", "return", "buildJaegerProcessThrift", "(", "span", ".", "tracer", ")", ...
// BuildJaegerProcessThrift creates a thrift Process type.
[ "BuildJaegerProcessThrift", "creates", "a", "thrift", "Process", "type", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/jaeger_thrift_span.go#L49-L53
train
jaegertracing/jaeger-client-go
zipkin/propagation.go
NewZipkinB3HTTPHeaderPropagator
func NewZipkinB3HTTPHeaderPropagator(opts ...Option) Propagator { p := Propagator{baggagePrefix: "baggage-"} for _, opt := range opts { opt(&p) } return p }
go
func NewZipkinB3HTTPHeaderPropagator(opts ...Option) Propagator { p := Propagator{baggagePrefix: "baggage-"} for _, opt := range opts { opt(&p) } return p }
[ "func", "NewZipkinB3HTTPHeaderPropagator", "(", "opts", "...", "Option", ")", "Propagator", "{", "p", ":=", "Propagator", "{", "baggagePrefix", ":", "\"baggage-\"", "}", "\n", "for", "_", ",", "opt", ":=", "range", "opts", "{", "opt", "(", "&", "p", ")", ...
// NewZipkinB3HTTPHeaderPropagator creates a Propagator for extracting and injecting // Zipkin HTTP B3 headers into SpanContexts. Baggage is by default enabled and uses prefix // 'baggage-'.
[ "NewZipkinB3HTTPHeaderPropagator", "creates", "a", "Propagator", "for", "extracting", "and", "injecting", "Zipkin", "HTTP", "B3", "headers", "into", "SpanContexts", ".", "Baggage", "is", "by", "default", "enabled", "and", "uses", "prefix", "baggage", "-", "." ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/zipkin/propagation.go#L44-L50
train
jaegertracing/jaeger-client-go
zipkin/propagation.go
Inject
func (p Propagator) Inject( sc jaeger.SpanContext, abstractCarrier interface{}, ) error { textMapWriter, ok := abstractCarrier.(opentracing.TextMapWriter) if !ok { return opentracing.ErrInvalidCarrier } textMapWriter.Set("x-b3-traceid", sc.TraceID().String()) if sc.ParentID() != 0 { textMapWriter.Set("x-b3-parentspanid", strconv.FormatUint(uint64(sc.ParentID()), 16)) } textMapWriter.Set("x-b3-spanid", strconv.FormatUint(uint64(sc.SpanID()), 16)) if sc.IsSampled() { textMapWriter.Set("x-b3-sampled", "1") } else { textMapWriter.Set("x-b3-sampled", "0") } sc.ForeachBaggageItem(func(k, v string) bool { textMapWriter.Set(p.baggagePrefix+k, v) return true }) return nil }
go
func (p Propagator) Inject( sc jaeger.SpanContext, abstractCarrier interface{}, ) error { textMapWriter, ok := abstractCarrier.(opentracing.TextMapWriter) if !ok { return opentracing.ErrInvalidCarrier } textMapWriter.Set("x-b3-traceid", sc.TraceID().String()) if sc.ParentID() != 0 { textMapWriter.Set("x-b3-parentspanid", strconv.FormatUint(uint64(sc.ParentID()), 16)) } textMapWriter.Set("x-b3-spanid", strconv.FormatUint(uint64(sc.SpanID()), 16)) if sc.IsSampled() { textMapWriter.Set("x-b3-sampled", "1") } else { textMapWriter.Set("x-b3-sampled", "0") } sc.ForeachBaggageItem(func(k, v string) bool { textMapWriter.Set(p.baggagePrefix+k, v) return true }) return nil }
[ "func", "(", "p", "Propagator", ")", "Inject", "(", "sc", "jaeger", ".", "SpanContext", ",", "abstractCarrier", "interface", "{", "}", ",", ")", "error", "{", "textMapWriter", ",", "ok", ":=", "abstractCarrier", ".", "(", "opentracing", ".", "TextMapWriter",...
// Inject conforms to the Injector interface for decoding Zipkin HTTP B3 headers
[ "Inject", "conforms", "to", "the", "Injector", "interface", "for", "decoding", "Zipkin", "HTTP", "B3", "headers" ]
896f2abd37e099bae3eae942250d1a37e4bdce0b
https://github.com/jaegertracing/jaeger-client-go/blob/896f2abd37e099bae3eae942250d1a37e4bdce0b/zipkin/propagation.go#L53-L77
train