@@ -51,7 +51,7 @@ public class ScriptHost : JobHost, IScriptJobHost
51
51
private readonly IMetricsLogger _metricsLogger = null ;
52
52
private readonly string _hostLogPath ;
53
53
private readonly Stopwatch _stopwatch = new Stopwatch ( ) ;
54
- private readonly string _currentRuntimelanguage ;
54
+ private readonly string _currentRuntimeLanguage ;
55
55
private readonly IOptions < JobHostOptions > _hostOptions ;
56
56
private readonly IConfiguration _configuration ;
57
57
private readonly ScriptTypeLocator _typeLocator ;
@@ -125,7 +125,7 @@ public ScriptHost(IOptions<JobHostOptions> options,
125
125
126
126
_hostLogPath = Path . Combine ( ScriptOptions . RootLogPath , "Host" ) ;
127
127
128
- _currentRuntimelanguage = _environment . GetEnvironmentVariable ( LanguageWorkerConstants . FunctionWorkerRuntimeSettingName ) ;
128
+ _currentRuntimeLanguage = _environment . GetEnvironmentVariable ( LanguageWorkerConstants . FunctionWorkerRuntimeSettingName ) ;
129
129
130
130
_loggerFactory = loggerFactory ;
131
131
_logger = loggerFactory . CreateLogger ( LogCategories . Startup ) ;
@@ -260,14 +260,19 @@ protected override async Task StartAsyncCore(CancellationToken cancellationToken
260
260
public async Task InitializeAsync ( )
261
261
{
262
262
_stopwatch . Start ( ) ;
263
+ if ( ! _environment . IsPlaceholderModeEnabled ( ) )
264
+ {
265
+ string runtimeLanguage = string . IsNullOrEmpty ( _currentRuntimeLanguage ) ? "none" : _currentRuntimeLanguage ;
266
+ _metricsLogger . LogEvent ( string . Format ( MetricEventNames . HostStartupRuntimeLanguage , runtimeLanguage ) ) ;
267
+ }
263
268
using ( _metricsLogger . LatencyEvent ( MetricEventNames . HostStartupLatency ) )
264
269
{
265
270
PreInitialize ( ) ;
266
271
HostInitializing ? . Invoke ( this , EventArgs . Empty ) ;
267
272
268
273
// Generate Functions
269
274
IEnumerable < FunctionMetadata > functions = GetFunctionsMetadata ( ) ;
270
- if ( Utility . ShouldInitiliazeLanguageWorkers ( functions , _currentRuntimelanguage ) )
275
+ if ( Utility . ShouldInitiliazeLanguageWorkers ( functions , _currentRuntimeLanguage ) )
271
276
{
272
277
await InitializeWorkersAsync ( ) ;
273
278
}
@@ -471,16 +476,16 @@ private void GenerateFunctions(IEnumerable<Type> directTypes)
471
476
/// </summary>
472
477
internal async Task InitializeFunctionDescriptorsAsync ( IEnumerable < FunctionMetadata > functionMetadata )
473
478
{
474
- if ( string . IsNullOrEmpty ( _currentRuntimelanguage ) )
479
+ if ( string . IsNullOrEmpty ( _currentRuntimeLanguage ) )
475
480
{
476
481
_logger . LogDebug ( "Adding Function descriptor providers for all languages." ) ;
477
482
_descriptorProviders . Add ( new DotNetFunctionDescriptorProvider ( this , ScriptOptions , _bindingProviders , _metricsLogger , _loggerFactory ) ) ;
478
483
_descriptorProviders . Add ( new WorkerFunctionDescriptorProvider ( this , ScriptOptions , _bindingProviders , _functionDispatcher , _loggerFactory ) ) ;
479
484
}
480
485
else
481
486
{
482
- _logger . LogDebug ( $ "Adding Function descriptor provider for language { _currentRuntimelanguage } .") ;
483
- if ( string . Equals ( _currentRuntimelanguage , LanguageWorkerConstants . DotNetLanguageWorkerName , StringComparison . OrdinalIgnoreCase ) )
487
+ _logger . LogDebug ( $ "Adding Function descriptor provider for language { _currentRuntimeLanguage } .") ;
488
+ if ( string . Equals ( _currentRuntimeLanguage , LanguageWorkerConstants . DotNetLanguageWorkerName , StringComparison . OrdinalIgnoreCase ) )
484
489
{
485
490
_descriptorProviders . Add ( new DotNetFunctionDescriptorProvider ( this , ScriptOptions , _bindingProviders , _metricsLogger , _loggerFactory ) ) ;
486
491
}
@@ -531,7 +536,7 @@ private async Task InitializeWorkersAsync()
531
536
attemptCount ) ;
532
537
} ;
533
538
534
- _functionDispatcher = new FunctionDispatcher ( EventManager , _rpcService , channelFactory , _workerConfigs , _currentRuntimelanguage ) ;
539
+ _functionDispatcher = new FunctionDispatcher ( EventManager , _rpcService , channelFactory , _workerConfigs , _currentRuntimeLanguage ) ;
535
540
536
541
_eventSubscriptions . Add ( EventManager . OfType < WorkerProcessErrorEvent > ( )
537
542
. Subscribe ( evt =>
@@ -709,7 +714,7 @@ internal async Task<Collection<FunctionDescriptor>> GetFunctionDescriptorsAsync(
709
714
Collection < FunctionDescriptor > functionDescriptors = new Collection < FunctionDescriptor > ( ) ;
710
715
var httpFunctions = new Dictionary < string , HttpTriggerAttribute > ( ) ;
711
716
712
- if ( ! _scriptHostEnvironment . IsDevelopment ( ) && ! Utility . IsSingleLanguage ( functions , _currentRuntimelanguage ) )
717
+ if ( ! _scriptHostEnvironment . IsDevelopment ( ) && ! Utility . IsSingleLanguage ( functions , _currentRuntimeLanguage ) )
713
718
{
714
719
throw new HostInitializationException ( $ "Found functions with more than one language. Select a language for your function app by specifying { LanguageWorkerConstants . FunctionWorkerRuntimeSettingName } AppSetting") ;
715
720
}
0 commit comments