`SentrySdk.StartSpan` starts a transaction with its operation and description swapped
Description
There seems to be an inconsistency / unexpected behavior in Sentry Traces when capturing via string-based overloads of SentrySdk.StartTransaction:
ITransactionTracer SentrySdk.StartTransaction(string name, string operation)ITransactionTracer SentrySdk.StartTransaction(string name, string operation, string? description)
Scenario string, string
using var transaction = SentrySdk.StartTransaction(
name: "my.transaction.name",
operation: "my.transaction.operation"
);
Results in:
span.description=my.transaction.namespan.name=my.transaction.operationspan.op=my.transaction.operation
Scenario string, string, string?
using var transaction = SentrySdk.StartTransaction(
name: "my.transaction.name",
operation: "my.transaction.operation",
description: "my.transaction.description"
);
Results in:
span.description=my.transaction.namespan.name=my.transaction.operationspan.op=my.transaction.operation
Thanks @rodolfoBee.
Hmm ... but the resulting payload actually looks alright and in accordance with: https://develop.sentry.dev/sdk/data-model/event-payloads/transaction/
{
"type": "transaction",
"transaction": "my.transaction.name",
"contexts": {
"trace": {
"type": "trace",
"span_id": "...",
"trace_id": "...",
"op": "my.transaction.operation",
"origin": "manual",
"description": "my.transaction.description",
"status": "ok"
}
}
}
Well ... we do have the wrong order when calling StartSpan() from an instance of IHub:
https://github.com/getsentry/sentry-dotnet/blob/48b744fd3e3996c1c425aae8a8607c69d2dfb62d/src/Sentry/HubExtensions.cs#L57-L62
which is invoked via:
https://github.com/getsentry/sentry-dotnet/blob/48b744fd3e3996c1c425aae8a8607c69d2dfb62d/src/Sentry/SentrySdk.cs#L642
But I don't think that this is related to directly calling SentrySdk.StartTransaction.
Removing Needs Reproduction: the payload reported here turned out to be correct, but there's a real bug nearby, so the title now describes that one.
SentrySdk.StartSpan(operation, description) calls HubExtensions.StartSpan, which starts a transaction when none is active with hub.StartTransaction(operation, description). That overload's parameters are (name, operation), so the transaction's name is the span's operation and its operation is the span's description. The code has a comment noting the wrong order and a concern that fixing it could break existing users, so the fix may need to wait for a major version.
Hi, I can pick this up. Question first: do you want it fixed now (swap the args in HubExtensions.StartSpan and note it in the changelog as a behavior change), or held for the next major? Either way I can put up a small PR with a test that checks the transaction's name and op.
Hi @ShmueLior - thanks for offering to contribute. This particular issue is a bit problematic though, since I think it would almost certainly break existing applications (in ways that are hard to detect)... which no doubt explains why it's been in the backlog for so long.
I've removed the Good First Issue label and added the Next Major instead as I think it would have to be done as part of a major release.