Skip to content

Commit

Permalink
refactor: removes Jaeger Tracing and updates to Gradle 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
makampf committed Sep 7, 2023
1 parent ccb2912 commit db98fcf
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 108 deletions.
12 changes: 3 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "org.springframework.boot" version "3.1.1"
id "io.spring.dependency-management" version "1.1.0"
id "org.springframework.boot" version "3.1.3"
id "io.spring.dependency-management" version "1.1.3"
id "java"
id "jacoco"
id "com.diffplug.spotless" version "6.19.0"
Expand Down Expand Up @@ -49,15 +49,9 @@ dependencies {
implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-r4:${hapiVersion}"
implementation "ca.uhn.hapi.fhir:hapi-fhir-client-okhttp:${hapiVersion}"

implementation "io.opentracing.contrib:opentracing-spring-web-starter:4.1.0"
implementation "io.opentracing.contrib:opentracing-spring-jaeger-web-starter:3.3.1"
implementation "io.opentracing.contrib:opentracing-spring-jaeger-cloud-starter:3.3.1"
implementation "io.opentracing.contrib:opentracing-okhttp3:3.0.0"
implementation "io.jaegertracing:jaeger-client:1.8.1"

developmentOnly "org.springframework.boot:spring-boot-devtools"
runtimeOnly "org.postgresql:postgresql:42.6.0"
runtimeOnly 'com.h2database:h2:2.1.214.redhat-00001'
runtimeOnly 'com.h2database:h2:2.2.222'
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
testImplementation "org.springframework.boot:spring-boot-starter-test"
}
Expand Down
5 changes: 0 additions & 5 deletions deploy/docker-compose.exposed.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
services:
jaeger:
ports:
- 127.0.0.1:16686:16686
- 127.0.0.1:6831:6831/udp

fhir-db:
ports:
- 127.0.0.1:15432:5432
Expand Down
13 changes: 0 additions & 13 deletions deploy/docker-compose.gw-deps.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
services:
jaeger:
image: jaegertracing/all-in-one:1.45@sha256:5d5c9d2d8c8cbb42f1db4aac1f1f8487bac63da6802004d0da8580fc0c7311a1

fhir-pseudonymizer:
image: ghcr.io/miracum/fhir-pseudonymizer:v2.17.0@sha256:431a7f4516c1f641966c507941b87a997441665656572a1c00c44376ef08fe24
environment:
Tracing__IsEnabled: "true"
Tracing__Jaeger__AgentHost: jaeger
Tracing__Jaeger__AgentPort: 6831
Vfps__Address: "dns:///vfps:8081"
UseSystemTextJsonFhirSerializer: "true"
PseudonymizationService: "Vfps"
volumes:
- ${PWD}/deploy/anonymization.yaml:/etc/anonymization.yaml:ro
depends_on:
- jaeger
- vfps

loinc-converter:
image: harbor.miracum.org/miracum-etl/loinc-conversion:v1.14.2@sha256:9815eb71c13fa2a0b74df6492f41cc2d7b9969696984e6045b6217600ad1f0e1
environment:
JAEGER_AGENT_HOST: jaeger
depends_on:
- jaeger

