Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ To capture transactions and spans customized to your organization's needs, you m
<PlatformContent includePath="performance/add-spans-example" />

<PlatformContent includePath="performance/retrieve-transaction" />

<PlatformContent includePath="performance/record-completed-transactions" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Record Already-Completed Transactions

<Alert>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The documentation references version 6.8.0 for a new .NET SDK feature, but this version is tentative and unconfirmed. The feature may ship in a different release.
Severity: MEDIUM

Suggested Fix

Hold the merge of this pull request until the .NET SDK version containing the RecordTransaction feature is officially released. Once the version is confirmed, update the availableSince alert in the documentation to reflect the correct version number.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: platform-includes/performance/record-completed-transactions/dotnet.mdx#L3

Potential issue: The documentation for the new `RecordTransaction` feature in the .NET
SDK specifies it is available since version `6.8.0`. However, this version number is an
unconfirmed assumption, as noted in the pull request description. Publishing this
documentation before the SDK version is finalized could lead to users on version `6.8.0`
not finding the API if it ships later, or users on earlier versions encountering runtime
errors. This will likely cause user confusion and support tickets.

Did we get this right? 👍 / 👎 to inform future reviews.


Requires Sentry SDK version `6.8.0` or higher.

</Alert>

`StartTransaction` measures work as it happens, using a live stopwatch. Sometimes, though, the work you want to report has already finished somewhere else — for example, spans measured on another machine or in another process and relayed to your application through a proxy. For those cases, use `SentrySdk.RecordTransaction` to record a transaction whose timing you supply explicitly:

```csharp
SentrySdk.RecordTransaction(
"checkout", // name
"http.server", // operation
originalStartTimestamp, // when the work started (DateTimeOffset)
originalDuration, // how long it ran (TimeSpan, must not be negative)
traceId: originTraceId, // optional: preserve the trace id from the originating system
spanId: originRootSpanId, // optional: preserve the root span id
parentSpanId: originParentId, // optional: continue a trace from another service
configure: transaction =>
{
transaction.Release = "1.2.3";
transaction.SetTag("origin", "proxy");

// Child spans also take their timing up front and can be nested arbitrarily
transaction.RecordSpan("db.query", queryStart, queryDuration, configure: span =>
{
span.Description = "SELECT * FROM orders";
span.RecordSpan("db.connection", connectStart, connectDuration);
});
});
```

The transaction is captured and sent to Sentry once the `configure` callback returns — there is no `Finish()` to call.

Because a recorded transaction represents work that happened elsewhere, it behaves differently from one started with `StartTransaction`:

- **Timing is explicit.** Each transaction and span takes a start timestamp and a duration up front, rather than being measured live.
- **Sampling is skipped.** Recorded transactions are always sent, regardless of <PlatformIdentifier name="traces-sample-rate" /> or <PlatformIdentifier name="traces-sampler" />. Your <PlatformIdentifier name="before-send-transaction" /> callback still runs, so you can filter or scrub there.
- **The current scope doesn't apply.** The transaction is captured against a clean scope, so breadcrumbs, user data, and tags from the current process won't leak onto work that happened elsewhere. To attach scope data that belongs with the original trace, use `transaction.ConfigureScope` inside the callback, or the `Release` and `Environment` setters.
Loading