Documentation
¶
Index ¶
- Variables
- func GetClientCalls(trace *apmmodel.OTelTrace, spanId string) []*model.ApmClientCall
- func GetErrorSpans(node *apmmodel.OtelServiceNode) []*model.ErrorSpan
- func GetMatchSampledSpanTrace(apmType string, service *apmmodel.OtelServiceNode, ...) *model.Trace
- func NewApmClientCall(clientSpan *apmmodel.OtelSpan, serverEntrySpan *apmmodel.OtelSpan) *model.ApmClientCall
- func SQLParseOperationAndTable(query string) (string, string)
- func SQLParseOperationAndTableNEW(query string) (string, string)
- type AdapterHTTPClient
- func (c *AdapterHTTPClient) QueryDetail(ctx context.Context, queryParams *api.QueryParams) ([]*model.OtelSpan, error)
- func (c *AdapterHTTPClient) QueryList(ctx context.Context, queryParams *api.QueryParams) ([]*model.OtelServiceNode, error)
- func (c *AdapterHTTPClient) SetRountTriper(rt http.RoundTripper)
- type ApmTraceClient
- func (client *ApmTraceClient) FillMutatedSpan(ctx context.Context, clusterID string, apmType string, traceId string, ...) error
- func (client *ApmTraceClient) NeedGetDetailSpan(ctx context.Context, apmType string) bool
- func (client *ApmTraceClient) QueryErrorTraceTree(ctx context.Context, clusterID string, traceId string, traces *model.Traces) (*model.ErrorTreeNode, error)
- func (client *ApmTraceClient) QueryMutatedSlowTraceTree(ctx context.Context, clusterID string, traceId string, traces *model.Traces) (*model.TraceTreeNode, []*model.ApmClientCall, error)
- func (client *ApmTraceClient) QueryServices(ctx context.Context, clusterID string, apmType string, traceId string, ...) ([]*apmmodel.OtelServiceNode, error)
- func (client *ApmTraceClient) QueryTrace(ctx context.Context, clusterID string, apmType string, traceId string, ...) (*apmmodel.OTelTrace, error)
- type CalcMutatedNodeFn
- type ErrorTraceTree
- type NodeSpanTrace
- type NodeSpanTraces
- type QueryParams
- type TraceTree
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrUnknownApmType error = errors.New("no match apmType is found")
)
Functions ¶
func GetClientCalls ¶
func GetClientCalls(trace *apmmodel.OTelTrace, spanId string) []*model.ApmClientCall
func GetErrorSpans ¶
func GetErrorSpans(node *apmmodel.OtelServiceNode) []*model.ErrorSpan
func NewApmClientCall ¶
Types ¶
type AdapterHTTPClient ¶
type AdapterHTTPClient struct {
TraceListAddress string
TraceDetailAddress string
Timeout time.Duration
// contains filtered or unexported fields
}
func NewAdapterHTTPClient ¶
func NewAdapterHTTPClient(address string, timeout int64) *AdapterHTTPClient
func (*AdapterHTTPClient) QueryDetail ¶
func (c *AdapterHTTPClient) QueryDetail(ctx context.Context, queryParams *api.QueryParams) ([]*model.OtelSpan, error)
func (*AdapterHTTPClient) QueryList ¶
func (c *AdapterHTTPClient) QueryList(ctx context.Context, queryParams *api.QueryParams) ([]*model.OtelServiceNode, error)
func (*AdapterHTTPClient) SetRountTriper ¶
func (c *AdapterHTTPClient) SetRountTriper(rt http.RoundTripper)
type ApmTraceClient ¶
type ApmTraceClient struct {
// contains filtered or unexported fields
}
func NewApmTraceClient ¶
func NewApmTraceClientByAPI ¶
func NewApmTraceClientByAPI(api api.AdapterAPI, muatedRatio int, mutateNodeMode string, getDetailTypes []string) *ApmTraceClient
func (*ApmTraceClient) FillMutatedSpan ¶
func (client *ApmTraceClient) FillMutatedSpan(ctx context.Context, clusterID string, apmType string, traceId string, serviceNode *apmmodel.OtelServiceNode) error
func (*ApmTraceClient) NeedGetDetailSpan ¶
func (client *ApmTraceClient) NeedGetDetailSpan(ctx context.Context, apmType string) bool
func (*ApmTraceClient) QueryErrorTraceTree ¶
func (client *ApmTraceClient) QueryErrorTraceTree(ctx context.Context, clusterID string, traceId string, traces *model.Traces) (*model.ErrorTreeNode, error)
func (*ApmTraceClient) QueryMutatedSlowTraceTree ¶
func (client *ApmTraceClient) QueryMutatedSlowTraceTree(ctx context.Context, clusterID string, traceId string, traces *model.Traces) (*model.TraceTreeNode, []*model.ApmClientCall, error)
func (*ApmTraceClient) QueryServices ¶
func (client *ApmTraceClient) QueryServices(ctx context.Context, clusterID string, apmType string, traceId string, rootTrace *model.TraceLabels) ([]*apmmodel.OtelServiceNode, error)
func (*ApmTraceClient) QueryTrace ¶
type CalcMutatedNodeFn ¶
type CalcMutatedNodeFn func(tree *TraceTree, traceId string, ratioThreshold int) (*model.TraceTreeNode, error)
var CalcByMutatedService CalcMutatedNodeFn = func(tree *TraceTree, traceId string, ratioThreshold int) (*model.TraceTreeNode, error) { serviceEndPoints := newServiceEndPoints() for _, v := range tree.NodeMap { v.CalcMutateValue() serviceEndPoints.addMutateSpan(v) } sort.Sort(byServiceMutatedValue(serviceEndPoints.services)) if len(serviceEndPoints.services) == 0 { return nil, fmt.Errorf("trace[%s] has no mutated service", traceId) } serviceEndPoint := serviceEndPoints.services[0] duration := tree.Root.TotalTime threshold := duration * uint64(ratioThreshold) / 100 if serviceEndPoint.SelfTime < threshold { var percent float64 = 0 if duration > 0 { percent = float64(serviceEndPoint.SelfTime*100) / float64(duration) } return nil, fmt.Errorf("service(%s) selfTime(%sms) has not enough duration ratio(%s%%)", serviceEndPoint.ServiceName, strconv.FormatFloat(float64(serviceEndPoint.SelfTime)/1000000, 'f', 2, 64), strconv.FormatFloat(percent, 'f', 2, 64)) } node, _ := serviceEndPoint.getMutateNode() if node.MutatedValue > 0 { return node, nil } return nil, fmt.Errorf("Instance(%s) URL(%s) is not mutated. Mutated[%d], Self: %d", node.Id, node.Url, node.MutatedValue, node.SelfTime) }
var CalcByMutatedSpan CalcMutatedNodeFn = func(tree *TraceTree, traceId string, ratioThreshold int) (*model.TraceTreeNode, error) { sortedNodes := make([]*model.TraceTreeNode, 0) for _, v := range tree.NodeMap { v.CalcMutateValue() if tree.Root.SpanId == v.SpanId && v.HasVNodeChild() { continue } sortedNodes = append(sortedNodes, v) } sort.Sort(byMuatedValue(sortedNodes)) duration := tree.Root.TotalTime threshold := duration * uint64(ratioThreshold) / 100 var profiledNode *model.TraceTreeNode = nil node := sortedNodes[0] if node.MutatedValue > 0 { if node.SelfTime >= threshold { return node, nil } if profiledNode == nil || profiledNode.SelfTime < node.SelfTime { profiledNode = node } } if profiledNode == nil { return nil, fmt.Errorf("Instance(%s) is not mutated. Mutated[%d], Self: %d", node.Id, node.MutatedValue, node.SelfTime) } var percent float64 = 0 if duration > 0 { percent = float64(profiledNode.SelfTime*100) / float64(duration) } return nil, fmt.Errorf("Instance(%s) selfTime(%sms) has not enough duration ratio(%s%%)", profiledNode.Id, strconv.FormatFloat(float64(profiledNode.SelfTime)/1000000, 'f', 2, 64), strconv.FormatFloat(percent, 'f', 2, 64)) }
var CalcByTop3MutatedService CalcMutatedNodeFn = func(tree *TraceTree, traceId string, ratioThreshold int) (*model.TraceTreeNode, error) { serviceEndPoints := newServiceEndPoints() for _, v := range tree.NodeMap { v.CalcMutateValue() serviceEndPoints.addMutateSpan(v) } sort.Sort(byServiceMutatedValue(serviceEndPoints.services)) if len(serviceEndPoints.services) == 0 { return nil, fmt.Errorf("trace[%s] has no mutated service", traceId) } duration := tree.Root.TotalTime threshold := duration * uint64(ratioThreshold) / 100 var profiledMutatedNode *model.TraceTreeNode var profiled bool for i, serviceEndPoint := range serviceEndPoints.services { if i == 3 { break } if serviceEndPoint.SelfTime < threshold { var percent float64 = 0 if duration > 0 { percent = float64(serviceEndPoint.SelfTime*100) / float64(duration) } log.Printf("The Top[%d] service(%s) selfTime(%sms) has not enough duration ratio(%s%%)", i+1, serviceEndPoint.ServiceName, strconv.FormatFloat(float64(serviceEndPoint.SelfTime)/1000000, 'f', 2, 64), strconv.FormatFloat(percent, 'f', 2, 64)) continue } profiledMutatedNode, profiled = serviceEndPoint.getMutateNode() if profiledMutatedNode.MutatedValue > 0 && profiled { return profiledMutatedNode, nil } } if profiledMutatedNode == nil { return nil, fmt.Errorf("no Top3 service has enough duration ratio") } else { return nil, fmt.Errorf("top3 node [%s] has enough duration ratio but is not profiled", profiledMutatedNode.Id) } }
type ErrorTraceTree ¶
type ErrorTraceTree struct {
Root *model.ErrorTreeNode
NodeMap map[string]*model.ErrorTreeNode
}
func BuildErrorTree ¶
func ConvertErrorTree ¶
func ConvertErrorTree(spanTrace *NodeSpanTrace) *ErrorTraceTree
func (*ErrorTraceTree) GetRootCauseErrorNode ¶
func (tree *ErrorTraceTree) GetRootCauseErrorNode(traceId string) (*model.ErrorTreeNode, error)
type NodeSpanTrace ¶
func (*NodeSpanTrace) GetClientCalls ¶
func (trace *NodeSpanTrace) GetClientCalls(spanId string) []*model.ApmClientCall
func (*NodeSpanTrace) GetServiceNode ¶
func (trace *NodeSpanTrace) GetServiceNode(spanId string) *apmmodel.OtelServiceNode
type NodeSpanTraces ¶
type NodeSpanTraces struct {
Traces []*NodeSpanTrace
}
func NewNodeSpanTraces ¶
func NewNodeSpanTraces(apmType string, serviceNodes []*apmmodel.OtelServiceNode, sampledTraces *model.Traces) *NodeSpanTraces
type QueryParams ¶
type TraceTree ¶
type TraceTree struct {
Root *model.TraceTreeNode
NodeMap map[string]*model.TraceTreeNode
}
func BuildTopologyTree ¶
func ConvertSlowTree ¶
func ConvertSlowTree(spanTrace *NodeSpanTrace) *TraceTree
func (*TraceTree) GetMutatedTraceNode ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.