Skip to content
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

Closed
wants to merge 25 commits into from
Closed

Conversation

relaxolotl
Copy link
Contributor

mostly a scratchpad of stuff being done to support bare bones transactions, plan is to break this up into smaller PRs

@relaxolotl relaxolotl changed the base branch from master to tracing/set-trace-context December 9, 2021 07:44
@relaxolotl
Copy link
Contributor Author

oh no

@relaxolotl relaxolotl force-pushed the tracing/barebones-transaction branch from ee11544 to f164c37 Compare December 9, 2021 07:48
Copy link
Member

@Swatinem Swatinem left a 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).
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah, good catch. python and js merely warn and set the value to <unlabeled transaction>, so i'll fall back to that.

Copy link
Member

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.

Comment on lines 685 to 694
// TODO: does it matter that this is sampled on creation vs on send? can we
// just sample on send like other events?
Copy link
Member

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?

Copy link
Contributor

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"));
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@loewenheim
Copy link
Contributor

I don't quite understand how the more strongly typed API of sentry_tracing_stub.h is meant to interact with the JSONly typed API elsewhere.

@relaxolotl
Copy link
Contributor Author

I don't quite understand how the more strongly typed API of sentry_tracing_stub.h is meant to interact with the JSONly typed API elsewhere.

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 sentry_value_t and a sentry_transaction_or_other_t". if you (or anybody else) have any ideas on how to tackle this challenge i'm all ears.

@relaxolotl relaxolotl force-pushed the tracing/set-trace-context branch from 955a459 to 148e3e1 Compare December 10, 2021 02:46
@relaxolotl relaxolotl force-pushed the tracing/barebones-transaction branch from f164c37 to c7b300c Compare December 10, 2021 20:09
@relaxolotl relaxolotl force-pushed the tracing/set-trace-context branch from 148e3e1 to 1751cdb Compare December 10, 2021 20:18
@relaxolotl relaxolotl force-pushed the tracing/barebones-transaction branch from c7b300c to a1e7cb8 Compare December 10, 2021 20:20
Comment on lines 217 to 218
sentry_transaction_context_set_operation(
tx_ctx, "Short and stout here is my handle and here is my spout");
Copy link
Contributor

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

Copy link
Contributor Author

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).

Copy link
Contributor Author

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...

Copy link
Contributor

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`.
Copy link
Contributor

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.

Copy link
Contributor Author

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`.
Copy link
Contributor

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`.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.?

Comment on lines 685 to 694
// TODO: does it matter that this is sampled on creation vs on send? can we
// just sample on send like other events?
Copy link
Contributor

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

src/sentry_value.c Outdated Show resolved Hide resolved
tests/unit/test_tracing.c Outdated Show resolved Hide resolved
Base automatically changed from tracing/set-trace-context to master December 13, 2021 23:56
@relaxolotl relaxolotl force-pushed the tracing/barebones-transaction branch from a1e7cb8 to efe5801 Compare December 14, 2021 00:23
@relaxolotl relaxolotl force-pushed the tracing/barebones-transaction branch 3 times, most recently from 7bc0497 to fbf4bd9 Compare December 14, 2021 02:31
@relaxolotl relaxolotl changed the base branch from master to tracing/sampling-decision December 14, 2021 02:37
@relaxolotl relaxolotl force-pushed the tracing/barebones-transaction branch from fbf4bd9 to 0a972a0 Compare December 14, 2021 02:44
@relaxolotl relaxolotl force-pushed the tracing/sampling-decision branch 2 times, most recently from 5493073 to c8236ed Compare December 14, 2021 04:46
@relaxolotl relaxolotl force-pushed the tracing/barebones-transaction branch from 0a972a0 to aa34743 Compare December 14, 2021 05:58
@relaxolotl
Copy link
Contributor Author

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.

Base automatically changed from tracing/sampling-decision to master December 15, 2021 20:42
@relaxolotl
Copy link
Contributor Author

now outdated; other PRs are now ahead of this work and i've switched to a different (local) scratchpad branch.

@relaxolotl relaxolotl closed this Dec 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants