コード例 #1
0
        internal ZipkinSpan GenerateSpan(ISpanData spanData, ZipkinEndpoint localEndpoint)
        {
            ISpanContext context        = spanData.Context;
            long         startTimestamp = ToEpochMicros(spanData.StartTimestamp);

            long endTimestamp = ToEpochMicros(spanData.EndTimestamp);

            ZipkinSpan.Builder spanBuilder =
                ZipkinSpan.NewBuilder()
                .TraceId(EncodeTraceId(context.TraceId))
                .Id(EncodeSpanId(context.SpanId))
                .Kind(ToSpanKind(spanData))
                .Name(spanData.Name)
                .Timestamp(ToEpochMicros(spanData.StartTimestamp))
                .Duration(endTimestamp - startTimestamp)
                .LocalEndpoint(localEndpoint);

            if (spanData.ParentSpanId != null && spanData.ParentSpanId.IsValid)
            {
                spanBuilder.ParentId(EncodeSpanId(spanData.ParentSpanId));
            }

            foreach (var label in spanData.Attributes.AttributeMap)
            {
                spanBuilder.PutTag(label.Key, AttributeValueToString(label.Value));
            }

            Status status = spanData.Status;

            if (status != null)
            {
                spanBuilder.PutTag(STATUS_CODE, status.CanonicalCode.ToString());
                if (status.Description != null)
                {
                    spanBuilder.PutTag(STATUS_DESCRIPTION, status.Description);
                }
            }

            foreach (var annotation in spanData.Annotations.Events)
            {
                spanBuilder.AddAnnotation(
                    ToEpochMicros(annotation.Timestamp), annotation.Event.Description);
            }

            foreach (var networkEvent in spanData.MessageEvents.Events)
            {
                spanBuilder.AddAnnotation(
                    ToEpochMicros(networkEvent.Timestamp), networkEvent.Event.Type.ToString());
            }

            return(spanBuilder.Build());
        }
コード例 #2
0
        private ZipkinEndpoint GetLocalZipkinEndpoint()
        {
            var result = new ZipkinEndpoint()
            {
                ServiceName = _options.ServiceName
            };

            string hostName = ResolveHostName();

            if (!string.IsNullOrEmpty(hostName))
            {
                result.Ipv4 = ResolveHostAddress(hostName, AddressFamily.InterNetwork);
                result.Ipv6 = ResolveHostAddress(hostName, AddressFamily.InterNetworkV6);
            }

            return(result);
        }
コード例 #3
0
        public override bool Equals(object o)
        {
            if (o == this)
            {
                return(true);
            }

            if (!(o is ZipkinEndpoint))
            {
                return(false);
            }

            ZipkinEndpoint that = (ZipkinEndpoint)o;

            return(((ServiceName == null)
              ? (that.ServiceName == null) : ServiceName.Equals(that.ServiceName)) &&
                   ((Ipv4 == null) ? (that.Ipv4 == null) : Ipv4.Equals(that.Ipv4)) &&
                   ((Ipv6 == null) ? (that.Ipv6 == null) : Ipv6.Equals(that.Ipv6)) &&
                   Port.Equals(that.Port));
        }
コード例 #4
0
 public TraceExporterHandler(ITraceExporterOptions options, ILogger logger = null)
 {
     _options       = options;
     _logger        = logger;
     _localEndpoint = GetLocalZipkinEndpoint();
 }
コード例 #5
0
 internal Builder RemoteEndpoint(ZipkinEndpoint v)
 {
     remoteEndpoint = v;
     return(this);
 }
コード例 #6
0
 internal Builder LocalEndpoint(ZipkinEndpoint v)
 {
     localEndpoint = v;
     return(this);
 }