コード例 #1
0
        public async Task <ReadAllPage> ReadAllForwards(
            long fromPositionInclusive,
            int maxCount,
            bool prefetchJsonData = true,
            CancellationToken cancellationToken = new CancellationToken())
        {
            var span = _spanSource.Begin("stream-store." + nameof(ReadAllForwards), ServiceName, "all", TypeName);

            try
            {
                return(await _streamStore
                       .ReadAllForwards(
                           fromPositionInclusive,
                           maxCount,
                           prefetchJsonData,
                           cancellationToken));
            }
            catch (Exception ex)
            {
                span?.SetError(ex);
                throw;
            }
            finally
            {
                span?.Dispose();
            }
        }
コード例 #2
0
        public int ExecuteNonQuery()
        {
            const string name = "sql." + nameof(ExecuteNonQuery);
            var          span = _spanSource.Begin(name, ServiceName, _command.Connection.Database, ServiceName);

            try
            {
                var result = _command.ExecuteNonQuery();
                if (span != null)
                {
                    span.SetMeta("sql.RowsAffected", result.ToString());
                    SetMeta(span);
                }
                return(result);
            }
            catch (Exception ex)
            {
                span?.SetError(ex);
                throw;
            }
            finally
            {
                span?.Dispose();
            }
        }
コード例 #3
0
        public override void Commit()
        {
            const string name = "sql." + nameof(Commit);
            var          span = _spanSource.Begin(name, ServiceName, "sql", TypeName);

            try
            {
                Transaction.Commit();

                span?.SetDatabaseName(Transaction);
            }
            catch (Exception ex)
            {
                span?.SetError(ex);
                throw;
            }
            finally
            {
                span?.Dispose();
            }
        }
コード例 #4
0
        private async Task <T> Trace <T>(string actionName, string resource, Func <Task <T> > action)
        {
            var span = _spanSource.Begin($"stream-store.{actionName}", ServiceName, resource, TypeName);

            try
            {
                return(await action());
            }
            catch (Exception ex)
            {
                span?.SetError(ex);
                throw;
            }
            finally
            {
                span?.Dispose();
            }
        }
コード例 #5
0
        public void Open()
        {
            var span = _spanSource.Begin("sql.connect", ServiceName, _connection.Database, ServiceName);

            try
            {
                _connection.Open();
            }
            catch (Exception ex)
            {
                span?.SetError(ex);
                throw;
            }
            finally
            {
                span?.Dispose();
            }
        }
コード例 #6
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var host = request.RequestUri.Host;
            var span = _spanSource.Begin($"HTTP {request.Method.Method}", "http", host, "http");

            try
            {
                span?.SetMeta("http.url", request.RequestUri.ToString());
                var response = await SendFunc(_innerHandler, request, cancellationToken);

                span?.SetMeta("http.status_code", ((int)response.StatusCode).ToString());
                return(response);
            }
            catch (Exception ex)
            {
                span?.SetError(ex);
                throw;
            }
            finally
            {
                span?.Dispose();
            }
        }