-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
barebones transaction work #618
Conversation
oh no |
ee11544
to
f164c37
Compare
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 looks very nice so far!
include/sentry.h
Outdated
|
||
/** | ||
* Sets the name of a transaction on a `transaction_context`. | ||
* Returns 1 if the name provided is invalid (e.g. empty or nil). |
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 this consistent with other similar APIs? I don’t quite remember if we even validate invalid values?
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.
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.
When I was experimenting with this in Rust, the server (relay?) would also default this. So the SDK is free to leave off the name completely (or make it empty) instead of defaulting it.
src/sentry_core.c
Outdated
// TODO: does it matter that this is sampled on creation vs on send? can we | ||
// just sample on send like other events? |
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.
good Q. I think since the sampling decision can also be set from the outside, it should be defined here?
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.
potentially adding spans could become a no-op if sampled on creation? saves some cpu
void | ||
sentry_transaction_finish(sentry_value_t tx) | ||
{ | ||
sentry_value_set_by_key(tx, "type", sentry_value_new_string("transaction")); |
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.
Why are we setting the type here?
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.
good question; if you're wondering why it's set in finish of all places, i'd have to say that there's no real rhyme or reason behind it besides the idea that the transactions shouldn't be treated like a regular event (ie require checking of the type field) elsewhere in the code after their creation. that's likely a naive assumption given the lack of typing we have for transactions, though. now that i've written this out, i might just set this field during initialization to be safe.
if you're wondering why this field is getting set at all (and why it isn't being set for events), it's the discriminant in "events" (https://develop.sentry.dev/sdk/event-payloads/types/#eventtype). tl;dr SDKs send two types of events, error monitoring-related events and transactions. the former is the default and doesn't need an explicit type
, the latter must have the type
field set to transaction for it to be treated as such.
I don't quite understand how the more strongly typed API of |
apologies for the confusion; it was probably a mistake for me to commit this to begin with. it was probably really confusing to see these types and then discover that none of them are used anywhere in the code. i unfortunately haven't spent much time thinking about how i could integrate these types internally into the implementation while keeping the JSON-ly typed API that's currently exposed to users. my mulling on this has terminated at "golly it would be a massive pain and waste of CPU cycles to be constantly converting between a |
955a459
to
148e3e1
Compare
f164c37
to
c7b300c
Compare
148e3e1
to
1751cdb
Compare
c7b300c
to
a1e7cb8
Compare
examples/example.c
Outdated
sentry_transaction_context_set_operation( | ||
tx_ctx, "Short and stout here is my handle and here is my spout"); |
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.
More of an api question, but i wonder if it makes sense to instead to always add this as a second argument to sentry_value_new_transaction_context("op", "name")
, this would be similar to python's start_transaction(op, name)
. it was my understanding that you really want to have op
filled in, if we do not want to make them obligatory we can still make them accept NULL
for them.
also happy to discuss this on the notion page if you prefer
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 have any particularly strong feelings on the matter - if it's more convenient to require an op
and it lines up with the sort of behaviour we would like to encourage from users, then this can definitely be done. the change will most likely be made in #619.
i would like to call out the description on this PR, which is still applicable to the contents of its changes: the main intent of this PR is to simply expose the work i'm doing to the rest of the team, but none of it is really "PR-ready" from my POV. i can address the comments made on this diff and any discussion on parts of this that aren't already opened up in existing PRs are welcome, but given the genuine WIP nature of the changes on here some things are expected to be fairly rough (e.g. the documentation).
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.
probably on me for making it possible to even see those parts of the diffs though...
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 may be commenting on the wrong PRs. apologies, i've not been paying enough attention on what the various PRs are for
include/sentry.h
Outdated
|
||
/** | ||
* Constructs a new transaction context to be passed | ||
* into `sentry_start_transaction`. |
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.
could we describe what the name parameter is? something like
*name* is the transaction name, this describes the transaction and can also be used
to search for the transaction in sentry.
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'm a little reluctant to provide too much product guidance here as existing documentation tends to defer to documentation on docs.sentry.io on that front (ie sentry_value_new_event
, sentry_value_new_message_event
, sentry_value_new_exception
, etc), preferring to mostly explain implementation-specific details. i'll admit that we can't really do the same for performance monitoring as its documentation isn't compiled in one easily referenceable location in the same way other types of messages are, making it difficult for us to do the same.
i've pushed an attempt to reach some sort of compromise between a full explanation and the approach used by existing documentation in #619.
include/sentry.h
Outdated
const char *name); | ||
|
||
/** | ||
* Sets the name of a transaction on a `transaction_context`. |
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, i'd like to describe what name is for
include/sentry.h
Outdated
sentry_value_t transaction_context, const char *name); | ||
|
||
/** | ||
* Sets the operation of a transaction on a `transaction_context`. |
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.
similar, maybe describe what operation is?
include/sentry.h
Outdated
* When turned on, the transaction will bypass all sampling | ||
* options and always be sent to sentry. If this is explicitly | ||
* turned off in the `transaction_context`, the transaction will | ||
* never be sent to sentry. |
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.
because sampled
is such a confusing word, could we explicitly describe: 1: is sent to sentry; 0: is **not** sent to sentry
?
include/sentry.h
Outdated
sentry_value_t transaction_context); | ||
|
||
/** | ||
* Finishes a transaction. |
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 now put on the transport to be sent to sentry? I'd add this in the description.
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.
perhaps? i'm not sure about the details myself; this doesn't really do much of anything different from capture_event
whose description is just Sends a sentry event.
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.
so Finishes a transaction and sends it
.?
src/sentry_core.c
Outdated
// TODO: does it matter that this is sampled on creation vs on send? can we | ||
// just sample on send like other events? |
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.
potentially adding spans could become a no-op if sampled on creation? saves some cpu
a1e7cb8
to
efe5801
Compare
7bc0497
to
fbf4bd9
Compare
fbf4bd9
to
0a972a0
Compare
5493073
to
c8236ed
Compare
0a972a0
to
aa34743
Compare
got started in creating some transaction-equivalents to envelope helpers that can also be found in other SDKs. the term "event" is starting to gain two different definitions though: the blanket "Event" that covers all types of items that may be stuffed into an envelope, and the "Event" that is a specific variant of the blanket "Event" which is one of those very items that can be placed in an envelope, and is a sibling to a Transaction. |
…ransaction events
now outdated; other PRs are now ahead of this work and i've switched to a different (local) scratchpad branch. |
mostly a scratchpad of stuff being done to support bare bones transactions, plan is to break this up into smaller PRs