Skip to content

Instantly share code, notes, and snippets.

View m-tilab's full-sized avatar
🎯
Focusing

Mahdi Tilab m-tilab

🎯
Focusing
View GitHub Profile
java -jar \
target/Distributed-Service-0.0.1-SNAPSHOT.jar \
--spring.application.name=Service-1 \
--server.port=8080
java -jar \
target/Distributed-Service-0.0.1-SNAPSHOT.jar \
--spring.application.name=Service-2 \
--server.port=8090
opentracing:
jaeger:
http-sender:
url: http://localhost:14268/api/traces
version: '3.3'
services:
jaeger-allinone:
image: jaegertracing/all-in-one:1.42
ports:
- 6831:6831/udp
- 6832:6832/udp
- 16686:16686
- 14268:14268
@RestController
@RequestMapping("/service")
public class Controller {
private static final Logger logger = LoggerFactory.getLogger(Controller.class);
private RestTemplate restTemplate;
@Value("${spring.application.name}")
private String applicationName;
implementation group: 'io.opentracing.contrib', name: 'opentracing-spring-jaeger-cloud-starter', version: '3.3.1'
implementation('io.projectreactor:reactor-core') {
version {
strictly '3.4.26'
}
}
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-jaeger-cloud-starter</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</exclusion>
</exclusions>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-jaeger-cloud-starter</artifactId>
<version>3.3.1</version>
</dependency>
...
searchService.search(ParameterObject.build()
.withType("type1")
.sortBy("ASC")
.build());
...
public class SearchService {
/* Parameter Object example. Default values are abstracted into the Parameter Object
at the time of Object creation */
public String search(ParameterObject parameterObject) {
return getQuerySummary(parameterObject.getType(), parameterObject.getSortBy(),
parameterObject.getSortOrder());
}
private String getQuerySummary(String type, String sortBy, SortOrder sortOrder) {
public class SearchService {
//Method Overloading example. SortOrder is defaulted in this method
public String search(String type, String sortBy) {
return getQuerySummary(type, sortBy, SortOrder.DESC);
}
/* Method Overloading example. SortBy is defaulted in this method. Note that the type has to be
different here to overload the method */
public String search(String type, SortOrder sortOrder) {
return getQuerySummary(type, "price", sortOrder);