Skip to content

Commit a811f08

Browse files
authored
CloudBank 32 tracking using OTEL and fixes (#808)
* Tracing updates * OTEL Updates * OTEL Updates * Cleanup and change to OTEL * Use var instead of hardcoding * Cleanups after running LL
1 parent b37106b commit a811f08

File tree

17 files changed

+62
-106
lines changed

17 files changed

+62
-106
lines changed

cloudbank-v32/account/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<parent>
99
<groupId>com.example</groupId>
10-
<artifactId>sample-spring-apps</artifactId>
10+
<artifactId>cloudbank-apps</artifactId>
1111
<version>0.0.1-SNAPSHOT</version>
1212
</parent>
1313

cloudbank-v32/account/src/main/java/com/example/accounts/AccountsApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
import org.springframework.boot.SpringApplication;
77
import org.springframework.boot.autoconfigure.SpringBootApplication;
8+
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
89

10+
@EnableDiscoveryClient
911
@SpringBootApplication
1012
public class AccountsApplication {
1113

cloudbank-v32/account/src/main/java/com/example/accounts/services/AccountTransferDAO.java

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public AccountTransferDAO(AccountRepository accountRepository, JournalRepository
2929
this.accountRepository = accountRepository;
3030
this.journalRepository = journalRepository;
3131
singleton = this;
32-
System.out.println("AccountTransferDAO accountsRepository = " + accountRepository
32+
log.info("AccountTransferDAO accountsRepository = " + accountRepository
3333
+ ", journalRepository = " + journalRepository);
3434
}
3535

@@ -43,24 +43,16 @@ public static AccountTransferDAO instance() {
4343
* @return Returns status code
4444
*/
4545
public static String getStatusString(ParticipantStatus status) {
46-
switch (status) {
47-
case Compensated:
48-
return "Compensated";
49-
case Completed:
50-
return "Completed";
51-
case FailedToCompensate:
52-
return "Failed to Compensate";
53-
case FailedToComplete:
54-
return "Failed to Complete";
55-
case Active:
56-
return "Active";
57-
case Compensating:
58-
return "Compensating";
59-
case Completing:
60-
return "Completing";
61-
default:
62-
return "Unknown";
63-
}
46+
return switch (status) {
47+
case Compensated -> "Compensated";
48+
case Completed -> "Completed";
49+
case FailedToCompensate -> "Failed to Compensate";
50+
case FailedToComplete -> "Failed to Complete";
51+
case Active -> "Active";
52+
case Compensating -> "Compensating";
53+
case Completing -> "Completing";
54+
default -> "Unknown";
55+
};
6456
}
6557

6658
/**
@@ -69,24 +61,16 @@ public static String getStatusString(ParticipantStatus status) {
6961
* @return Participant Status
7062
*/
7163
public static ParticipantStatus getStatusFromString(String statusString) {
72-
switch (statusString) {
73-
case "Compensated":
74-
return ParticipantStatus.Compensated;
75-
case "Completed":
76-
return ParticipantStatus.Completed;
77-
case "Failed to Compensate":
78-
return ParticipantStatus.FailedToCompensate;
79-
case "Failed to Complete":
80-
return ParticipantStatus.FailedToComplete;
81-
case "Active":
82-
return ParticipantStatus.Active;
83-
case "Compensating":
84-
return ParticipantStatus.Compensating;
85-
case "Completing":
86-
return ParticipantStatus.Completing;
87-
default:
88-
return null;
89-
}
64+
return switch (statusString) {
65+
case "Compensated" -> ParticipantStatus.Compensated;
66+
case "Completed" -> ParticipantStatus.Completed;
67+
case "Failed to Compensate" -> ParticipantStatus.FailedToCompensate;
68+
case "Failed to Complete" -> ParticipantStatus.FailedToComplete;
69+
case "Active" -> ParticipantStatus.Active;
70+
case "Compensating" -> ParticipantStatus.Compensating;
71+
case "Completing" -> ParticipantStatus.Completing;
72+
default -> null;
73+
};
9074
}
9175

9276
public void saveAccount(Account account) {
@@ -111,7 +95,7 @@ public ResponseEntity<ParticipantStatus> status(String lraId, String journalType
11195
}
11296

11397
/**
114-
* Set status for a Journal Entry.
98+
* Update the LRA status in the journal table during the "after LRA" phase.
11599
* @param lraId LRA Id
116100
* @param status Status
117101
* @param journalType Journal Type

cloudbank-v32/account/src/main/java/com/example/accounts/services/DepositService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public ResponseEntity<String> completeWork(@RequestHeader(LRA_HTTP_CONTEXT_HEADE
103103
public ResponseEntity<String> compensateWork(@RequestHeader(LRA_HTTP_CONTEXT_HEADER) String lraId)
104104
throws Exception {
105105
log.info("deposit compensate called for LRA : " + lraId);
106+
106107
Journal journal = AccountTransferDAO.instance().getJournalForLRAid(lraId, DEPOSIT);
107108
journal.setLraState(AccountTransferDAO.getStatusString(ParticipantStatus.Compensated));
108109
AccountTransferDAO.instance().saveJournal(journal);
@@ -116,6 +117,8 @@ public ResponseEntity<String> compensateWork(@RequestHeader(LRA_HTTP_CONTEXT_HEA
116117
@Status
117118
public ResponseEntity<ParticipantStatus> status(@RequestHeader(LRA_HTTP_CONTEXT_HEADER) String lraId,
118119
@RequestHeader(LRA_HTTP_PARENT_CONTEXT_HEADER) String parentLRA) throws Exception {
120+
log.info("status called for LRA : " + lraId);
121+
119122
return AccountTransferDAO.instance().status(lraId, DEPOSIT);
120123
}
121124

cloudbank-v32/account/src/main/resources/application.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
spring:
55
application:
66
name: account
7-
jersey:
8-
type: filter
7+
# jersey:
8+
# type: filter
99
jpa:
1010
hibernate:
1111
ddl-auto: validate
@@ -16,7 +16,7 @@ spring:
1616
show-sql: true
1717
microtx:
1818
lra:
19-
coordinator-url: http://otmm-tcs.otmm.svc.cluster.local:9000/api/v1/lra-coordinator
19+
coordinator-url: ${MP_LRA_COORDINATOR_URL}
2020
propagation-active: true
2121
headers-propagation-prefix: "{x-b3-, oracle-tmm-, authorization, refresh-}"
2222

@@ -53,7 +53,7 @@ eureka:
5353

5454
lra:
5555
coordinator:
56-
url: http://otmm-tcs.otmm.svc.cluster.local:9000/api/v1/lra-coordinator
56+
url: ${MP_LRA_COORDINATOR_URL}
5757

5858
management:
5959
endpoint:
@@ -76,16 +76,14 @@ management:
7676
enabled: true
7777
java:
7878
enabled: true
79-
zipkin:
79+
otlp:
8080
tracing:
81-
endpoint: http://jaegertracing-collector.observability:9411/api/v2/spans
82-
# otlp:
83-
# tracing:
84-
# endpoint: http://open-telemetry-opentelemetry-collector.open-telemetry:4317
81+
endpoint: http://open-telemetry-opentelemetry-collector.open-telemetry:4318/v1/traces
8582

8683
logging:
8784
level:
8885
root: INFO
8986
com.example: INFO
9087
pattern:
9188
level: '%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]'
89+

cloudbank-v32/checks/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77
<parent>
88
<groupId>com.example</groupId>
9-
<artifactId>sample-spring-apps</artifactId>
9+
<artifactId>cloudbank-apps</artifactId>
1010
<version>0.0.1-SNAPSHOT</version>
1111
</parent>
1212
<artifactId>checks</artifactId>

cloudbank-v32/checks/src/main/resources/application.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,14 @@ management:
4242
enabled: true
4343
java:
4444
enabled: true
45-
zipkin:
45+
otlp:
4646
tracing:
47-
endpoint: http://jaegertracing-collector.observability:9411/api/v2/spans
48-
# otlp:
49-
# tracing:
50-
# endpoint: http://open-telemetry-opentelemetry-collector.open-telemetry:4317
47+
endpoint: http://open-telemetry-opentelemetry-collector.open-telemetry:4318/v1/traces
5148

5249
logging:
5350
level:
5451
root: INFO
5552
com.example: INFO
5653
pattern:
5754
level: '%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]'
55+

cloudbank-v32/creditscore/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<parent>
99
<groupId>com.example</groupId>
10-
<artifactId>sample-spring-apps</artifactId>
10+
<artifactId>cloudbank-apps</artifactId>
1111
<version>0.0.1-SNAPSHOT</version>
1212
</parent>
1313

cloudbank-v32/creditscore/src/main/resources/application.yaml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
spring:
55
application:
66
name: creditscore
7-
# zipkin:
8-
# base-url: ${zipkin.base-url}/api/v2/spans
97

108
# Disables autoconfiguration for the refresh scope and associated features.
119
cloud:
@@ -44,15 +42,10 @@ management:
4442
enabled: true
4543
java:
4644
enabled: true
47-
zipkin:
45+
otlp:
4846
tracing:
49-
endpoint: http://jaegertracing-collector.observability:9411/api/v2/spans
50-
# otlp:
51-
# tracing:
52-
# endpoint: http://open-telemetry-opentelemetry-collector.open-telemetry:4317
53-
# endpoint: http://open-telemetry-opentelemetry-collector.open-telemetry:4318/v1/traces
54-
# endpoint: open-telemetry-opentelemetry-collector.open-telemetry:4317
55-
# endpoint: http://open-telemetry-opentelemetry-collector.open-telemetry:4317/v1/traces
47+
endpoint: http://open-telemetry-opentelemetry-collector.open-telemetry:4318/v1/traces
48+
5649
logging:
5750
level:
5851
root: INFO

cloudbank-v32/customer/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<parent>
99
<groupId>com.example</groupId>
10-
<artifactId>sample-spring-apps</artifactId>
10+
<artifactId>cloudbank-apps</artifactId>
1111
<version>0.0.1-SNAPSHOT</version>
1212
</parent>
1313

0 commit comments

Comments
 (0)