This repository was archived by the owner on Aug 14, 2024. It is now read-only.
  
  
  - 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 220
    This repository was archived by the owner on Aug 14, 2024. It is now read-only.
  
  
[DEV-DOCS] start_transaction(true) #690
Copy link
Copy link
Closed
getsentry/rfcs
#14Description
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:
- Static API Changes
- new argument
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()?
Metadata
Metadata
Assignees
Labels
No labels