コード例 #1
0
        public TraceAs(string serviceName, string message, OperationType operationType, Dictionary <string, string> tags = null, bool hasInnerTrace = false)
        {
            try
            {
                _hasInnerTrace   = hasInnerTrace;
                zipkinAnnotation = ZipkinAnnotationFactory.GetAnnotationObject(operationType);

                trace = Trace.Current == null?Trace.Create() : Trace.Current.Child();

                trace.Record(Annotations.ServiceName(serviceName));
                trace.Record(zipkinAnnotation.AnnotationStart(message));
                trace.Record(Annotations.Rpc(message));
                if (tags != null)
                {
                    foreach (var key in tags.Keys)
                    {
                        trace.Record(Annotations.Tag(key, tags[key]));
                    }
                }

                if (hasInnerTrace)
                {
                    Trace.Current = trace;
                }
            }
            catch (Exception e)
            {
            }
        }
コード例 #2
0
        public static IZipkinAnnotation GetAnnotationObject(OperationType operationType)
        {
            IZipkinAnnotation zipkinAnnotation = null;

            switch (operationType)
            {
            case OperationType.LocalOperation:
                zipkinAnnotation = new ZipkinLocalOperationAnnotation();
                break;

            case OperationType.Client:
                zipkinAnnotation = new ZipkinClientAnnotations();
                break;

            case OperationType.Server:
                zipkinAnnotation = new ZipkinServerAnnotations();
                break;
            }

            return(zipkinAnnotation);
        }