[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: TransactionContext.php
<?php declare(strict_types=1); namespace Sentry\Tracing; final class TransactionContext extends SpanContext { private const TRACEPARENT_HEADER_REGEX = '/^[ \\t]*(?<trace_id>[0-9a-f]{32})?-?(?<span_id>[0-9a-f]{16})?-?(?<sampled>[01])?[ \\t]*$/i'; public const DEFAULT_NAME = '<unlabeled transaction>'; /** * @var string Name of the transaction */ private $name; /** * @var bool|null The parent's sampling decision */ private $parentSampled; /** * @var TransactionMetadata The transaction metadata */ private $metadata; /** * Constructor. * * @param string $name The name of the transaction * @param bool|null $parentSampled The parent's sampling decision * @param TransactionMetadata|null $metadata The transaction metadata */ public function __construct( string $name = self::DEFAULT_NAME, ?bool $parentSampled = null, ?TransactionMetadata $metadata = null ) { $this->name = $name; $this->parentSampled = $parentSampled; $this->metadata = $metadata ?? new TransactionMetadata(); } /** * Gets the name of the transaction. */ public function getName(): string { return $this->name; } /** * Sets the name of the transaction. * * @param string $name The name */ public function setName(string $name): void { $this->name = $name; } /** * Gets the parent's sampling decision. */ public function getParentSampled(): ?bool { return $this->parentSampled; } /** * Sets the parent's sampling decision. * * @param bool|null $parentSampled The decision */ public function setParentSampled(?bool $parentSampled): void { $this->parentSampled = $parentSampled; } /** * Gets the transaction metadata. */ public function getMetadata(): TransactionMetadata { return $this->metadata; } /** * Sets the transaction metadata. * * @param TransactionMetadata $metadata The transaction metadata */ public function setMetadata(TransactionMetadata $metadata): void { $this->metadata = $metadata; } /** * Sets the transaction source. * * @param TransactionSource $transactionSource The transaction source */ public function setSource(TransactionSource $transactionSource): void { $this->metadata->setSource($transactionSource); } /** * Returns a context populated with the data of the given header. * * @param string $header The sentry-trace header from the request * * @deprecated since version 3.9, to be removed in 4.0 */ public static function fromSentryTrace(string $header): self { $context = new self(); if (!preg_match(self::TRACEPARENT_HEADER_REGEX, $header, $matches)) { return $context; } if (!empty($matches['trace_id'])) { $context->traceId = new TraceId($matches['trace_id']); } if (!empty($matches['span_id'])) { $context->parentSpanId = new SpanId($matches['span_id']); } if (isset($matches['sampled'])) { $context->parentSampled = '1' === $matches['sampled']; } return $context; } /** * Returns a context populated with the data of the given environment variables. * * @param string $sentryTrace The sentry-trace value from the environment * @param string $baggage The baggage header value from the environment */ public static function fromEnvironment(string $sentryTrace, string $baggage): self { return self::parseTraceAndBaggage($sentryTrace, $baggage); } /** * Returns a context populated with the data of the given headers. * * @param string $sentryTraceHeader The sentry-trace header from an incoming request * @param string $baggageHeader The baggage header from an incoming request */ public static function fromHeaders(string $sentryTraceHeader, string $baggageHeader): self { return self::parseTraceAndBaggage($sentryTraceHeader, $baggageHeader); } private static function parseTraceAndBaggage(string $sentryTrace, string $baggage): self { $context = new self(); $hasSentryTrace = false; if (preg_match(self::TRACEPARENT_HEADER_REGEX, $sentryTrace, $matches)) { if (!empty($matches['trace_id'])) { $context->traceId = new TraceId($matches['trace_id']); $hasSentryTrace = true; } if (!empty($matches['span_id'])) { $context->parentSpanId = new SpanId($matches['span_id']); $hasSentryTrace = true; } if (isset($matches['sampled'])) { $context->parentSampled = '1' === $matches['sampled']; $hasSentryTrace = true; } } $samplingContext = DynamicSamplingContext::fromHeader($baggage); if ($hasSentryTrace && !$samplingContext->hasEntries()) { // The request comes from an old SDK which does not support Dynamic Sampling. // Propagate the Dynamic Sampling Context as is, but frozen, even without sentry-* entries. $samplingContext->freeze(); $context->getMetadata()->setDynamicSamplingContext($samplingContext); } if ($hasSentryTrace && $samplingContext->hasEntries()) { // The baggage header contains Dynamic Sampling Context data from an upstream SDK. // Propagate this Dynamic Sampling Context. $context->getMetadata()->setDynamicSamplingContext($samplingContext); } return $context; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.73 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002