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 9c9298f
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.withHostname:}" ) private String graphitePrefixWithHostname;

@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( graphitePrefixWithHostname, graphitePrefix,
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 graphiteMetricsPrefixWithHostname, String graphiteMetricsPrefix,
int podId, String groupId, String version )
throws UnknownHostException
{
String fqdn = InetAddress.getLocalHost().getHostName();
Expand All @@ -36,6 +36,10 @@ public static String getGraphiteMetricPrefix( String graphiteMetricsPrefix, int
graphiteMetricsPrefix = String.format( "pod%s.%s.%s.%s.%s", podId, groupId, "carbonj", hostname,
version.replaceAll( "\\.", "_" ));
}
else if ( !StringUtils.isEmpty(graphiteMetricsPrefixWithHostname) )
{
graphiteMetricsPrefix = graphiteMetricsPrefixWithHostname + hostname;
}
else if ( StringUtils.isEmpty( graphiteMetricsPrefix ) )
{
graphiteMetricsPrefix = "um.dev.carbonj." + hostname;
Expand Down

0 comments on commit 9c9298f

Please sign in to comment.