-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add outcome to transactions and spans #299
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! IMO we should maintain full ECS fidelity, and allow success/failed/unknown/(unspecified).
I think we might want to define outcome for HTTP client spans as well.
An outcome always makes sense for span or transaction events but sometimes it can't be determined. Added outcome for http exit spans Clarify that client errors are still a success for transactions
Co-authored-by: Mathieu Martin <webmat@gmail.com>
This implements elastic/apm#299. Additionally, the "status_code" attribute has been added to HTTP spans.
@@ -4,8 +4,10 @@ Agents should instrument HTTP request routers/handlers, starting a new transacti | |||
|
|||
- The transaction `type` should be `request`. | |||
- The transaction `result` should be `HTTP Nxx`, where N is the first digit of the status code (e.g. `HTTP 4xx` for a 404) | |||
- The transaction `outcome` should be `"success"` for HTTP status codes < 500 and `"failure"` for status codes >= 500. \ | |||
Status codes in the 4xx range (client errors) are not considered a `failure` as the failure has not been caused by the application itself but by the caller. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be the default behavior but we should allow users to capture 4xx errors as errors as some users for e.g. may want to capture 401/403 as errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it enough to just offer the API for now? I'd wait to add another config option until we actually get requests for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added APIs for setting the outcome in the Python implementation: elastic/apm-agent-python@ce13f92b63
So a user could do this somewhere in their code if they determine that the transaction should be considered failed:
import elasticapm
elasticapm.set_transaction_failure()
- `http.url` (the target URL) \ | ||
The captured URL should have the userinfo (username and password), if any, redacted. | ||
- `http.status_code` (the response status code) \ | ||
The span's `outcome` should be set to `"success"` if the status code is lower than 400 and to `"failure"` otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments as above to allow flexibility to users to customize the outcomes based on what they see as errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it seems like for spans we are considering an erroneous outcome if < 400 and for transactions it is >500.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's >= 400 for spans (includes client errors) and >= 500 for transactions (does not include client errors)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ on the API to set outcomes.
We've got all the required approvals now. This is scheduled to be merged next Monday unless there are objections. |
💔 Build FailedExpand to view the summary
Build stats
Steps errorsExpand to view the steps failures
Log outputExpand to view the last 100 lines of log output
|
* handle transaction_ignore_urls setting [WIP] * added framework specific tests (and fixed issues revealed by the tests...) * implement "outcome" property for transactions and spans This implements elastic/apm#299. Additionally, the "status_code" attribute has been added to HTTP spans. * fix some tests * change default outcome for spans to "unknown" * added API functions for setting transaction outcome * rework outcome API, and make sure it works for unsampled transactions * fix some tests * fix a test and add one for testing override behavior * add an override=False that went forgotten * expand docs a bit * implement transaction_ignore_urls [WIP] * do less work in aiohttp if we're not tracing a transaction * construct path to json tests in a platform independent way * fix merge issues * address review
* handle transaction_ignore_urls setting [WIP] * added framework specific tests (and fixed issues revealed by the tests...) * implement "outcome" property for transactions and spans This implements elastic/apm#299. Additionally, the "status_code" attribute has been added to HTTP spans. * fix some tests * change default outcome for spans to "unknown" * added API functions for setting transaction outcome * rework outcome API, and make sure it works for unsampled transactions * fix some tests * fix a test and add one for testing override behavior * add an override=False that went forgotten * expand docs a bit * implement transaction_ignore_urls [WIP] * do less work in aiohttp if we're not tracing a transaction * construct path to json tests in a platform independent way * fix merge issues * address review
Background
In APM UI we want to add a chart displaying the error rate. Currently we are calculating the rate as the ratio of errors to transactions in a given time range. But since a transaction can have multiple errors and we can have errors outside of transactions we can not calculate it like that.
Solution
A solution would be having a flag on the transaction informing if that transaction is erroneous. And to calculate the Error rate we'd do:
total_number_of_transactions_with_errors / total_number_of_transactions
in a given time range.supersedes discussion issue: #281