예제 #1
0
// buildZipkinSpan builds zipkin span based on tchannel span.
func buildZipkinSpan(span tc.Span, annotations []tc.Annotation, binaryAnnotations []tc.BinaryAnnotation, name string, endpoint *tc.Endpoint) *tcollector.Span {
	host := tcollector.Endpoint{
		Ipv4:        (int32)(inetAton(endpoint.Ipv4)),
		Port:        endpoint.Port,
		ServiceName: endpoint.ServiceName,
	}

	// TODO Add BinaryAnnotations
	thriftSpan := tcollector.Span{
		TraceId:     uint64ToBytes(span.TraceID()),
		Host:        &host,
		Name:        name,
		Id:          uint64ToBytes(span.SpanID()),
		ParentId:    uint64ToBytes(span.ParentID()),
		Annotations: buildZipkinAnnotations(annotations),
		Debug:       false,
	}

	return &thriftSpan
}
// buildZipkinSpan builds zipkin span based on tchannel span.
func buildZipkinSpan(span tc.Span, annotations []tc.Annotation, binaryAnnotations []tc.BinaryAnnotation, targetEndpoint tc.TargetEndpoint) *tcollector.Span {
	hostport := strings.Split(targetEndpoint.HostPort, ":")
	port, _ := strconv.ParseInt(hostport[1], 10, 32)
	host := tcollector.Endpoint{
		Ipv4:        int32(inetAton(hostport[0])),
		Port:        int32(port),
		ServiceName: targetEndpoint.ServiceName,
	}

	// TODO Add BinaryAnnotations
	thriftSpan := tcollector.Span{
		TraceId:     uint64ToBytes(span.TraceID()),
		Host:        &host,
		Name:        targetEndpoint.Operation,
		Id:          uint64ToBytes(span.SpanID()),
		ParentId:    uint64ToBytes(span.ParentID()),
		Annotations: buildZipkinAnnotations(annotations),
		Debug:       false,
	}

	return &thriftSpan
}