@@ -58,4 +58,68 @@ public function testForceEnabled()
5858
5959 $ this ->assertTrue ($ tracer ->spanContext ()->enabled ());
6060 }
61+
62+ public function testGlobalAttributes ()
63+ {
64+ $ rt = Tracer::start ($ this ->reporter ->reveal (), [
65+ 'sampler ' => new AlwaysSampleSampler (),
66+ 'skipReporting ' => true
67+ ]);
68+ Tracer::addAttribute ('foo ' , 'bar ' );
69+ $ spans = $ rt ->tracer ()->spans ();
70+ $ span = $ spans [count ($ spans ) - 1 ];
71+ $ this ->assertEquals (['foo ' => 'bar ' ], $ span ->attributes ());
72+ }
73+
74+ public function testGlobalAnnotation ()
75+ {
76+ $ rt = Tracer::start ($ this ->reporter ->reveal (), [
77+ 'sampler ' => new AlwaysSampleSampler (),
78+ 'skipReporting ' => true
79+ ]);
80+ Tracer::addAnnotation ('some description ' , [
81+ 'attributes ' => [
82+ 'foo ' => 'bar '
83+ ]
84+ ]);
85+ $ spans = $ rt ->tracer ()->spans ();
86+ $ span = $ spans [count ($ spans ) - 1 ];
87+
88+ $ this ->assertCount (1 , $ span ->timeEvents ());
89+ $ annotation = $ span ->timeEvents ()[0 ];
90+ $ this ->assertEquals ('some description ' , $ annotation ->description ());
91+ $ this ->assertEquals (['foo ' => 'bar ' ], $ annotation ->attributes ());
92+ }
93+
94+ public function testGlobalMessageEvent ()
95+ {
96+ $ rt = Tracer::start ($ this ->reporter ->reveal (), [
97+ 'sampler ' => new AlwaysSampleSampler (),
98+ 'skipReporting ' => true
99+ ]);
100+ Tracer::addMessageEvent ('SENT ' , 'message-id ' );
101+ $ spans = $ rt ->tracer ()->spans ();
102+ $ span = $ spans [count ($ spans ) - 1 ];
103+
104+ $ this ->assertCount (1 , $ span ->timeEvents ());
105+ $ messageEvent = $ span ->timeEvents ()[0 ];
106+ $ this ->assertEquals ('SENT ' , $ messageEvent ->type ());
107+ $ this ->assertEquals ('message-id ' , $ messageEvent ->id ());
108+ }
109+
110+ public function testGlobalLink ()
111+ {
112+ $ rt = Tracer::start ($ this ->reporter ->reveal (), [
113+ 'sampler ' => new AlwaysSampleSampler (),
114+ 'skipReporting ' => true
115+ ]);
116+ Tracer::addLink ('trace-id ' , 'span-id ' );
117+ $ spans = $ rt ->tracer ()->spans ();
118+ $ span = $ spans [count ($ spans ) - 1 ];
119+
120+ $ this ->assertCount (1 , $ span ->links ());
121+ $ link = $ span ->links ()[0 ];
122+ $ this ->assertEquals ('trace-id ' , $ link ->traceId ());
123+ $ this ->assertEquals ('span-id ' , $ link ->spanId ());
124+ }
61125}
0 commit comments