Skip to content

Commit 6888351

Browse files
GuidesBotGuidesBot
and
GuidesBot
authored
Updated by github actions from guide-microprofile-opentracing-jaeger (#991)
Co-authored-by: GuidesBot <[email protected]>
1 parent bbcf5d6 commit 6888351

File tree

1 file changed

+26
-10
lines changed
  • instructions/cloud-hosted-guide-microprofile-opentracing-jaeger

1 file changed

+26
-10
lines changed

instructions/cloud-hosted-guide-microprofile-opentracing-jaeger/instructions.md

+26-10
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ docker run -d --name jaeger \
8888
-p 14268:14268 \
8989
-p 14250:14250 \
9090
-p 9411:9411 \
91-
jaegertracing/all-in-one:1.17
91+
jaegertracing/all-in-one:1.22
9292
```
9393
{: codeblock}
9494

9595
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).
9797

9898
Before you proceed, make sure that your Jaeger server is up and running.
9999
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
141141
You can view the traces for the inventory or system services under the **Search** tab.
142142
Select the services in the **Select a service** menu and click the **Find Traces** button at the end of the section.
143143

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.
146146

147147
View the traces for **inventory**. You'll see the following trace:
148148

@@ -200,7 +200,8 @@ mvn liberty:dev
200200

201201
After you see the following message, your application server in dev mode is ready:
202202
```
203-
Press the Enter key to run tests on demand.
203+
************************************************************************
204+
* Liberty is running in dev mode.
204205
```
205206

206207
Dev mode holds your command-line session to listen for file changes.
@@ -321,6 +322,7 @@ import javax.inject.Inject;
321322
import java.util.List;
322323
import java.util.Collections;
323324
325+
import org.eclipse.microprofile.config.inject.ConfigProperty;
324326
import org.eclipse.microprofile.opentracing.Traced;
325327
import io.opentracing.Scope;
326328
import io.opentracing.Tracer;
@@ -329,12 +331,16 @@ import io.opentracing.Span;
329331
@ApplicationScoped
330332
public class InventoryManager {
331333
334+
@Inject
335+
@ConfigProperty(name = "system.http.port")
336+
int SYSTEM_PORT;
337+
332338
private List<SystemData> systems = Collections.synchronizedList(new ArrayList<>());
333339
private SystemClient systemClient = new SystemClient();
334340
@Inject Tracer tracer;
335341
336342
public Properties get(String hostname) {
337-
systemClient.init(hostname, 9080);
343+
systemClient.init(hostname, SYSTEM_PORT);
338344
Properties properties = systemClient.getProperties();
339345
return properties;
340346
}
@@ -349,6 +355,8 @@ public class InventoryManager {
349355
Span span = tracer.buildSpan("add() Span").start();
350356
try (Scope childScope = tracer.activateSpan(span)) {
351357
systems.add(system);
358+
} finally {
359+
span.finish();
352360
}
353361
}
354362
}
@@ -465,7 +473,8 @@ public class InventoryResource {
465473
{: codeblock}
466474

467475

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)**.
469478

470479

471480
Run the following curl command:
@@ -490,8 +499,8 @@ Verify that you see the following span:
490499
### Injecting a custom Tracer object
491500

492501
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.
495504

496505
Inject the **Tracer** object into the **inventory/src/main/java/io/openliberty/guides/inventory/InventoryManager.java** file.
497506
Then, use it to define a new child scope in the **add()** call.
@@ -517,6 +526,7 @@ import javax.inject.Inject;
517526
import java.util.List;
518527
import java.util.Collections;
519528
529+
import org.eclipse.microprofile.config.inject.ConfigProperty;
520530
import org.eclipse.microprofile.opentracing.Traced;
521531
import io.opentracing.Scope;
522532
import io.opentracing.Tracer;
@@ -525,12 +535,16 @@ import io.opentracing.Span;
525535
@ApplicationScoped
526536
public class InventoryManager {
527537
538+
@Inject
539+
@ConfigProperty(name = "system.http.port")
540+
int SYSTEM_PORT;
541+
528542
private List<SystemData> systems = Collections.synchronizedList(new ArrayList<>());
529543
private SystemClient systemClient = new SystemClient();
530544
@Inject Tracer tracer;
531545
532546
public Properties get(String hostname) {
533-
systemClient.init(hostname, 9080);
547+
systemClient.init(hostname, SYSTEM_PORT);
534548
Properties properties = systemClient.getProperties();
535549
return properties;
536550
}
@@ -545,6 +559,8 @@ public class InventoryManager {
545559
Span span = tracer.buildSpan("add() Span").start();
546560
try (Scope childScope = tracer.activateSpan(span)) {
547561
systems.add(system);
562+
} finally {
563+
span.finish();
548564
}
549565
}
550566
}

0 commit comments

Comments
 (0)