Skip to content

Commit 5f633e6

Browse files
committed
Merge branch 'dev' into v3.x
2 parents 681016a + 9b5f477 commit 5f633e6

File tree

51 files changed

+4594
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4594
-225
lines changed

src/WebJobs.Script.Grpc/generate_protos.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ setlocal
3434
@rem enter Script.Rpc directory
3535
cd /d %~dp0
3636

37-
set NUGET_PATH=%UserProfile%\.nuget\packages
37+
set NUGET_PATH="%UserProfile%\.nuget\packages"
3838
set GRPC_TOOLS_PATH=%NUGET_PATH%\grpc.tools\1.20.1\tools\windows_x86
3939
set PROTO_PATH=.\azure-functions-language-worker-protobuf\src\proto
4040
set PROTO=.\azure-functions-language-worker-protobuf\src\proto\FunctionRpc.proto

src/WebJobs.Script.WebHost/Configuration/ScriptApplicationHostOptionsSetup.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public void Configure(string name, ScriptApplicationHostOptions options)
5959
options.ScriptPath = Path.Combine(tempRoot, @"functions\standby\wwwroot");
6060
options.SecretsPath = Path.Combine(tempRoot, @"functions\standby\secrets");
6161
options.IsSelfHost = options.IsSelfHost;
62+
options.IsStandbyConfiguration = true;
6263
}
6364
}
6465

src/WebJobs.Script.WebHost/DependencyInjection/DryIoc/Container.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ namespace DryIoc
6464
using MemberAssignmentExpr = System.Linq.Expressions.MemberAssignment;
6565
using FactoryDelegateExpr = System.Linq.Expressions.Expression<FactoryDelegate>;
6666
using global::Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.DryIoc;
67-
6867
#endif
6968

7069
/// <summary>IoC Container. Documentation is available at https://bitbucket.org/dadhi/dryioc. </summary>
@@ -432,11 +431,11 @@ private void ThrowIfContainerDisposed()
432431
_scopeContext == null ? _ownCurrentScope : _scopeContext.GetCurrentOrDefault();
433432

434433
/// <inheritdoc />
435-
public IResolverContext WithCurrentScope(IScope scope)
434+
public IResolverContext WithCurrentScope(IScope scope, bool preferInterpretaion = false)
436435
{
437436
ThrowIfContainerDisposed();
438437
return new Container(Rules, _registry, _singletonScope, _scopeContext,
439-
scope, _disposed, _disposeStackTrace, parent: this, root: _root ?? this);
438+
scope, _disposed, _disposeStackTrace, parent: this, root: _root ?? this, preferInterpretation: preferInterpretaion);
440439
}
441440

442441
void IResolverContext.UseInstance(Type serviceType, object instance, IfAlreadyRegistered ifAlreadyRegistered,
@@ -693,7 +692,7 @@ public IContainer With(Rules rules, IScopeContext scopeContext, RegistrySharing
693692
: Ref.Of(_registry.Value.WithoutCache());
694693

695694
return new Container(rules, registry, singletonScope, scopeContext,
696-
_ownCurrentScope, _disposed, _disposeStackTrace, _parent, _root);
695+
_ownCurrentScope, _disposed, _disposeStackTrace, _parent, _root, _preferInterpretation);
697696
}
698697

699698
/// <summary>Produces new container which prevents any further registrations.</summary>
@@ -2593,7 +2592,7 @@ public interface IResolverContext : IResolver, IDisposable
25932592
IScope CurrentScope { get; }
25942593

25952594
/// <summary>Creates resolver context with specified current scope (or container which implements the context).</summary>
2596-
IResolverContext WithCurrentScope(IScope scope);
2595+
IResolverContext WithCurrentScope(IScope scope, bool preferInterpretation);
25972596

