@@ -88,12 +88,12 @@ docker run -d --name jaeger \
88
88
-p 14268:14268 \
89
89
-p 14250:14250 \
90
90
-p 9411:9411 \
91
- jaegertracing/all-in-one:1.17
91
+ jaegertracing/all-in-one:1.22
92
92
```
93
93
{: codeblock}
94
94
95
95
You can find information about the Jaeger server and instructions for starting the all-in-one executable file in the
96
- [ Jaeger documentation] ( https://www.jaegertracing.io/docs/1.17 /getting-started/#all-in-one ) .
96
+ [ Jaeger documentation] ( https://www.jaegertracing.io/docs/1.22 /getting-started/#all-in-one ) .
97
97
98
98
Before you proceed, make sure that your Jaeger server is up and running.
99
99
Select ** Launch Application** from the menu of the IDE,
@@ -141,8 +141,8 @@ To view the traces, go to the **`https://accountname-16686.theiadocker-4.proxy.c
141
141
You can view the traces for the inventory or system services under the ** Search** tab.
142
142
Select the services in the ** Select a service** menu and click the ** Find Traces** button at the end of the section.
143
143
144
- If you only see the ** jaeger-query** listed in the dropdown, you might need to wait a little longer and refresh the page
145
- to see the application services.
144
+ If you only see the ** jaeger-query** option listed in the dropdown,
145
+ you might need to wait a little longer and refresh the page to see the application services.
146
146
147
147
View the traces for ** inventory** . You'll see the following trace:
148
148
@@ -200,7 +200,8 @@ mvn liberty:dev
200
200
201
201
After you see the following message, your application server in dev mode is ready:
202
202
```
203
- Press the Enter key to run tests on demand.
203
+ ************************************************************************
204
+ * Liberty is running in dev mode.
204
205
```
205
206
206
207
Dev mode holds your command-line session to listen for file changes.
@@ -321,6 +322,7 @@ import javax.inject.Inject;
321
322
import java.util.List;
322
323
import java.util.Collections;
323
324
325
+ import org.eclipse.microprofile.config.inject.ConfigProperty;
324
326
import org.eclipse.microprofile.opentracing.Traced;
325
327
import io.opentracing.Scope;
326
328
import io.opentracing.Tracer;
@@ -329,12 +331,16 @@ import io.opentracing.Span;
329
331
@ApplicationScoped
330
332
public class InventoryManager {
331
333
334
+ @Inject
335
+ @ConfigProperty(name = "system.http.port")
336
+ int SYSTEM_PORT;
337
+
332
338
private List<SystemData> systems = Collections.synchronizedList(new ArrayList<>());
333
339
private SystemClient systemClient = new SystemClient();
334
340
@Inject Tracer tracer;
335
341
336
342
public Properties get(String hostname) {
337
- systemClient.init(hostname, 9080 );
343
+ systemClient.init(hostname, SYSTEM_PORT );
338
344
Properties properties = systemClient.getProperties();
339
345
return properties;
340
346
}
@@ -349,6 +355,8 @@ public class InventoryManager {
349
355
Span span = tracer.buildSpan("add() Span").start();
350
356
try (Scope childScope = tracer.activateSpan(span)) {
351
357
systems.add(system);
358
+ } finally {
359
+ span.finish();
352
360
}
353
361
}
354
362
}
@@ -465,7 +473,8 @@ public class InventoryResource {
465
473
{: codeblock}
466
474
467
475
468
- Disable tracing of the ** listContents()** JAX-RS method by setting ** @Traced (false)** .
476
+ Disable tracing of the ** listContents()** JAX-RS method
477
+ by setting ** @Traced (false)** .
469
478
470
479
471
480
Run the following curl command:
@@ -490,8 +499,8 @@ Verify that you see the following span:
490
499
### Injecting a custom Tracer object
491
500
492
501
The MicroProfile OpenTracing specification also makes the underlying OpenTracing ** Tracer** instance
493
- available for use. You can access the configured ** Tracer** by injecting it into a bean by using the ** @ Inject **
494
- annotation from the Contexts and Dependency Injections API.
502
+ available for use. You can access the configured ** Tracer** by injecting it into a bean by using the
503
+ ** @ Inject ** annotation from the Contexts and Dependency Injections API.
495
504
496
505
Inject the ** Tracer** object into the ** inventory/src/main/java/io/openliberty/guides/inventory/InventoryManager.java** file.
497
506
Then, use it to define a new child scope in the ** add()** call.
@@ -517,6 +526,7 @@ import javax.inject.Inject;
517
526
import java.util.List;
518
527
import java.util.Collections;
519
528
529
+ import org.eclipse.microprofile.config.inject.ConfigProperty;
520
530
import org.eclipse.microprofile.opentracing.Traced;
521
531
import io.opentracing.Scope;
522
532
import io.opentracing.Tracer;
@@ -525,12 +535,16 @@ import io.opentracing.Span;
525
535
@ApplicationScoped
526
536
public class InventoryManager {
527
537
538
+ @Inject
539
+ @ConfigProperty(name = "system.http.port")
540
+ int SYSTEM_PORT;
541
+
528
542
private List<SystemData> systems = Collections.synchronizedList(new ArrayList<>());
529
543
private SystemClient systemClient = new SystemClient();
530
544
@Inject Tracer tracer;
531
545
532
546
public Properties get(String hostname) {
533
- systemClient.init(hostname, 9080 );
547
+ systemClient.init(hostname, SYSTEM_PORT );
534
548
Properties properties = systemClient.getProperties();
535
549
return properties;
536
550
}
@@ -545,6 +559,8 @@ public class InventoryManager {
545
559
Span span = tracer.buildSpan("add() Span").start();
546
560
try (Scope childScope = tracer.activateSpan(span)) {
547
561
systems.add(system);
562
+ } finally {
563
+ span.finish();
548
564
}
549
565
}
550
566
}
0 commit comments