Skip to content

Commit

Permalink
W-16656937: add graphite.prefix.withHostname
Browse files Browse the repository at this point in the history
  • Loading branch information
pdmoineau committed Sep 11, 2024
1 parent 5719cc4 commit de9c175
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ NameUtils nameUtils()

@Value( "${graphite.prefix:}" ) private String graphitePrefix;

@Value( "${graphite.prefix.includeHostname:false}" ) private boolean graphitePrefixIncludeHostname;

@Value( "${dw.podId:-1}" ) private int podId;

@Value( "${dw.groupId:}" ) private String groupId;
Expand All @@ -82,7 +84,8 @@ NameUtils nameUtils()
{
GraphiteReporter graphiteReporter =
Util.getGraphiteReporter( metricRegistry, graphiteHost, graphitePort, graphiteTransport,
Util.getGraphiteMetricPrefix( graphitePrefix, podId, groupId, svcVersion ) );
Util.getGraphiteMetricPrefix( graphitePrefix, graphitePrefixIncludeHostname,
podId, groupId, svcVersion ) );
if ( graphiteReporter != null )
{
graphiteReporter.start( 60, TimeUnit.SECONDS );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public class Util

private static GraphiteReporter graphiteReporter = null;

public static String getGraphiteMetricPrefix( String graphiteMetricsPrefix, int podId, String groupId,
String version )
public static String getGraphiteMetricPrefix( String graphiteMetricsPrefix, boolean graphitePrefixIncludeHostname,
int podId, String groupId, String version )
throws UnknownHostException
{
String fqdn = InetAddress.getLocalHost().getHostName();
Expand All @@ -40,6 +40,10 @@ else if ( StringUtils.isEmpty( graphiteMetricsPrefix ) )
{
graphiteMetricsPrefix = "um.dev.carbonj." + hostname;
}
else if ( graphitePrefixIncludeHostname )
{
graphiteMetricsPrefix = graphiteMetricsPrefix + "." + hostname;
}
return graphiteMetricsPrefix;
}

Expand Down

0 comments on commit de9c175

Please sign in to comment.