Skip to content

Commit 1b0abe8

Browse files
authored
Merge pull request #2 from wasadus/customGraphitePath
for the case of multiple consumer types from same .exe
2 parents 13f6d75 + aaa9c52 commit 1b0abe8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Cassandra.DistributedTaskQueue/Profiling/GraphiteRtqProfiler.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Diagnostics;
33
using System.Linq;
44
using System.Net;
@@ -18,26 +18,27 @@ public class GraphiteRtqProfiler : IRtqProfiler
1818
public GraphiteRtqProfiler([NotNull] IStatsDClient statsDClient,
1919
[NotNull] IGraphiteClient graphiteClient,
2020
[NotNull] string statsDKeyNamePrefix,
21-
[NotNull] string consumerGraphitePathPrefix)
21+
[NotNull] string consumerGraphitePathPrefix,
22+
[CanBeNull] string consumerName = null)
2223
{
2324
if (string.IsNullOrEmpty(statsDKeyNamePrefix))
2425
throw new InvalidOperationException("statsDKeyNamePrefix is empty");
2526
if (string.IsNullOrEmpty(consumerGraphitePathPrefix))
2627
throw new InvalidOperationException("consumerGraphitePathPrefix is empty");
2728
this.statsDClient = statsDClient.WithScopes($"{statsDKeyNamePrefix}.{Dns.GetHostName()}", $"{statsDKeyNamePrefix}.Total");
2829
this.graphiteClient = graphiteClient;
29-
this.consumerGraphitePathPrefix = FormatGraphitePathPrefix(consumerGraphitePathPrefix);
30+
this.consumerGraphitePathPrefix = FormatGraphitePathPrefix(consumerGraphitePathPrefix, consumerName);
3031
}
3132

3233
[NotNull]
33-
private static string FormatGraphitePathPrefix([NotNull] string graphitePathPrefix)
34+
private static string FormatGraphitePathPrefix([NotNull] string graphitePathPrefix, [CanBeNull] string consumerName)
3435
{
3536
var processName = Process.GetCurrentProcess()
3637
.ProcessName
3738
.Replace(".exe", string.Empty)
3839
.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries)
3940
.Last();
40-
return $"{graphitePathPrefix}.{Dns.GetHostName()}.{processName}";
41+
return $"{graphitePathPrefix}.{Dns.GetHostName()}.{consumerName ?? processName}";
4142
}
4243

4344
public void ProcessTaskCreation([NotNull] TaskMetaInformation meta)

0 commit comments

Comments
 (0)