コード例 #1
0
        private Task SendSpansAsync(LightStepReport report, CancellationToken cancellationToken)
        {
            var requestUri = this.options.Satellite;
            var request    = new HttpRequestMessage(HttpMethod.Post, requestUri);
            var jsonReport = JsonConvert.SerializeObject(report);

            request.Content = new StringContent(jsonReport, Encoding.UTF8, "application/json");
            return(this.PostSpansAsync(this.httpClient, request, cancellationToken));
        }
コード例 #2
0
        private Task SendSpansAsync(LightStepReport report, CancellationToken cancellationToken)
        {
            var requestUri = this.options.Satellite;
            var request    = new HttpRequestMessage(HttpMethod.Post, requestUri);
            var jsonReport = JsonConvert.SerializeObject(report);

            request.Content = new StringContent(jsonReport, Encoding.UTF8, "application/json");

            // avoid cancelling here: this is no return point: if we reached this point
            // and cancellation is requested, it's better if we try to finish sending spans rather than drop it
            return(this.PostSpansAsync(this.httpClient, request));
        }
コード例 #3
0
        public override async Task <ExportResult> ExportAsync(IEnumerable <Span> spanDataList, CancellationToken cancellationToken)
        {
            var lsReport = new LightStepReport
            {
                Auth = new Authentication {
                    AccessToken = this.options.AccessToken
                },
                Reporter = new Reporter
                {
                    // TODO: ReporterID should be randomly generated.
                    ReporterId = 219,
                    Tags       = new List <Tag>
                    {
                        new Tag {
                            Key = "lightstep.component_name", StringValue = this.options.ServiceName
                        },
                    },
                },
            };

            foreach (var data in spanDataList)
            {
                lsReport.Spans.Add(data.ToLightStepSpan());
            }

            try
            {
                await this.SendSpansAsync(lsReport, cancellationToken).ConfigureAwait(false);

                return(ExportResult.Success);
            }
            catch (Exception)
            {
                // TODO distinguish retryable exceptions
                return(ExportResult.FailedNotRetryable);
            }
        }