| @@ -3,8 +3,9 @@ | ||
| 3 | 3 | declare (strict_types=1); |
| 4 | 4 | namespace WCPOS\Vendor\Sentry\State; |
| 5 | 5 | |
| 6 | 6 | use WCPOS\Vendor\Psr\Log\NullLogger; |
| 7 | +use WCPOS\Vendor\Sentry\Attachment\Attachment; | |
| 7 | 8 | use WCPOS\Vendor\Sentry\Breadcrumb; |
| 8 | 9 | use WCPOS\Vendor\Sentry\CheckIn; |
| 9 | 10 | use WCPOS\Vendor\Sentry\CheckInStatus; |
| 10 | 11 | use WCPOS\Vendor\Sentry\ClientInterface; |
| @@ -177,14 +178,28 @@ | ||
| 177 | 178 | $maxBreadcrumbs = $options->getMaxBreadcrumbs(); |
| 178 | 179 | if ($maxBreadcrumbs <= 0) { |
| 179 | 180 | return \false; |
| 180 | 181 | } |
| 181 | - $breadcrumb = $beforeBreadcrumbCallback($breadcrumb); | |
| 182 | + try { | |
| 183 | + $breadcrumb = $beforeBreadcrumbCallback($breadcrumb); | |
| 184 | + } catch (\Throwable $exception) { | |
| 185 | + $options->getLoggerOrNullLogger()->error(\sprintf('The "before_breadcrumb" callback failed with exception: "%s".', $exception->getMessage())); | |
| 186 | + return \false; | |
| 187 | + } | |
| 182 | 188 | if ($breadcrumb !== null) { |
| 183 | 189 | $this->getScope()->addBreadcrumb($breadcrumb, $maxBreadcrumbs); |
| 184 | 190 | } |
| 185 | 191 | return $breadcrumb !== null; |
| 186 | 192 | } |
| 193 | + public function addAttachment(Attachment $attachment) : bool | |
| 194 | + { | |
| 195 | + $client = $this->getClient(); | |
| 196 | + if ($client === null) { | |
| 197 | + return \false; | |
| 198 | + } | |
| 199 | + $this->getScope()->addAttachment($attachment); | |
| 200 | + return \true; | |
| 201 | + } | |
| 187 | 202 | /** |
| 188 | 203 | * {@inheritdoc} |
| 189 | 204 | */ |
| 190 | 205 | public function getIntegration(string $className) : ?IntegrationInterface |
| @@ -217,10 +232,16 @@ | ||
| 217 | 232 | $sampleRand = $context->getMetadata()->getSampleRand(); |
| 218 | 233 | if ($transaction->getSampled() === null) { |
| 219 | 234 | $tracesSampler = $options->getTracesSampler(); |
| 220 | 235 | if ($tracesSampler !== null) { |
| 221 | - $sampleRate = $tracesSampler($samplingContext); | |
| 222 | - $sampleSource = 'config:traces_sampler'; | |
| 236 | + try { | |
| 237 | + $sampleRate = $tracesSampler($samplingContext); | |
| 238 | + $sampleSource = 'config:traces_sampler'; | |
| 239 | + } catch (\Throwable $exception) { | |
| 240 | + $options->getLoggerOrNullLogger()->error(\sprintf('The "traces_sampler" callback failed with exception: "%s".', $exception->getMessage())); | |
| 241 | + $sampleRate = $options->getTracesSampleRate() ?? 0; | |
| 242 | + $sampleSource = 'config:traces_sampler_error_fallback'; | |
| 243 | + } | |
| 223 | 244 | } else { |
| 224 | 245 | $parentSampleRate = $context->getMetadata()->getParentSamplingRate(); |
| 225 | 246 | if ($parentSampleRate !== null) { |
| 226 | 247 | $sampleRate = $parentSampleRate; |
| @@ -256,10 +277,16 @@ | ||
| 256 | 277 | $transaction->initSpanRecorder(); |
| 257 | 278 | $profilesSampleSource = 'config:profiles_sample_rate'; |
| 258 | 279 | $profilesSampler = $options->getProfilesSampler(); |
| 259 | 280 | if ($profilesSampler !== null) { |
| 260 | - $profilesSampleRate = $profilesSampler($samplingContext); | |
| 261 | - $profilesSampleSource = 'config:profiles_sampler'; | |
| 281 | + try { | |
| 282 | + $profilesSampleRate = $profilesSampler($samplingContext); | |
| 283 | + $profilesSampleSource = 'config:profiles_sampler'; | |
| 284 | + } catch (\Throwable $exception) { | |
| 285 | + $options->getLoggerOrNullLogger()->error(\sprintf('The "profiles_sampler" callback failed with exception: "%s".', $exception->getMessage())); | |
| 286 | + $profilesSampleRate = $options->getProfilesSampleRate() ?? 0; | |
| 287 | + $profilesSampleSource = 'config:profiles_sampler_error_fallback'; | |
| 288 | + } | |
| 262 | 289 | } else { |
| 263 | 290 | $profilesSampleRate = $options->getProfilesSampleRate(); |
| 264 | 291 | } |
| 265 | 292 | if ($profilesSampleRate === null) { |