Пример #1
0
        public async Task <HerculesResult <IList <Guid> > > GetTraceIdsAsync(string tracePrefix, TimeSpan timeout)
        {
            try
            {
                var request = Request.Get("/tracing").WithAdditionalQueryParameter("prefix", tracePrefix);

                var result = await client.SendAsync(request, timeout).ConfigureAwait(false);

                var status = ResponseAnalyzer.Analyze(result.Response, out var errorMessage);

                var payload = status == HerculesStatus.Success
                    ? JsonConvert
                              .DeserializeObject <List <string> >(result.Response.Content.ToString())
                              .Select(Guid.Parse)
                              .ToList()
                    : null;

                return(new HerculesResult <IList <Guid> >(status, payload, errorMessage));
            }
            catch (Exception error)
            {
                log.Error(error);
                return(new HerculesResult <IList <Guid> >(HerculesStatus.UnknownError, null, error.Message));
            }
        }
        public async Task <ReadTraceResult> ReadAsync(TraceReadQuery query, TimeSpan timeout, CancellationToken cancellationToken = default)
        {
            try
            {
                var request = Request.Get("/trace").WithTraceReadQuery(query);
                var result  = await client.SendAsync(request, timeout, cancellationToken : cancellationToken).ConfigureAwait(false);

                var status = ResponseAnalyzer.Analyze(result.Response, out var errorMessage);

                var payload = default(ReadTracePayload);
                if (status == HerculesStatus.Success)
                {
                    payload = CreateReadTracePayload(JsonConvert.DeserializeObject <TraceResponseDto>(result.Response.Content.ToString()));
                }

                return(new ReadTraceResult(status, payload, errorMessage));
            }
            catch (Exception error)
            {
                log.Error(error);
                return(new ReadTraceResult(HerculesStatus.UnknownError, default, error.Message));