vfps-db:
image: docker.io/library/postgres:15.3@sha256:31c9342603866f29206a06b77c8fed48b3c3f70d710a4be4e8216b134f92d0df
Expand Down Expand Up @@ -67,8 +56,6 @@ services:
ConnectionStrings__PostgreSQL: "Host=vfps-db:5432;Database=vfps;Timeout=60;Max Auto Prepare=5;Application Name=vfps;Maximum Pool Size=50;"
PGUSER: postgres
PGPASSWORD: postgres
Tracing__IsEnabled: "true"
Tracing__Jaeger__AgentHost: "jaeger"
Pseudonymization__Caching__Namespaces__IsEnabled: "true"
depends_on:
- vfps-db
Expand Down
3 changes: 0 additions & 3 deletions deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ services:
SERVICES_PSQL_ENABLED: ${SERVICES_PSQL_ENABLED:-true}
SERVICES_KAFKA_ENABLED: ${SERVICES_KAFKA_ENABLED:-false}
BOOTSTRAP_SERVERS: ${BOOTSTRAP_SERVERS:-kafka1:19092}
OPENTRACING_JAEGER_ENABLED: ${OPENTRACING_JAEGER_ENABLED:-true}
OPENTRACING_JAEGER_UDP_SENDER_HOST: ${OPENTRACING_JAEGER_UDP_SENDER_HOST:-jaeger}
depends_on:
- loinc-converter
- fhir-db
- jaeger
- fhir-pseudonymizer
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 10 additions & 6 deletions gradlew
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -133,26 +130,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
58 changes: 0 additions & 58 deletions src/main/java/org/miracum/etl/fhirgateway/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,19 @@
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
import io.jaegertracing.internal.propagation.TraceContextCodec;
import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.binder.okhttp3.OkHttpMetricsEventListener;
import io.opentracing.Span;
import io.opentracing.contrib.java.spring.jaeger.starter.TracerBuilderCustomizer;
import io.opentracing.contrib.okhttp3.OkHttpClientSpanDecorator;
import io.opentracing.contrib.okhttp3.TracingInterceptor;
import io.opentracing.propagation.Format;
import io.opentracing.util.GlobalTracer;
import java.util.Arrays;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
import okhttp3.Connection;
import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.miracum.etl.fhirgateway.processors.FhirPseudonymizer;
import org.miracum.etl.fhirgateway.processors.IPseudonymizer;
import org.miracum.etl.fhirgateway.processors.NoopPseudonymizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -60,37 +48,15 @@ public FhirContext fhirContext(
boolean useLoadBalancerConnectionPool) {
var fhirContext = FhirContext.forR4();

var opNameDecorator =
new OkHttpClientSpanDecorator() {
@Override
public void onRequest(Request request, Span span) {
// add the operation name to the span
span.setOperationName(request.url().encodedPath());
}

@Override
public void onError(Throwable throwable, Span span) {}

@Override
public void onResponse(Connection connection, Response response, Span span) {}
};

var connectionPool = new ConnectionPool();
if (useLoadBalancerConnectionPool) {
connectionPool =
new ConnectionPool(
MAX_IDLE_CONNECTIONS, KEEP_ALIVE_DURATION_MILLISECONDS, TimeUnit.MILLISECONDS);
}

var tracingInterceptor =
new TracingInterceptor(
GlobalTracer.get(),
Arrays.asList(OkHttpClientSpanDecorator.STANDARD_TAGS, opNameDecorator));

var okclient =
new OkHttpClient.Builder()
.addInterceptor(tracingInterceptor)
.addNetworkInterceptor(tracingInterceptor)
.connectionPool(connectionPool)
.eventListener(
OkHttpMetricsEventListener.builder(Metrics.globalRegistry, "fhir.client").build())
Expand All @@ -103,21 +69,6 @@ public void onResponse(Connection connection, Response response, Span span) {}
return fhirContext;
}

@Bean
public TracerBuilderCustomizer traceContextJaegerTracerCustomizer() {
return builder -> {
var injector = new TraceContextCodec.Builder().build();

builder
.registerInjector(Format.Builtin.HTTP_HEADERS, injector)
.registerExtractor(Format.Builtin.HTTP_HEADERS, injector);

builder
.registerInjector(Format.Builtin.TEXT_MAP, injector)
.registerExtractor(Format.Builtin.TEXT_MAP, injector);
};
}

@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
Expand Down Expand Up @@ -205,13 +156,4 @@ public IPseudonymizer fhirPseudonymizer(
return new NoopPseudonymizer();
}
}

@Bean
@ConditionalOnProperty(
value = "opentracing.jaeger.enabled",
havingValue = "false",
matchIfMissing = false)
public io.opentracing.Tracer jaegerTracer() {
return io.opentracing.noop.NoopTracerFactory.create();
}
}
6 changes: 0 additions & 6 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ services:
match-expression: "fhir\\."
replace-with: "fhir.post-gateway-pseuded-"

opentracing:
jaeger:
probabilistic-sampler:
sampling-rate: 1
log-spans: true

spring:
datasource:
url: jdbc:postgresql://localhost:15432/fhir
Expand Down
8 changes: 1 addition & 7 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ spring:
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.miracum.kafka.serializers.KafkaFhirSerializer
cloud:
function.definition: process
stream:
function.definition: process
bindings:
process-in-0:
consumer:
Expand Down Expand Up @@ -102,12 +102,6 @@ fhir:
systems:
loinc: "http://loinc.org"

opentracing:
jaeger:
udp-sender:
host: localhost
log-spans: false

app:
version: 0.0.0-dev

Expand Down

0 comments on commit db98fcf

Please sign in to comment.