protected override void OnHostInitialized() { ApplyJobHostMetadata(); _httpRoutesManager.InitializeHttpFunctionRoutes(this); _logger.ScriptHostInitialized((long)_stopwatch.GetElapsedTime().TotalMilliseconds); HostInitialized?.Invoke(this, EventArgs.Empty); base.OnHostInitialized(); }
public void ProcessMessageDispatchStop(ValueStopwatch stopwatch) { if (!IsEnabled()) { return; } MessageDispatchStop(stopwatch.IsActive ? stopwatch.GetElapsedTime().TotalMilliseconds : 0.0); }
public void ScanForXmlStop(ValueStopwatch stopwatch) { if (!IsEnabled()) { return; } ScanStop(stopwatch.IsActive ? stopwatch.GetElapsedTime().TotalMilliseconds : -1.0); }
public void HandshakeFailed(bool isServer, ValueStopwatch stopwatch, string exceptionMessage) { Interlocked.Increment(ref _finishedTlsHandshakes); Interlocked.Increment(ref _failedTlsHandshakes); if (IsEnabled(EventLevel.Error, EventKeywords.None)) { HandshakeFailed(isServer, stopwatch.GetElapsedTime().TotalMilliseconds, exceptionMessage); } HandshakeStop(SslProtocols.None); }
public void ConnectionStop(string connectionId, ValueStopwatch timer) { if (IsEnabled()) { var duration = timer.IsActive ? timer.GetElapsedTime().TotalMilliseconds : 0.0; _connectionDuration.WriteMetric((float)duration); _connectionsStopped.WriteMetric(1.0f); if (IsEnabled(EventLevel.Informational, EventKeywords.None)) { ConnectionStop(connectionId); } } }
public void ConnectionStop(string connectionId, ValueStopwatch timer) { Interlocked.Increment(ref _connectionsStopped); Interlocked.Decrement(ref _currentConnections); if (IsEnabled()) { var duration = timer.IsActive ? timer.GetElapsedTime().TotalMilliseconds : 0.0; _connectionDuration !.WriteMetric(duration); if (IsEnabled(EventLevel.Informational, EventKeywords.None)) { ConnectionStop(connectionId); } } }
public async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, ValueStopwatch queueDuration, CancellationToken cancellationToken) { // Allocate an active request QuicStream? quicStream = null; Http3RequestStream?requestStream = null; ValueTask waitTask = default; try { try { while (true) { lock (SyncObj) { if (_connection == null) { break; } if (_connection.GetRemoteAvailableBidirectionalStreamCount() > 0) { quicStream = _connection.OpenBidirectionalStream(); requestStream = new Http3RequestStream(request, this, quicStream); _activeRequests.Add(quicStream, requestStream); break; } waitTask = _connection.WaitForAvailableBidirectionalStreamsAsync(cancellationToken); } if (HttpTelemetry.Log.IsEnabled() && !waitTask.IsCompleted && !queueDuration.IsActive) { // We avoid logging RequestLeftQueue if a stream was available immediately (synchronously) queueDuration = ValueStopwatch.StartNew(); } // Wait for an available stream (based on QUIC MAX_STREAMS) if there isn't one available yet. await waitTask.ConfigureAwait(false); } } finally { if (HttpTelemetry.Log.IsEnabled() && queueDuration.IsActive) { HttpTelemetry.Log.Http30RequestLeftQueue(queueDuration.GetElapsedTime().TotalMilliseconds); } } if (quicStream == null) { throw new HttpRequestException(SR.net_http_request_aborted, null, RequestRetryType.RetryOnConnectionFailure); } requestStream !.StreamId = quicStream.StreamId; bool goAway; lock (SyncObj) { goAway = _lastProcessedStreamId != -1 && requestStream.StreamId > _lastProcessedStreamId; } if (goAway) { throw new HttpRequestException(SR.net_http_request_aborted, null, RequestRetryType.RetryOnConnectionFailure); } if (NetEventSource.Log.IsEnabled()) { Trace($"Sending request: {request}"); } Task <HttpResponseMessage> responseTask = requestStream.SendAsync(cancellationToken); // null out requestStream to avoid disposing in finally block. It is now in charge of disposing itself. requestStream = null; return(await responseTask.ConfigureAwait(false)); } catch (QuicConnectionAbortedException ex) { // This will happen if we aborted _connection somewhere. Abort(ex); throw new HttpRequestException(SR.Format(SR.net_http_http3_connection_error, ex.ErrorCode), ex, RequestRetryType.RetryOnConnectionFailure); } finally { requestStream?.Dispose(); } }