Skip to content

Commit

Permalink
feat: jaeger
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidawilliam committed May 13, 2021
1 parent 448170a commit 06f7017
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
<version>2.2.8.RELEASE</version>
</dependency>

<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-tracer-configuration-starter</artifactId>
<version>0.4.0</version>
</dependency>


</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.Timer;
import io.opentracing.Span;
import io.opentracing.Tracer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -40,6 +42,9 @@ public class PropostaController {
@Autowired
private AnaliseFinanceiraClient analiseFinanceiraClient;

@Autowired
private Tracer tracer;

//TODO
// Refatorar com a anotação @Timed
@GetMapping("/{id}")
Expand Down Expand Up @@ -79,6 +84,11 @@ public ResponseEntity criar(UriComponentsBuilder uriComponentsBuilder,
// Estudar como refatorar
// Refatorar também para caso o link não responda (tirar setEstadoProposta do catch)
try {
Span activeSpan = tracer.activeSpan();
activeSpan.setTag("user.email", "william@hotmail.com");
activeSpan.log("Meu log");
activeSpan.setBaggageItem("user.email", "william@hotmail.com");

var validacaoRequest = new AnaliseFinanceiraRequest(
String.valueOf(novaProposta.getId()),
novaProposta.getDocumento(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Biometria {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

// @Lob
private byte[] fingerPrint;

@ManyToOne
Expand Down
17 changes: 16 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,19 @@ keycloak.auth-server-url=http://localhost:8080/auth

## spring security resource server configuration
spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:18080/auth/realms/nosso-cartao
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:18080/auth/realms/nosso-cartao/protocol/openid-connect/certs
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:18080/auth/realms/nosso-cartao/protocol/openid-connect/certs

# Jaeger - Habilita ou não
opentracing.jaeger.enabled=${JAEGER_ENABLED:true}

# Jaeger - Nome do serviço
opentracing.jaeger.service-name=${spring.application.name:meuservico}

# Jaeger - Endereço para enviar os metadados (trace, span, etc)
opentracing.jaeger.http-sender.url=${JAEGER_ENDPOINT:http://localhost:14268/api/traces}

# Jaeger - Tipo de amostragem (probabilístico) e sua configuração (1 = 100%)
opentracing.jaeger.probabilistic-sampler.sampling-rate=${JAEGER_SAMPLER:1}

opentracing.jaeger.const-sampler.decision=${JAEGER_SAMPLER:true}
opentracing.jaeger.rate-limiting-sampler.max-traces-per-second=${JAEGER_SAMPLER:10}

0 comments on commit 06f7017

Please sign in to comment.