Skip to content

Conversation

@jsumners-nr
Copy link
Contributor

@jsumners-nr jsumners-nr commented Jun 7, 2024

This PR fixes a comment in our configuration defaults. Basically, the comment had the intention inverted. The best documentation I could find to verify the configuration setting in general is in the Java agent's code -- https://github.com/newrelic/newrelic-java-agent/blob/a4187358aeeda79d9b9d0b7ca87faf378bd35d82/newrelic-agent/src/main/resources/newrelic.yml#L195-L213. This meshes with our actual implementation:

isBetter(name, duration, apdexT) {
/* 1. If the transaction duration is below the tracing threshold, the
* transaction is skipped.
*
* The threshold for slow traces defaults to apdex_f, which is 4 * apdex_t.
*/
const config = this.config.transaction_tracer
let isOverThreshold
if (
config &&
config.transaction_threshold != null &&
config.transaction_threshold !== 'apdex_f' &&
typeof config.transaction_threshold === 'number'
) {
isOverThreshold = duration >= config.transaction_threshold * TO_MILLIS
} else {
isOverThreshold = duration >= 4 * TO_MILLIS * apdexT
}
if (!isOverThreshold) {
return false
}
/* 2. If the transaction duration is less than the duration of the current
* slow transaction, the transaction is skipped.
*/
let slowerThanExisting = true
if (this.trace) {
slowerThanExisting = this.trace.getDurationInMillis() < duration
}
if (!slowerThanExisting) {
return false
}
/* We always gather some slow transactions at the start, regardless of
* the size of Top N. This changes the behavior of the rest of the
* decision-making process in some subtle ways.
*/
const hasMetGuarantee = this.reported >= 5
/* 3. If the transaction's name is in the transaction map and its duration
* is less than the response time in the map, it is skipped.
*/
let slowerThanCaptured = true
if (hasMetGuarantee && this.requestTimes[name]) {
slowerThanCaptured = this.requestTimes[name] < duration
}
if (!slowerThanCaptured) {
return false
}
/* Not part of enumerated rules, but necessary for Top N support:
* Ensure this name is either already in the request time map
* or that the map still hasn't hit capacity.
*/
return !(
hasMetGuarantee &&
!this.requestTimes[name] &&
Object.keys(this.requestTimes).length >= this.capacity
)
}
}

The Python agent's documentation concurs -- https://docs.newrelic.com/docs/apm/agents/python-agent/configuration/python-agent-configuration/#txn-tracer-threshold

@jsumners-nr jsumners-nr marked this pull request as ready for review June 7, 2024 18:59
@jsumners-nr jsumners-nr requested a review from bizob2828 June 10, 2024 13:07
@bizob2828 bizob2828 added the documentation Improvements or additions to documentation label Jun 10, 2024
@bizob2828 bizob2828 merged commit 7cd6aef into newrelic:main Jun 10, 2024
@jsumners-nr jsumners-nr deleted the fix-comment branch June 10, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants