Example #1
0
        public WindowsAzureStorageTimelineMessage(string serviceName, string serviceOperation, string resourceUri, int responseCode, DateTime startTime, DateTime endTime, TimeSpan offset, RequestEventArgs requestEventArgs)
        {
            Id = Guid.NewGuid();

            EventName     = string.Format("WAZStorage:{0} - {1} {2} {3}", serviceName, serviceOperation, resourceUri, responseCode);
            EventCategory = new TimelineCategoryItem("Windows Azure Storage", "#0094FF", "#0094FF");

            ServiceName      = serviceName;
            ServiceOperation = serviceOperation;
            Url          = resourceUri;
            ResponseCode = responseCode;

            StartTime = startTime;
            Duration  = endTime - startTime;
            Offset    = offset;

            RequestSize = requestEventArgs.Request.ContentLength;
            foreach (var header in requestEventArgs.Request.Headers.AllKeys)
            {
                RequestSize += header.Length + 2 + string.Join(";", requestEventArgs.Request.Headers.GetValues(header)).Length;
            }
            ResponseSize = requestEventArgs.Response.ContentLength;
            foreach (var header in requestEventArgs.Response.Headers.AllKeys)
            {
                ResponseSize += header.Length + 2 + string.Join(";", requestEventArgs.Response.Headers.GetValues(header)).Length;
            }

            RequestHeaders  = requestEventArgs.Request.Headers;
            ResponseHeaders = requestEventArgs.Request.Headers;

            EventSubText = string.Format("out: {0}/in: {1}", RequestSize.ToBytesHuman(), ResponseSize.ToBytesHuman());
        }
        [InlineData(RequestSize.Always, int.MaxValue, true)] // 2 GB event? No problem...
        public void ExtractPayload_RequestSizeSmall_ContentLength(RequestSize requestSize, int contentLength, bool readBody)
        {
            _fixture.RequestSize = requestSize;
            _ = _fixture.HttpRequest.ContentLength.Returns(contentLength);
            var sut = _fixture.GetSut();

            Assert.Equal(readBody, sut.ExtractPayload(_fixture.HttpRequest) != null);
        }
Example #3
0
        /// <summary>
        /// Adds ASP.NET classic integration.
        /// </summary>
        public static void AddAspNet(this SentryOptions options, RequestSize maxRequestBodySize = RequestSize.None)
        {
            var payloadExtractor = new RequestBodyExtractionDispatcher(
                new IRequestPayloadExtractor[] { new FormRequestPayloadExtractor(), new DefaultRequestPayloadExtractor() },
                options,
                () => maxRequestBodySize
                );

            var eventProcessor = new SystemWebRequestEventProcessor(payloadExtractor, options);

            options.AddEventProcessor(eventProcessor);
        }
Example #4
0
        /// <summary>
        /// Adds ASP.NET classic integration.
        /// </summary>
        public static void AddAspNet(this SentryOptions options, RequestSize maxRequestBodySize = RequestSize.None)
        {
            var payloadExtractor = new RequestBodyExtractionDispatcher(
                new IRequestPayloadExtractor[] { new FormRequestPayloadExtractor(), new DefaultRequestPayloadExtractor() },
                options,
                () => maxRequestBodySize);

            var eventProcessor = new SystemWebRequestEventProcessor(payloadExtractor, options);

            // Ignore options.IsGlobalModeEnable, we always want to use HttpContext as backing store here
            options.ScopeStackContainer ??= new HttpContextScopeStackContainer();

            options.DiagnosticLogger ??= new TraceDiagnosticLogger(options.DiagnosticLevel);
            options.Release ??= SystemWebVersionLocator.Resolve(options, HttpContext.Current);
            options.AddEventProcessor(eventProcessor);
            options.AddDiagnosticSourceIntegration();
        }
