Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

[DEV-DOCS] start_transaction(true) #690

Closed
smeubank opened this issue Sep 21, 2022 · 2 comments · May be fixed by getsentry/rfcs#14
Closed

[DEV-DOCS] start_transaction(true) #690

smeubank opened this issue Sep 21, 2022 · 2 comments · May be fixed by getsentry/rfcs#14
Assignees

Comments

@smeubank
Copy link
Member

start_transaction doesn’t continue baggage by default

  • Nested transactions are problematic for baggage since we don’t automatically propagate them for custom transaction calls
  • out of the box, we carry forward baggage and sentry-trace headers (propagate trace) for nested transactions
    • If there is a problem we can re-evaluate is needed
  • Integrations can decide if they want to

- Next steps: dev docs spec and try to move forward,

proposed solution: start_transaction(create_new_trace=True)

Places to document:

Open points:

  • at the very least agreement on what the default behavior should be per platform
    • or more high level client side vs server side
<?php

$sentryTraceHeader = $request->getHeaderLine('sentry-trace');
$baggageHeader = $request->getHeaderLine('baggage');

$transactionContext = \Sentry\Tracing\TransactionContext::continueFromHeaders($sentryTraceHeader, $baggageHeader);

// Start the transaction
$transaction = \Sentry\startTransaction($transactionContext);

...

$transactionContext = new \Sentry\Tracing\TransactionContext();

// Start a nested transaction
// In this case, we would not continue the trace and instead start a new one.
$transaction = \Sentry\startTransaction();

https://sentry.io/organizations/sentry-sdks/performance/sentry-php:c81f843eb6474d53aca7902229cbe32a

---

$transactionContext = \Sentry\Tracing\TransactionContext::fromParent($transaction);
// Start a nested transaction
$transaction = \Sentry\startTransaction($transactionContext);

public static function fromParent(Transaction $transaction)
{
    $context = new self();
    $context->traceId = $transaction->getTraceId();
    $context->parentSpanId = $transaction->getParentSpanId();
    $context->sampled = $transaction->getSampled();
    $context->getMetadata()->setBaggage($transaction->getBaggage());

    return $context;
}

https://sentry.io/organizations/sentry-sdks/performance/sentry-php:a2e3d29c847e49ebac13ce9448254af6

// - How would someone fetch the current transaction? SentrySdk::getCurrentHub()->getTransaction()?
// - Should we auto populate this inside TransactionContext::__construct()?
@smeubank
Copy link
Member Author

To push this conversation forward a decision needs to be made, an RFC will be started here https://github.com/getsentry/rfcs

@cleptric
Copy link
Member

The RFC was closed, so I'm closing this here as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants