File tree 3 files changed +13
-5
lines changed
chapter08-deploying-for-developers/quarkus-demo
src/main/java/com/example/demo
3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 1
1
.DS_Store
2
+ .idea
3
+ .iml
4
+ target /
Original file line number Diff line number Diff line change 15
15
<maven .compiler.source>11</maven .compiler.source>
16
16
<maven .compiler.target>11</maven .compiler.target>
17
17
<project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
18
- <project .reporting.outputEncoding>UTF-8</project .reporting.outputEncoding>
19
18
<quarkus-plugin .version>2.5.0.Final</quarkus-plugin .version>
20
19
<quarkus .platform.artifact-id>quarkus-bom</quarkus .platform.artifact-id>
21
20
<quarkus .platform.group-id>io.quarkus</quarkus .platform.group-id>
Original file line number Diff line number Diff line change 6
6
import io .opentelemetry .context .Context ;
7
7
8
8
import javax .ws .rs .*;
9
- import java .time .LocalDateTime ;
10
9
import java .util .logging .Logger ;
11
10
import javax .ws .rs .core .MediaType ;
12
11
13
12
@ Path ("/greeting" )
14
13
public class GreetingResource {
15
14
private static final String template = "Hello, %s!" ;
16
15
17
- private final static Logger log = Logger .getLogger (GreetingResource .class .getName ());
16
+ private final static Logger log ;
17
+
18
+ static {
19
+ log = Logger .getLogger (GreetingResource .class .getName ());
20
+ }
18
21
19
22
@ GET
20
23
@ Produces (MediaType .APPLICATION_JSON )
21
24
@ Timed (value ="custom" )
22
- public Greeting greeting (@ QueryParam ("name" ) @ DefaultValue ( "World" ) String name ) {
25
+ public Greeting greeting (@ QueryParam ("name" ) String name ) {
23
26
pause ();
24
27
return new Greeting (String .format (template , name ));
25
28
}
26
29
27
30
private void pause () {
28
- Span span = Span .fromContext (Context .current ()).setAttribute ("pause" , "start" );
31
+ Span span = Span .fromContext (Context .current ())
32
+ .setAttribute ("pause" , "start" );
29
33
try {
30
34
Thread .sleep (2000 );
31
35
} catch (InterruptedException e ) {
36
+ span .setStatus (StatusCode .ERROR , "Execution was interrupted" );
32
37
span .setAttribute ("unexpected.pause" , "exception" );
38
+ span .recordException (e );
33
39
log .severe ("Thread interrupted" );
34
40
}
35
41
}
You can’t perform that action at this time.
0 commit comments