Example #5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (RequestMethod.Length != 0)
            {
                hash ^= RequestMethod.GetHashCode();
            }
            if (RequestUrl.Length != 0)
            {
                hash ^= RequestUrl.GetHashCode();
            }
            if (RequestSize != 0L)
            {
                hash ^= RequestSize.GetHashCode();
            }
            if (Status != 0)
            {
                hash ^= Status.GetHashCode();
            }
            if (ResponseSize != 0L)
            {
                hash ^= ResponseSize.GetHashCode();
            }
            if (UserAgent.Length != 0)
            {
                hash ^= UserAgent.GetHashCode();
            }
            if (RemoteIp.Length != 0)
            {
                hash ^= RemoteIp.GetHashCode();
            }
            if (Referer.Length != 0)
            {
                hash ^= Referer.GetHashCode();
            }
            if (CacheHit != false)
            {
                hash ^= CacheHit.GetHashCode();
            }
            if (ValidatedWithOriginServer != false)
            {
                hash ^= ValidatedWithOriginServer.GetHashCode();
            }
            return(hash);
        }
Example #6
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (RequestMethod.Length != 0)
            {
                hash ^= RequestMethod.GetHashCode();
            }
            if (RequestUrl.Length != 0)
            {
                hash ^= RequestUrl.GetHashCode();
            }
            if (RequestSize != 0L)
            {
                hash ^= RequestSize.GetHashCode();
            }
            if (Status != 0)
            {
                hash ^= Status.GetHashCode();
            }
            if (ResponseSize != 0L)
            {
                hash ^= ResponseSize.GetHashCode();
            }
            if (UserAgent.Length != 0)
            {
                hash ^= UserAgent.GetHashCode();
            }
            if (RemoteIp.Length != 0)
            {
                hash ^= RemoteIp.GetHashCode();
            }
            if (ServerIp.Length != 0)
            {
                hash ^= ServerIp.GetHashCode();
            }
            if (Referer.Length != 0)
            {
                hash ^= Referer.GetHashCode();
            }
            if (latency_ != null)
            {
                hash ^= Latency.GetHashCode();
            }
            if (CacheLookup != false)
            {
                hash ^= CacheLookup.GetHashCode();
            }
            if (CacheHit != false)
            {
                hash ^= CacheHit.GetHashCode();
            }
            if (CacheValidatedWithOriginServer != false)
            {
                hash ^= CacheValidatedWithOriginServer.GetHashCode();
            }
            if (CacheFillBytes != 0L)
            {
                hash ^= CacheFillBytes.GetHashCode();
            }
            if (Protocol.Length != 0)
            {
                hash ^= Protocol.GetHashCode();
            }
            return(hash);
        }
Example #7
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (TraceId.Length != 0)
            {
                hash ^= TraceId.GetHashCode();
            }
            if (SpanId.Length != 0)
            {
                hash ^= SpanId.GetHashCode();
            }
            if (ParentSpanId.Length != 0)
            {
                hash ^= ParentSpanId.GetHashCode();
            }
            if (SpanName.Length != 0)
            {
                hash ^= SpanName.GetHashCode();
            }
            if (startTime_ != null)
            {
                hash ^= StartTime.GetHashCode();
            }
            if (endTime_ != null)
            {
                hash ^= EndTime.GetHashCode();
            }
            hash ^= SpanTags.GetHashCode();
            if (HttpStatusCode != 0L)
            {
                hash ^= HttpStatusCode.GetHashCode();
            }
            if (ClientSpan != false)
            {
                hash ^= ClientSpan.GetHashCode();
            }
            if (RewriteClientSpanId != false)
            {
                hash ^= RewriteClientSpanId.GetHashCode();
            }
            if (SourceName.Length != 0)
            {
                hash ^= SourceName.GetHashCode();
            }
            if (sourceIp_ != null)
            {
                hash ^= SourceIp.GetHashCode();
            }
            if (DestinationName.Length != 0)
            {
                hash ^= DestinationName.GetHashCode();
            }
            if (destinationIp_ != null)
            {
                hash ^= DestinationIp.GetHashCode();
            }
            if (RequestSize != 0L)
            {
                hash ^= RequestSize.GetHashCode();
            }
            if (RequestTotalSize != 0L)
            {
                hash ^= RequestTotalSize.GetHashCode();
            }
            if (ResponseSize != 0L)
            {
                hash ^= ResponseSize.GetHashCode();
            }
            if (ResponseTotalSize != 0L)
            {
                hash ^= ResponseTotalSize.GetHashCode();
            }
            if (ApiProtocol.Length != 0)
            {
                hash ^= ApiProtocol.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }