-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refine implementation, add configuration, add unit tests
- Loading branch information
Showing
8 changed files
with
558 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
newrelic-agent/src/main/java/com/newrelic/agent/config/SlowTransactionsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* | ||
* * Copyright 2020 New Relic Corporation. All rights reserved. | ||
* * SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package com.newrelic.agent.config; | ||
|
||
import com.newrelic.agent.service.slowtransactions.SlowTransactionService; | ||
|
||
public interface SlowTransactionsConfig { | ||
|
||
/** | ||
* True if the {@link SlowTransactionService} is enabled, else false. | ||
*/ | ||
boolean isEnabled(); | ||
|
||
/** | ||
* The minimum number of milliseconds a transaction must be running to be | ||
* reported as slow. | ||
*/ | ||
long getThresholdMillis(); | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
newrelic-agent/src/main/java/com/newrelic/agent/config/SlowTransactionsConfigImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* | ||
* * Copyright 2020 New Relic Corporation. All rights reserved. | ||
* * SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package com.newrelic.agent.config; | ||
|
||
import java.util.Map; | ||
|
||
public class SlowTransactionsConfigImpl extends BaseConfig implements SlowTransactionsConfig { | ||
|
||
public static final String ROOT = "slow_transactions"; | ||
public static final String SYSTEM_PROPERTY_ROOT = "newrelic.config." + ROOT + "."; | ||
public static final String ENABLED = "enabled"; | ||
public static final String THRESHOLD = "threshold"; | ||
|
||
public static final boolean DEFAULT_ENABLED = false; | ||
public static final int DEFAULT_THRESHOLD_MILLIS = 1000; | ||
|
||
private final boolean isEnabled; | ||
private final int thresholdMillis; | ||
|
||
public SlowTransactionsConfigImpl(Map<String, Object> pProps) { | ||
super(pProps, SYSTEM_PROPERTY_ROOT); | ||
isEnabled = getProperty(ENABLED, DEFAULT_ENABLED); | ||
thresholdMillis = getIntProperty(THRESHOLD, DEFAULT_THRESHOLD_MILLIS); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return isEnabled; | ||
} | ||
|
||
@Override | ||
public long getThresholdMillis() { | ||
return thresholdMillis; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.