Performance API follow up
See original GitHub issueI’ve tried to add some docs, and in the process a few things came up.
Docs PR: https://github.com/getsentry/sentry-docs/pull/2790
Notes:
- StartTransaction vs CreateTransaction
Sentry’s SDKs use
startTransaction
but .NET hasCreateTransaction
Java requires only “name” and .NET requires “name” and “op”. Code snippets in Java set an Op right after creating it, should it be in the Start method instead?
Java has Sentry.getSpan();
to get the current “span bound to the Hub”. How do we do this in .NET?
Is this in JavaScript? If not, how do we do it there?
// C#:
var innerSpan = span.StartChild("task");
// Java
Span innerSpan = span.startChild("task", item.getName());
How do I set the span name in C#? Only operation in the method signature.
var transaction = SentrySdk.CreateTransaction("ProcessOrderBatch()", "batch");
try
{
procesOrderBatch();
transaction.Finish();
}
catch (Exception e)
{
// How do I set the exception? Or relate to an error event?
// Java: transaction.setThrowable(e);
transaction.Finish(SpanStatus.InternalError);
// this
SentrySdk.CaptureException(e); // How is the transaction and error linked?
// or
throw; // I expect the request is logged upstream so the reference to the Exception must have been given to the transaction earlier in this catch block
}
In Java we set the exception to the transaction, which is kept in a WeakRef so we can corelate the error event to the transaction. How do we do this in C#?
Java has:
ISpan span = Sentry.getSpan();
if (span == null) {
span = Sentry.startTransaction("task");
} else {
span = span.startChild();
}
How do we do this? Should we change Java to something else. I believe Go doesn’t distinct between StartTran or StartSpan (thinking in the future with single span ingestion, does it matter?)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:13 (11 by maintainers)
Top GitHub Comments
Closing this, as the only remaining issue is tracked in #738
SentryTransaction#transaction
ideally would be “name”, but this is the json property that’s expected on the backend. If we want custom property we would need to write custom json serializer. Anyway, this property is hidden from the user. From the user point of view, he passes “name” toSentryTransaction
constructor.Regarding
Scope#setTransactionName
- it’s taken into account only if there is an ongoing transaction - then we callSentryTransaction#setName
. If there is no transaction set on scope, callingsetTransactionName
is no-op. I’ve lost track a bit - is this behavior incorrect?