-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linux Consumption metrics publisher for Legion #9741
base: dev
Are you sure you want to change the base?
Conversation
@@ -24,6 +20,7 @@ public class FlexConsumptionMetricsPublisher : IMetricsPublisher, IDisposable | |||
private readonly ILogger<FlexConsumptionMetricsPublisher> _logger; | |||
private readonly object _lock = new object(); | |||
private readonly IFileSystem _fileSystem; | |||
private readonly LegionMetricsFileManager _metricsFileManager; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both Flex and CV1 on Legion use the same file writer for metrics, so I refactored this logic out
{ | ||
private readonly ILinuxConsumptionMetricsTracker _metricsTracker; | ||
private readonly LegionMetricsFileManager _metricsFileManager; | ||
private readonly TimeSpan _memorySnapshotInterval = TimeSpan.FromMilliseconds(1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intervals for memory and publishing are the same as in LinuxContainerMetricsPublisher, The main change is how this activity is published. Here we publish to the ILinuxConsumptionMetricsTracker component directly, instead of buffering activities and flushing out via http as LinuxContainerMetricsPublisher does.
{ | ||
try | ||
{ | ||
if (_metricsTracker.TryGetMetrics(out LinuxConsumptionMetrics trackedMetrics)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tracker returns aggregated metrics based on the activities that were sent to it, based on its own internal aggregation intervals
|
||
namespace Microsoft.Azure.WebJobs.Script.WebHost.Models | ||
{ | ||
public class ActivityBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These contracts are shared between CV1 and Flex. I moved these existing types out into the new Microsoft.Azure.Functions.Platform.Metrics.LinuxConsumption library
@@ -241,6 +242,11 @@ private static void AddStandbyServices(this IServiceCollection services) | |||
|
|||
private static void AddLinuxContainerServices(this IServiceCollection services) | |||
{ | |||
if (SystemEnvironment.Instance.IsLinuxConsumptionOnLegion()) | |||
{ | |||
services.AddLinuxConsumptionMetricsServices(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds the ILinuxConsumptionMetricsTracker implementation
src/WebJobs.Script.WebHost/WebHostServiceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
@@ -75,6 +75,7 @@ | |||
<PackageReference Include="Microsoft.Azure.AppService.Middleware.Functions" Version="1.5.4" /> | |||
<PackageReference Include="Microsoft.Azure.AppService.Proxy.Client" Version="2.2.20220831.41" /> | |||
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.8" /> | |||
<PackageReference Include="Microsoft.Azure.Functions.Platform.Metrics.LinuxConsumption" Version="1.0.3" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this draft PR, I manually uploaded this version of the package to the Azure Functions artifacts feed. An official build pipeline isn't set up for this yet.
ff34487
to
f77f233
Compare
f77f233
to
51cf502
Compare
51cf502
to
4699883
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will look at PR more in depth soon, leaving initial comment for now since it is a potential issue
/// <returns><see cref="true"/> if the app is V1 Linux Consumption running on Legion; otherwise, <see cref="false"/>.</returns> | ||
public static bool IsV1LinuxConsumptionOnLegion(this IEnvironment environment) | ||
{ | ||
return IsLinuxConsumptionOnLegion(environment) && string.IsNullOrEmpty(environment.GetEnvironmentVariable(FunctionsMetricsPublishPath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mathewc is there supposed to be a "!" in front of the null/empty check for FunctionsMetricsPublishPath?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I see that we'll need to change this. I came up with this after initially discussing with Bala, but you're right that in both cases the metrics path will be set, so we need a different discriminator
4699883
to
48eb894
Compare
48eb894
to
d14e185
Compare
_metricsTracker = metricsTracker ?? throw new ArgumentNullException(nameof(metricsTracker)); | ||
_metricsLogger = metricsLogger ?? throw new ArgumentNullException(nameof(metricsLogger)); | ||
_containerName = _environment.GetEnvironmentVariable(EnvironmentSettingNames.ContainerName); | ||
_metricPublishInterval = TimeSpan.FromMilliseconds(metricsPublishIntervalMS ?? 30 * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious, why is this 30 seconds instead of 5 seconds?
This PR pulls in the new metrics component for Linux Consumption in Legion environments.
Pull request checklist
release_notes.md