25982597
/// <summary>Allows to put instance into the scope.</summary>
25992598
void UseInstance(Type serviceType, object instance, IfAlreadyRegistered IfAlreadyRegistered,
@@ -2687,7 +2686,7 @@ public static IScope GetNamedScope(this IResolverContext r, object name, bool th
26872686
/// handler.Handle(data);
26882687
/// }
26892688
/// ]]></code></example>
2690-
public static IResolverContext OpenScope(this IResolverContext r, object name = null, bool trackInParent = false)
2689+
public static IResolverContext OpenScope(this IResolverContext r, object name = null, bool trackInParent = false, bool preferInterpretation = false)
26912690
{
26922691
// todo: Should we use OwnCurrentScope, then should it be in ResolverContext?
26932692
var openedScope = r.ScopeContext == null
@@ -2697,7 +2696,7 @@ public static IResolverContext OpenScope(this IResolverContext r, object name =
26972696
if (trackInParent)
26982697
(openedScope.Parent ?? r.SingletonScope).TrackDisposable(openedScope);
26992698

2700-
return r.WithCurrentScope(openedScope);
2699+
return r.WithCurrentScope(openedScope, preferInterpretation);
27012700
}
27022701
}
27032702

src/WebJobs.Script.WebHost/DependencyInjection/ScopedResolver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public void Dispose()
4040
internal ServiceScope CreateChildScope(IServiceScopeFactory rootScopeFactory)
4141
{
4242
var scopedRoot = rootScopeFactory.CreateScope();
43-
Container scopedContext = Container.OpenScope() as Container;
43+
var preferInterpretation = (Container as Container).PreferInterpretation;
44+
Container scopedContext = Container.OpenScope(preferInterpretation: preferInterpretation) as Container;
4445

4546
Rules rules = scopedContext.Rules;
4647
foreach (var unknownServiceResolver in scopedContext.Rules.UnknownServiceResolvers)

src/WebJobs.Script.WebHost/DependencyInjection/WebHostServiceProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public object GetService(Type serviceType)
4848

4949
public IServiceScope CreateScope()
5050
{
51-
return new JobHostServiceScope(_container.OpenScope());
51+
return new JobHostServiceScope(_container.OpenScope(preferInterpretation: _container.PreferInterpretation));
5252
}
5353
}
5454
}

src/WebJobs.Script.WebHost/Diagnostics/LinuxAppServiceEventGenerator.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ namespace Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics
99
internal class LinuxAppServiceEventGenerator : LinuxEventGenerator
1010
{
1111
private readonly LinuxAppServiceFileLoggerFactory _loggerFactory;
12+
private readonly HostNameProvider _hostNameProvider;
1213

13-
public LinuxAppServiceEventGenerator(LinuxAppServiceFileLoggerFactory loggerFactory)
14+
public LinuxAppServiceEventGenerator(LinuxAppServiceFileLoggerFactory loggerFactory, HostNameProvider hostNameProvider)
1415
{
1516
_loggerFactory = loggerFactory;
17+
_hostNameProvider = hostNameProvider ?? throw new ArgumentNullException(nameof(hostNameProvider));
1618
}
1719

18-
public static string TraceEventRegex { get; } = $"(?<Level>[0-6]),(?<SubscriptionId>[^,]*),(?<AppName>[^,]*),(?<FunctionName>[^,]*),(?<EventName>[^,]*),(?<Source>[^,]*),\"(?<Details>.*)\",\"(?<Summary>.*)\",(?<HostVersion>[^,]*),(?<EventTimestamp>[^,]+),(?<ExceptionType>[^,]*),\"(?<ExceptionMessage>.*)\",(?<FunctionInvocationId>[^,]*),(?<HostInstanceId>[^,]*),(?<ActivityId>[^,\"]*)";
20+
public static string TraceEventRegex { get; } = $"(?<Level>[0-6]),(?<SubscriptionId>[^,]*),(?<HostName>[^,]*),(?<AppName>[^,]*),(?<FunctionName>[^,]*),(?<EventName>[^,]*),(?<Source>[^,]*),\"(?<Details>.*)\",\"(?<Summary>.*)\",(?<HostVersion>[^,]*),(?<EventTimestamp>[^,]+),(?<ExceptionType>[^,]*),\"(?<ExceptionMessage>.*)\",(?<FunctionInvocationId>[^,]*),(?<HostInstanceId>[^,]*),(?<ActivityId>[^,\"]*)";
1921

2022
public static string MetricEventRegex { get; } = $"(?<SubscriptionId>[^,]*),(?<AppName>[^,]*),(?<FunctionName>[^,]*),(?<EventName>[^,]*),(?<Average>\\d*),(?<Min>\\d*),(?<Max>\\d*),(?<Count>\\d*),(?<HostVersion>[^,]*),(?<EventTimestamp>[^,]+),(?<Details>[^,\"]*)";
2123

@@ -27,10 +29,11 @@ public override void LogFunctionTraceEvent(LogLevel level, string subscriptionId
2729
{
2830
var eventTimestamp = DateTime.UtcNow.ToString(EventTimestampFormat);
2931
var hostVersion = ScriptHost.Version;
32+
var hostName = _hostNameProvider.Value;
3033
FunctionsSystemLogsEventSource.Instance.SetActivityId(activityId);
3134

3235
var logger = _loggerFactory.GetOrCreate(FunctionsLogsCategory);
33-
WriteEvent(logger, $"{(int)ToEventLevel(level)},{subscriptionId},{appName},{functionName},{eventName},{source},{NormalizeString(details)},{NormalizeString(summary)},{hostVersion},{eventTimestamp},{exceptionType},{NormalizeString(exceptionMessage)},{functionInvocationId},{hostInstanceId},{activityId}");
36+
WriteEvent(logger, $"{(int)ToEventLevel(level)},{subscriptionId},{hostName},{appName},{functionName},{eventName},{source},{NormalizeString(details)},{NormalizeString(summary)},{hostVersion},{eventTimestamp},{exceptionType},{NormalizeString(exceptionMessage)},{functionInvocationId},{hostInstanceId},{activityId}");
3437
}
3538

3639
public override void LogFunctionMetricEvent(string subscriptionId, string appName, string functionName, string eventName, long average,

src/WebJobs.Script.WebHost/Diagnostics/LinuxEventGenerator.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,23 @@ public abstract class LinuxEventGenerator : IEventGenerator
1212
public static readonly string EventTimestampFormat = "MM/dd/yyyy hh:mm:ss.fff tt";
1313

1414
// These names should match the source file names for fluentd
15-
public static readonly string FunctionsLogsCategory = "functionslogs";
15+
public static readonly string FunctionsLogsCategory = "functionslogsv2";
1616
public static readonly string FunctionsMetricsCategory = "functionsmetrics";
1717
public static readonly string FunctionsDetailsCategory = "functionsdetails";
1818
public static readonly string FunctionsExecutionEventsCategory = "functionexecutionevents";
1919

2020
internal static string NormalizeString(string value)
2121
{
22-
// need to remove newlines for csv output
22+
// Need to remove newlines for csv output
2323
value = value.Replace(Environment.NewLine, " ");
2424

25+
// Need to replace double quotes with single quotes as
26+
// our regex query looks at double quotes as delimeter for
27+
// individual column
28+
// TODO: Once the regex takes into account for quotes, we can
29+
// safely remove this
30+
value = value.Replace("\"", "'");
31+
2532
// Wrap string literals in enclosing quotes
2633
// For string columns that may contain quotes and/or
2734
// our delimiter ',', before writing the value we

src/WebJobs.Script.WebHost/HostNameProvider.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ namespace Microsoft.Azure.WebJobs.Script.WebHost
2121
public class HostNameProvider
2222
{
2323
private readonly IEnvironment _environment;
24-
private readonly ILogger _logger;
2524
private string _hostName;
2625

27-
public HostNameProvider(IEnvironment environment, ILogger<HostNameProvider> logger)
26+
public HostNameProvider(IEnvironment environment)
2827
{
2928
_environment = environment ?? throw new ArgumentNullException(nameof(environment));
30-
_logger = logger;
3129
}
3230

3331
public virtual string Value
@@ -52,17 +50,17 @@ public virtual string Value
5250
}
5351
}
5452

55-
public virtual void Synchronize(HttpRequest request)
53+
public virtual void Synchronize(HttpRequest request, ILogger logger)
5654
{
5755
string hostNameHeaderValue = request.Headers[ScriptConstants.AntaresDefaultHostNameHeader];
5856
if (!string.IsNullOrEmpty(hostNameHeaderValue) &&
5957
string.Compare(Value, hostNameHeaderValue) != 0)
6058
{
61-
if (string.Compare(Value, hostNameHeaderValue) != 0)
62-
{
63-
_logger.LogInformation("HostName updated from '{0}' to '{1}'", Value, hostNameHeaderValue);
64-
_hostName = hostNameHeaderValue;
65-
}
59+
if (string.Compare(Value, hostNameHeaderValue) != 0)
60+
{
61+
logger.LogInformation("HostName updated from '{0}' to '{1}'", Value, hostNameHeaderValue);
62+
_hostName = hostNameHeaderValue;
63+
}
6664
}
6765
}
6866

0 commit comments

Comments
 (0)