Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public CounterPayload(string providerName, string name, string displayName, stri
public IReadOnlyDictionary<string, string> Metadata { get; }

public EventType EventType { get; set; }

}

public class GaugePayload : CounterPayload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ protected override async Task OnEventSourceAvailable(EventPipeEventSource eventS
{
if (traceEvent.TryGetCounterPayload(_filter, _sessionId, out List<ICounterPayload> counterPayload))
{
ExecuteCounterLoggerAction((metricLogger) => metricLogger.Log(counterPayload));
ExecuteCounterLoggerAction((metricLogger) => {
foreach (var payload in counterPayload)
{
metricLogger.Log(payload);
}
});
}
}
catch (Exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.Diagnostics.Monitoring.EventPipe
{
internal interface ICountersLogger
{
//TODO Consider making these async.

void Log(List<ICounterPayload> counter);
void Log(ICounterPayload counter);
void PipelineStarted();
void PipelineStopped();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public static bool TryGetCounterPayload(this TraceEvent traceEvent, CounterFilte

if (sessionId != null && "System.Diagnostics.Metrics".Equals(traceEvent.ProviderName))
{

ICounterPayload individualPayload = null;

if (traceEvent.EventName == "BeginInstrumentReporting")
Expand Down Expand Up @@ -126,9 +125,13 @@ public static bool TryGetCounterPayload(this TraceEvent traceEvent, CounterFilte
return false;
}

public static bool TryGetCounterPayload(this TraceEvent traceEvent, CounterFilter filter, out List<ICounterPayload> payload)
public static bool TryGetIndividualCounterPayload(this TraceEvent traceEvent, CounterFilter filter, out ICounterPayload payload)
{
return TryGetCounterPayload(traceEvent, filter, null, out payload);
bool gotCounterPayload = TryGetCounterPayload(traceEvent, filter, null, out List<ICounterPayload> payloadsList);

payload = payloadsList.FirstOrDefault();

return gotCounterPayload;
}

private static void HandleGauge(TraceEvent obj, CounterFilter filter, string sessionId, out ICounterPayload payload)
Expand Down Expand Up @@ -307,7 +310,6 @@ private static void HandleObservableInstrumentCallbackError(TraceEvent obj, stri
payload = new ErrorPayload(string.Empty, string.Empty, string.Empty, string.Empty, new(), 0, obj.TimeStamp, errorMessage);
}


//The metadata payload is formatted as a string of comma separated key:value pairs.
//This limitation means that metadata values cannot include commas; otherwise, the
//metadata will be parsed incorrectly. If a value contains a comma, then all metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public IReadOnlyDictionary<string, IReadOnlyCollection<string>> GetProviderEvent
public bool HasSatisfiedCondition(TraceEvent traceEvent)
{
// Filter to the counter of interest before forwarding to the implementation
if (traceEvent.TryGetCounterPayload(_filter, out List<ICounterPayload> payload))
if (traceEvent.TryGetIndividualCounterPayload(_filter, out ICounterPayload payload))
{
return _impl.HasSatisfiedCondition(payload[0]); // Need to check if this is safe - in theory just want the first (and only) result
return _impl.HasSatisfiedCondition(payload);
}
return false;
}
Expand Down