22
33namespace Spatie \FlareClient \EntryPoint ;
44
5+ use Spatie \FlareClient \Contracts \AttributesProvider ;
6+ use Spatie \FlareClient \Contracts \EntryPointHandlerProvider ;
7+ use Spatie \FlareClient \Contracts \SamplingAttributesProvider ;
58use Spatie \FlareClient \Enums \EntryPointType ;
69
710class EntryPoint
@@ -14,6 +17,9 @@ class EntryPoint
1417
1518 public ?string $ handlerType ;
1619
20+ /** @var array<string, mixed> */
21+ public array $ samplingAttributes = [];
22+
1723 public function __construct (
1824 public EntryPointType $ type ,
1925 public string $ value ,
@@ -25,17 +31,33 @@ public function updateValue(string $value): void
2531 $ this ->value = $ value ;
2632 }
2733
34+ /** @param array<string, mixed> $samplingAttributes */
2835 public function setHandler (
2936 string $ handlerIdentifier ,
3037 ?string $ handlerName ,
3138 ?string $ handlerType ,
39+ array $ samplingAttributes = [],
3240 ): void {
3341 $ this ->handlerIdentifier = $ handlerIdentifier ;
3442 $ this ->handlerName = $ handlerName ;
3543 $ this ->handlerType = $ handlerType ;
44+ $ this ->samplingAttributes = $ samplingAttributes ;
3645 $ this ->handlerResolved = true ;
3746 }
3847
48+ public function setHandlerFromAttributesProvider (
49+ AttributesProvider &EntryPointHandlerProvider $ provider ,
50+ ): void {
51+ $ this ->setHandler (
52+ handlerIdentifier: $ provider ->entryPointHandlerIdentifier () ?? 'unknown ' ,
53+ handlerName: $ provider ->entryPointHandlerName (),
54+ handlerType: $ provider ->entryPointHandlerType () ?? 'unknown ' ,
55+ samplingAttributes: $ provider instanceof SamplingAttributesProvider
56+ ? $ provider ->samplingAttributes ()
57+ : [],
58+ );
59+ }
60+
3961 /** @return array<string, string|null> */
4062 public function toAttributes (): array
4163 {
0 commit comments