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

Feature work/kafka - Revise byte count metric #1987

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions src/Agent/NewRelic/Agent/Core/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ public void RecordCountMetric(string metricName, long count = 1)
_agentHealthReporter.ReportCountMetric(metricName, count);
}

public void RecordByteMetric(string metricName, long totalBytes, long? exclusiveBytes = null)
{
_agentHealthReporter.ReportByteMetric(metricName, totalBytes, exclusiveBytes);
}

public void RecordLogMessage(string frameworkName, object logEvent, Func<object, DateTime> getTimestamp, Func<object, object> getLevel, Func<object, string> getLogMessage, Func<object, Exception> getLogException, Func<object, Dictionary<string, object>> getContextData, string spanId, string traceId)
{
_agentHealthReporter.ReportLogForwardingFramework(frameworkName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ public void ReportCountMetric(string metricName, long count)
var metric = _metricBuilder.TryBuildCountMetric(metricName, count);
TrySend(metric);
}
public void ReportByteMetric(string metricName, long totalBytes, long? exclusiveBytes)
{
var metric = _metricBuilder.TryBuildByteMetric(metricName, totalBytes, exclusiveBytes);
TrySend(metric);
}



public void ReportDotnetVersion()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,6 @@ public interface IAgentHealthReporter : IOutOfBandMetricSource
void ReportLoggingEventsDropped(int droppedCount);
void ReportLogForwardingFramework(string logFramework);
void ReportLogForwardingEnabledWithFramework(string logFramework);
void ReportByteMetric(string metricName, long totalBytes, long? exclusiveBytes = null);
}
}
1 change: 1 addition & 0 deletions src/Agent/NewRelic/Agent/Core/WireModels/IMetricBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,6 @@ public interface IMetricBuilder
MetricWireModel TryBuildSupportabilityLoggingEventsDroppedMetric(int droppedCount);

MetricWireModel TryBuildCountMetric(string metricName, long count);
MetricWireModel TryBuildByteMetric(string metricName, long totalBytes, long? exclusiveBytes = null);
}
}
6 changes: 6 additions & 0 deletions src/Agent/NewRelic/Agent/Core/WireModels/MetricWireModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,12 @@ public MetricWireModel TryBuildCountMetric(string metricName, long count)
return BuildMetric(_metricNameService, metricName, null, data);
}

public MetricWireModel TryBuildByteMetric(string metricName, long totalBytes, long? exclusiveBytes)
{
var data = MetricDataWireModel.BuildByteData(totalBytes, exclusiveBytes);
return BuildMetric(_metricNameService, metricName, null, data);
}

#endregion
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ public interface IAgentExperimental
/// <param name="metricName"></param>
/// <param name="count"></param>
void RecordCountMetric(string metricName, long count = 1);
/// <summary>
/// Records a byte count metric with the given name
/// </summary>
/// <param name="metricName"></param>
/// <param name="totalBytes"></param>
/// <param name="exclusiveBytes"></param>
void RecordByteMetric(string metricName, long totalBytes, long? exclusiveBytes = null);

/// <summary>
/// Records the log message in the transaction to later be forwarded if log forwarding is enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private static void ReportSizeMetrics(IAgent agent, ITransaction transaction, st
// Add metrics for bytes received and messages received
var agentExp = agent.GetExperimentalApi();
agentExp.RecordCountMetric($"Message/Kafka/Topic/Named/{topic}/Received/Messages", 1);
agentExp.RecordCountMetric($"Message/Kafka/Topic/Named/{topic}/Received/Bytes", totalSize);
agentExp.RecordByteMetric($"Message/Kafka/Topic/Named/{topic}/Received/Bytes", totalSize);
}

private static Func<object, string> GetTopicAccessorFunc(Type t) =>
Expand Down
Loading