-
Notifications
You must be signed in to change notification settings - Fork 514
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 optional field transaction.sampled
#441
Conversation
feedback appreciated @elastic/apm-agent-devs @elastic/apm-ui |
@roncohen Your consideration related to the default value made me think that we have other fields with default values where we are currently allowed to omit the property if we just want the default value. This reasoning should apply to all such fields right? But in general, if we want the property to be present with its default value in the database, I think it would be more user-friendly if it was the job of the APM Server to populate it in case it wasn't present in the intake JSON. Wouldn't that be better? |
I like it 👍 |
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 have no strong feelings either way on making apm-server default to true when spans are present. One thought would be to fail validation in the only invalid case - where spans are present and sampled is false. 👍 for getting this in now and making those decisions as needed.
@watson which fields are those? 🤔 |
|
FYI, my sampling PR (elastic/apm-agent-python/pull/116) already contains this field. I hope to merge it soon. As for default value vs. required, I more or less agree with @watson. Fields that have an obvious default value shouldn't be required by the API. The more required fields we have, the harder it is to interact with the APM server through things like curl, which makes it harder to play around with, which is important for authors of new agents. |
What exactly does the |
@simitt the absence of We could say that |
Thanks @beniwohli for explanation. |
docs/fields.asciidoc
Outdated
|
||
type: boolean | ||
|
||
Unsampled transactions have no spans. |
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.
Am I the only one who's brain explodes making sense of double negatives? Sampled transactions have spans.
@beniwohli To be clear, you're arguing that |
@roncohen yes. My concern with adding more required fields is that the API becomes less explorable with tools like curl. Specifically in this case, I think it's ok to assume that a transaction has been sampled unless the agent specifically tells us otherwise. If an agent doesn't support sampling, by definition all transactions are sampled. If the agent supports sampling, it'll know what value to set |
I also agree with @beniwohli about not making it required. |
The logic also confused me at first. Agree with @jahtalab . |
I like |
Made 'sampled' optional and it now defaults to true. Also rebased to fix conflicts. |
@roncohen When are you planning to merge this? |
Thanks for your input @mikker, @jahtalab and @beniwohli! |
I think |
To me the confusing part is that But overall I'd also go with |
I think the details of the missing |
@@ -115,6 +115,7 @@ | |||
}, | |||
"name": "GET /api/types", | |||
"result": "success", | |||
"sampled": true, |
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.
please remove from the minimal
example as it is not a required field.
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 don't think this is a minimal
example?
@@ -12,7 +12,8 @@ | |||
"name": "GET /api/types", | |||
"type": "request", | |||
"duration": 32.592981, | |||
"timestamp": "2017-05-09T15:04:05.999999Z" | |||
"timestamp": "2017-05-09T15:04:05.999999Z", | |||
"sampled": false |
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.
please remove from the minimal example as it is not a required field.
@@ -15,7 +15,8 @@ | |||
"name": "GET /api/types", | |||
"type": "request", | |||
"duration": 32.592981, | |||
"timestamp": "2017-05-30T18:53:27.154Z" | |||
"timestamp": "2017-05-30T18:53:27.154Z", | |||
"sampled": false |
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.
please remove from the minimal example as it is not a required field.
@@ -13,6 +13,7 @@ | |||
"type": "request", | |||
"duration": 32.592981, | |||
"timestamp": "2017-05-30T18:53:27.154Z", | |||
"sampled": true, |
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.
please remove from the minimal example as it is not a required field.
@@ -31,14 +31,16 @@ | |||
"timestamp": "2017-05-30T18:53:27.154Z", | |||
"result": "200", | |||
"context": null, | |||
"spans": null | |||
"spans": null, | |||
"sampled": false |
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.
please rset to null
to test that you actually allow null values (this test will fail, as there is a null option missing in the spec).
@@ -16,7 +16,8 @@ | |||
"duration": 32.592981, | |||
"start": 24.01, | |||
"timestamp": "2017-05-09T15:04:05.999999Z", | |||
"spans": [] | |||
"spans": [], | |||
"sampled": true |
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.
please remove as it is not a required field.
docs/fields.asciidoc
Outdated
|
||
type: boolean | ||
|
||
Sampled transactions have spans. Defaults to true |
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.
How about: `If the transaction is sampled, then all available information has been recorded, otherwise information about spans and context are discarded.
@@ -55,6 +55,10 @@ | |||
} | |||
}, | |||
"additionalProperties": false | |||
}, | |||
"sampled": { | |||
"type": "boolean", |
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.
"type": ["boolean", "null"]
otherwise you cannot send the key with an empty value.
- name: sampled | ||
type: boolean | ||
description: > | ||
Sampled transactions have spans. Defaults to true |
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.
see comment about description in json spec.
@@ -4,5 +4,6 @@ | |||
"type": "request", | |||
"duration": 1.0, | |||
"timestamp": "2017-05-30T18:53:27.154Z", | |||
"spans": [] | |||
"spans": [], | |||
"sampled": true |
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.
please remove as it is not a required field, also from the other test json files.
@roncohen you probably didn't run |
@simitt "approved" files deal with the output right? those should have the EDIT: nevermind ;) |
@roncohen yeah right, weird that some specs are still failing for approved files. Is there an issue with files that you had added and are removed again? |
Not sure what you mean. Could you elaborate? |
transaction.sampled
transaction.sampled
Default 'sampled' to true
This adds a required field
transaction.sampled
to the intake API and the Elasticsearch output document for transactions.This doesn't change the requirements around what data is included when sampled is
false
/true
. That is, agents can still sendspans
and setsampled: false
. We might want to add this enforcement later, but I wanted to get this in now as it's a breaking change.Why required?
I considered defaulting it to
true
whenspans
is missing in the payload in order to maintain backwards compatibility with current agents, but decided against it because now is the time to make breaking changes and because i believe having it default totrue
whenspans
is missing in the payload will add complexity in the long run. Happy to discuss though.