Skip to content
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

[AzureMonitorDistro] Fix livemetrics reporting incorrect values #46429

Merged
merged 4 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove DocumentBuffer class
  • Loading branch information
TimothyMothra committed Oct 4, 2024
commit f41aac13246747d5a373405269b949f3c28e87c5

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Concurrent;
using Azure.Monitor.OpenTelemetry.AspNetCore.Models;

namespace Azure.Monitor.OpenTelemetry.AspNetCore.LiveMetrics.DataCollection
Expand All @@ -14,17 +15,17 @@ namespace Azure.Monitor.OpenTelemetry.AspNetCore.LiveMetrics.DataCollection
/// </summary>
internal class DoubleBuffer
{
private DocumentBuffer _currentBuffer = new();
private ConcurrentQueue<DocumentIngress> _currentBuffer = new();
rajkumar-rangaraj marked this conversation as resolved.
Show resolved Hide resolved

public void WriteDocument(DocumentIngress document)
{
_currentBuffer.Add(document);
_currentBuffer.Enqueue(document);
}

public DocumentBuffer FlipDocumentBuffers()
public ConcurrentQueue<DocumentIngress> FlipDocumentBuffers()
{
// Atomically exchange the current buffer with a new empty buffer and return the old buffer
return Interlocked.Exchange(ref _currentBuffer, new DocumentBuffer());
return Interlocked.Exchange(ref _currentBuffer, new ConcurrentQueue<DocumentIngress>());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Concurrent;
using Azure.Monitor.OpenTelemetry.AspNetCore.LiveMetrics;
using Azure.Monitor.OpenTelemetry.AspNetCore.LiveMetrics.DataCollection;
using Azure.Monitor.OpenTelemetry.AspNetCore.LiveMetrics.Filtering;
Expand Down Expand Up @@ -45,9 +46,10 @@ public MonitoringDataPoint GetDataPoint()
string projectionError = string.Empty;
Dictionary<string, AccumulatedValues> metricAccumulators = CreateMetricAccumulators(_collectionConfiguration);
LiveMetricsBuffer liveMetricsBuffer = new();
DocumentBuffer filledBuffer = _documentBuffer.FlipDocumentBuffers();
IEnumerable<DocumentStream> documentStreams = _collectionConfiguration.DocumentStreams;
foreach (var item in filledBuffer.ReadAllAndClear())

ConcurrentQueue<DocumentIngress> filledBuffer = _documentBuffer.FlipDocumentBuffers();
TimothyMothra marked this conversation as resolved.
Show resolved Hide resolved
while (filledBuffer.TryDequeue(out DocumentIngress? item))
{
bool matchesDocumentStreamFilter = false;

Expand Down
Loading