Example #1
0
        static async Task Main(string[] args)
        {
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

            //Console.WriteLine("Hello World!");
            var channel = GrpcChannel.ForAddress("http://localhost:6003", new GrpcChannelOptions()
            {
                //DisposeHttpClient = true,
                ThrowOperationCanceledOnCancellation = true,
            });



            var client   = new Jaeger.ApiV2.QueryService.QueryServiceClient(channel);
            var response = client.GetServices(new Jaeger.ApiV2.GetServicesRequest()
            {
            }, new Grpc.Core.CallOptions());

            Console.WriteLine(string.Join(",", response.Services));

            var response1 = client.GetOperations(new Jaeger.ApiV2.GetOperationsRequest()
            {
                Service = response.Services[0],
            }, new Grpc.Core.CallOptions());

            Console.WriteLine(string.Join(",", response1.OperationNames));

            var response2 = client.GetTrace(new Jaeger.ApiV2.GetTraceRequest()
            {
                TraceId = ByteString.CopyFrom(Jaeger.TraceId.FromString("4399add89a1b8a02").ToByteArray()),
            }, new Grpc.Core.CallOptions());

            while (await response2.ResponseStream.MoveNext(CancellationToken.None))
            {
                Console.WriteLine(string.Join("|", response2.ResponseStream.Current.Spans.Select(s => s.SpanId.ToString())));
            }
            var ps = new Jaeger.ApiV2.TraceQueryParameters()
            {
                ServiceName  = response.Services[0],
                StartTimeMin = Timestamp.FromDateTimeOffset(DateTimeOffset.Now.AddDays(-7)),
                //OperationName= response1.OperationNames[0],
                StartTimeMax  = Timestamp.FromDateTimeOffset(DateTimeOffset.Now),
                OperationName = "HTTP GET",
                //DurationMin=Duration.FromTimeSpan(TimeSpan.Zero)
            };
            //ps.Tags.Add("http.method", "GET");
            var response3 = client.FindTraces(new Jaeger.ApiV2.FindTracesRequest()
            {
                Query = ps
            }, new Grpc.Core.CallOptions());

            while (await response3.ResponseStream.MoveNext(CancellationToken.None))
            {
                Console.WriteLine(string.Join("|", response3.ResponseStream.Current.Spans.Select(s => s.SpanId.ToString())));
            }
        }
Example #2
0
        public async Task <QueryResponseServices <TracingDto> > Services(string traceId)
        {
            if (string.IsNullOrEmpty(traceId))
            {
                return new QueryResponseServices <TracingDto>()
                       {
                           Data = new TracingDto[0],
                       }
            }
            ;
            var result = _QueryServiceClient.GetTrace(new Jaeger.ApiV2.GetTraceRequest()
            {
                TraceId = ByteString.CopyFrom(Jaeger.TraceId.FromString(traceId).ToByteArray())
            });
            List <SpanDto> spans = new List <SpanDto>();
            Dictionary <string, SpanProcess> dict_process = new Dictionary <string, SpanProcess>();

            while (await result.ResponseStream.MoveNext(CancellationToken.None))
            {
                foreach (var span in result.ResponseStream.Current.Spans)
                {
                    if (!dict_process.ContainsKey(span.ProcessId))
                    {
                        dict_process.Add(span.ProcessId, _Mapper.Map <SpanProcess>(span.Process));
                    }
                    spans.Add(_Mapper.Map <SpanDto>(span));
                }
            }
            List <TracingDto> tracingDtos = new List <TracingDto>();

            tracingDtos.Add(Convert(spans, dict_process));
            return(new QueryResponseServices <TracingDto>()
            {
                Data = tracingDtos
            });
        }