Skip to content

Commit

Permalink
feat(PodMetrics): optimize startup (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanJosipovic authored Sep 26, 2024
1 parent a9f08cf commit 6bbbed4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 26 deletions.
5 changes: 3 additions & 2 deletions src/KubeUI/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reflection;
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Avalonia.Data.Core.Plugins;
using Avalonia.Logging;
Expand Down Expand Up @@ -112,7 +113,7 @@ public override void Initialize()
.AddMeter(Instrumentation.MeterName)
.AddOtlpExporter((e, b) =>
{
b.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 60 * 1000; // 1 min
b.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = (int)TimeSpan.FromMinutes(1).TotalMilliseconds;
e.Endpoint = new Uri("https://otel.kubeui.com/v1/metrics");
e.Headers = $"key={key}";
e.Protocol = OtlpExportProtocol.HttpProtobuf;
Expand Down
14 changes: 2 additions & 12 deletions src/KubeUI/Controls/PodMetricCPUCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,7 @@ public PodMetricCPUCell()
{
s_timer.Tick += Timer_Tick;
s_timer.Interval = TimeSpan.FromSeconds(1);
}

protected override void OnDataContextChanged(EventArgs e)
{
base.OnDataContextChanged(e);

Update();

if (!s_timer.IsEnabled)
{
s_timer.Start();
}
s_timer.Start();
}

private void Timer_Tick(object? sender, EventArgs e)
Expand Down Expand Up @@ -80,5 +69,6 @@ protected override void OnUnloaded(RoutedEventArgs e)
public void Initialize(ICluster cluster)
{
Cluster = cluster;
Update();
}
}
14 changes: 2 additions & 12 deletions src/KubeUI/Controls/PodMetricMemoryCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,7 @@ public PodMetricMemoryCell()
{
s_timer.Tick += Timer_Tick;
s_timer.Interval = TimeSpan.FromSeconds(1);
}

protected override void OnDataContextChanged(EventArgs e)
{
base.OnDataContextChanged(e);

Update();

if (!s_timer.IsEnabled)
{
s_timer.Start();
}
s_timer.Start();
}

private void Timer_Tick(object? sender, EventArgs e)
Expand Down Expand Up @@ -81,5 +70,6 @@ protected override void OnUnloaded(RoutedEventArgs e)
public void Initialize(ICluster cluster)
{
Cluster = cluster;
Update();
}
}

0 comments on commit 6bbbed4

Please sign in to comment.