@@ -22,75 +22,21 @@ function setupOnce(testCase)
2222 end
2323 end
2424
25+ methods (TestMethodSetup )
26+ function setup(testCase )
27+ commonSetup(testCase );
28+ end
29+ end
30+
2531 methods (TestMethodTeardown )
2632 function teardown(testCase )
2733 commonTeardown(testCase );
2834 end
2935 end
3036
31- methods (Test )
32- function testNondefaultEndpoint(testCase )
33- % testNondefaultEndpoint: using an alternative endpoint
34-
35- testCase .assumeTrue(logical(exist(" opentelemetry.exporters.otlp.OtlpHttpSpanExporter" , " class" )), ...
36- " Otlp HTTP exporter must be installed." );
37-
38- commonSetup(testCase , " nondefault_endpoint.yml" )
39-
40- tracername = " foo" ;
41- spanname = " bar" ;
42-
43- exp = opentelemetry .exporters .otlp .OtlpHttpSpanExporter(...
44- " Endpoint" , " http://localhost:9921/v1/traces" );
45- processor = opentelemetry .sdk .trace .SimpleSpanProcessor(exp );
46- tp = opentelemetry .sdk .trace .TracerProvider(processor );
47- tr = getTracer(tp , tracername );
48- sp = startSpan(tr , spanname );
49- pause(1 );
50- endSpan(sp );
51-
52- % perform test comparisons
53- results = readJsonResults(testCase );
54- results = results{1 };
55-
56- % check span and tracer names
57- verifyEqual(testCase , string(results .resourceSpans .scopeSpans .spans .name ), spanname );
58- verifyEqual(testCase , string(results .resourceSpans .scopeSpans .scope .name ), tracername );
59- end
60-
61- function testNondefaultGrpcEndpoint(testCase )
62- % testNondefaultEndpoint: using an alternative endpoint
63-
64- testCase .assumeTrue(logical(exist(" opentelemetry.exporters.otlp.OtlpGrpcSpanExporter" , " class" )), ...
65- " Otlp gRPC exporter must be installed." );
66-
67- commonSetup(testCase , " nondefault_endpoint.yml" )
68-
69- tracername = " foo" ;
70- spanname = " bar" ;
71-
72- exp = opentelemetry .exporters .otlp .OtlpGrpcSpanExporter(...
73- " Endpoint" , " http://localhost:9922" );
74- processor = opentelemetry .sdk .trace .SimpleSpanProcessor(exp );
75- tp = opentelemetry .sdk .trace .TracerProvider(processor );
76- tr = getTracer(tp , tracername );
77- sp = startSpan(tr , spanname );
78- pause(1 );
79- endSpan(sp );
80-
81- % perform test comparisons
82- results = readJsonResults(testCase );
83- results = results{1 };
84-
85- % check span and tracer names
86- verifyEqual(testCase , string(results .resourceSpans .scopeSpans .spans .name ), spanname );
87- verifyEqual(testCase , string(results .resourceSpans .scopeSpans .scope .name ), tracername );
88- end
89-
37+ methods (Test )
9038 function testAlwaysOffSampler(testCase )
9139 % testAlwaysOffSampler: should not produce any spans
92- commonSetup(testCase )
93-
9440 tp = opentelemetry .sdk .trace .TracerProvider( ...
9541 opentelemetry .sdk .trace .SimpleSpanProcessor , ...
9642 " Sampler" , opentelemetry .sdk .trace .AlwaysOffSampler );
@@ -106,8 +52,6 @@ function testAlwaysOffSampler(testCase)
10652
10753 function testAlwaysOnSampler(testCase )
10854 % testAlwaysOnSampler: should produce all spans
109- commonSetup(testCase )
110-
11155 tracername = " foo" ;
11256 spanname = " bar" ;
11357
@@ -130,8 +74,6 @@ function testAlwaysOnSampler(testCase)
13074
13175 function testTraceIdRatioBasedSampler(testCase )
13276 % testTraceIdRatioBasedSampler: filter spans based on a ratio
133- commonSetup(testCase )
134-
13577 s = opentelemetry .sdk .trace .TraceIdRatioBasedSampler(0 ); % equivalent to always off
13678
13779 tracername = " mytracer" ;
@@ -187,8 +129,6 @@ function testTraceIdRatioBasedSampler(testCase)
187129 function testCustomResource(testCase )
188130 % testCustomResource: check custom resources are included in
189131 % emitted spans
190- commonSetup(testCase )
191-
192132 customkeys = [" foo" " bar" ];
193133 customvalues = [1 5 ];
194134 tp = opentelemetry .sdk .trace .TracerProvider(opentelemetry .sdk .trace .SimpleSpanProcessor , ...
@@ -213,8 +153,6 @@ function testCustomResource(testCase)
213153 function testShutdown(testCase )
214154 % testShutdown: shutdown method should stop exporting
215155 % of spans
216- commonSetup(testCase )
217-
218156 tp = opentelemetry .sdk .trace .TracerProvider();
219157 tr = getTracer(tp , " foo" );
220158
@@ -238,8 +176,6 @@ function testShutdown(testCase)
238176
239177 function testCleanupSdk(testCase )
240178 % testCleanupSdk: shutdown an SDK tracer provider through the Cleanup class
241- commonSetup(testCase )
242-
243179 tp = opentelemetry .sdk .trace .TracerProvider();
244180 tr = getTracer(tp , " foo" );
245181
@@ -262,9 +198,7 @@ function testCleanupSdk(testCase)
262198 end
263199
264200 function testCleanupApi(testCase )
265- % testCleanupApi: shutdown an API tracer provider through the Cleanup class
266- commonSetup(testCase )
267-
201+ % testCleanupApi: shutdown an API tracer provider through the Cleanup class
268202 tp = opentelemetry .sdk .trace .TracerProvider();
269203 setTracerProvider(tp );
270204 clear(" tp" );
0 commit comments