Skip to content

Commit

Permalink
Merge pull request #868 from sabith-nadakkavil/openTelemetry
Browse files Browse the repository at this point in the history
feat: Integrate Open Observe for telemetry tracking #866
  • Loading branch information
ratheesh-kr authored Dec 11, 2024
2 parents 97b5a70 + 4b73b10 commit 961b96e
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 232 deletions.
53 changes: 24 additions & 29 deletions hub-prime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>
<groupId>org.techbd</groupId>
<artifactId>hub-prime</artifactId>
<version>0.376.0</version>
<version>0.377.0</version>
<packaging>war</packaging>
<name>Tech by Design Hub (Prime)</name>
<description>Tech by Design Hub (Primary)</description>
Expand All @@ -34,13 +34,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-bom</artifactId>
<version>1.44.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -318,28 +311,30 @@
<artifactId>hapi-fhir-client</artifactId>
<version>7.4.0</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp</artifactId>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-otlp</artifactId>
<version>1.14.1</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-otel</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>3.9.1</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-spring-boot-starter</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>3.0.0</version> <!-- Use a compatible version -->
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</dependency>
</dependencies>

<build>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@

import io.micrometer.common.util.StringUtils;
import io.netty.handler.ssl.SslContextBuilder;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
import jakarta.annotation.Nonnull;
import jakarta.servlet.http.Cookie;
Expand Down Expand Up @@ -117,8 +116,6 @@ public Object processBundle(final @RequestBody @Nonnull String payload,
HttpServletRequest request, HttpServletResponse response, String provenance,
boolean includeOperationOutcome, String mtlsStrategy)
throws IOException {
Span span = tracer.spanBuilder("FHIRService.processBundle").startSpan();
try {
final var start = Instant.now();
LOG.info("Bundle processing start at {} for interaction id {}.",
start, getBundleInteractionId(request));
Expand Down Expand Up @@ -182,9 +179,6 @@ public Object processBundle(final @RequestBody @Nonnull String payload,
LOG.info("Bundle processing end for interaction id: {} Time Taken : {} milliseconds",
interactionId, timeElapsed.toMillis());
return payloadWithDisposition;
} finally {
span.end();
}
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -261,8 +255,6 @@ private Map<String, Object> registerBundleInteraction(org.jooq.Configuration joo
HttpServletRequest request, HttpServletResponse response,
String payload, Map<String, Map<String, Object>> validationResult)
throws IOException {
Span span = tracer.spanBuilder("FHIRService.registerBundleInteraction").startSpan();
try {
final Interactions interactions = new Interactions();
final var mutatableReq = new ContentCachingRequestWrapper(request);
RequestEncountered requestEncountered = null;
Expand Down Expand Up @@ -307,9 +299,6 @@ private Map<String, Object> registerBundleInteraction(org.jooq.Configuration joo
rre.tenant(), e);
}
return null;
} finally {
span.end();
}
}

private void prepareRequest(RegisterInteractionHttpRequest rihr, RequestResponseEncountered rre,
Expand Down Expand Up @@ -380,8 +369,6 @@ private void setActiveInteraction(final @NonNull HttpServletRequest request,
private Map<String, Object> validate(HttpServletRequest request, String payload, String fhirProfileUrl,
String uaValidationStrategyJson,
boolean includeRequestInOutcome) {
Span span = tracer.spanBuilder("FhirService.validate").startSpan();
try {
final var start = Instant.now();
String interactionId = getBundleInteractionId(request);
LOG.info("FHIRService - Validate -BEGIN for interactionId: {} ", interactionId);
Expand Down Expand Up @@ -443,9 +430,6 @@ private Map<String, Object> validate(HttpServletRequest request, String payload,
LOG.info("FHIRService - Validate -END for interaction id: {} Time Taken : {} milliseconds",
interactionId, timeElapsed.toMillis());
}
} finally {
span.end();
}
}

private void sendToScoringEngine(org.jooq.Configuration jooqCfg, HttpServletRequest request,
Expand All @@ -457,8 +441,6 @@ private void sendToScoringEngine(org.jooq.Configuration jooqCfg, HttpServletRequ
String provenance,
Map<String, Object> validationPayloadWithDisposition, boolean includeOperationOutcome,
String mtlsStrategy) {
Span span = tracer.spanBuilder("FhirService.sentToScoringEngine").startSpan();
try {
final var interactionId = getBundleInteractionId(request);
LOG.info("FHIRService:: sendToScoringEngine BEGIN for interaction id: {} for", interactionId);

Expand Down Expand Up @@ -508,9 +490,6 @@ private void sendToScoringEngine(org.jooq.Configuration jooqCfg, HttpServletRequ
} finally {
LOG.info("FHIRService:: sendToScoringEngine END for interaction id: {}", interactionId);
}
} finally {
span.end();
}
}

public void handleMTlsStrategy(DefaultDataLakeApiAuthn defaultDatalakeApiAuthn, String interactionId,
Expand Down Expand Up @@ -1024,8 +1003,6 @@ private void sendPostRequest(WebClient webClient,
org.jooq.Configuration jooqCfg,
String provenance,
String requestURI, String scoringEngineApiURL) {
Span span = tracer.spanBuilder("FhirService.sendPostRequest").startSpan();
try {
LOG.debug("FHIRService:: sendToScoringEngine Post to scoring engine - BEGIN interaction id: {} tenantID :{}",
interactionId, tenantId);

Expand All @@ -1048,9 +1025,6 @@ private void sendPostRequest(WebClient webClient,

LOG.info("FHIRService:: sendToScoringEngine Post to scoring engine - END interaction id: {} tenantid: {}",
interactionId, tenantId);
} finally {
span.end();
}
}

private void handleResponse(String response,
Expand All @@ -1060,8 +1034,6 @@ private void handleResponse(String response,
String tenantId,
String provenance,
String scoringEngineApiURL) {
Span span = tracer.spanBuilder("FhirService.handleResponse").startSpan();
try {
LOG.debug("FHIRService:: handleResponse BEGIN for interaction id: {}", interactionId);

try {
Expand Down Expand Up @@ -1089,9 +1061,6 @@ private void handleResponse(String response,
provenance);
}
LOG.info("FHIRService:: handleResponse END for interaction id: {}", interactionId);
} finally {
span.end();
}
}

private void handleError(Map<String, Object> validationPayloadWithDisposition,
Expand Down Expand Up @@ -1235,8 +1204,6 @@ private void registerStateForward(org.jooq.Configuration jooqCfg, String provena
String tenantId,
Map<String, Object> payloadWithDisposition,
String outboundHttpMessage, boolean includeIncomingPayloadInDB, String payload) {
Span span = tracer.spanBuilder("FHIRService.registerStateForward").startSpan();
try {
LOG.info("REGISTER State Forward : BEGIN for inteaction id : {} tenant id : {}",
bundleAsyncInteractionId, tenantId);
final var forwardedAt = OffsetDateTime.now();
Expand Down Expand Up @@ -1278,16 +1245,11 @@ private void registerStateForward(org.jooq.Configuration jooqCfg, String provena
tenantId,
e);
}
} finally {
span.end();
}
}

private void registerStateComplete(org.jooq.Configuration jooqCfg, String bundleAsyncInteractionId,
String requestURI, String tenantId,
String response, String provenance) {
Span span = tracer.spanBuilder("FHIRService.registerStateComplete").startSpan();
try {
LOG.info("REGISTER State Complete : BEGIN for interaction id : {} tenant id : {}",
bundleAsyncInteractionId, tenantId);
final var forwardRIHR = new RegisterInteractionHttpRequest();
Expand Down Expand Up @@ -1325,16 +1287,11 @@ private void registerStateComplete(org.jooq.Configuration jooqCfg, String bundle
+ forwardRIHR.getName()
+ " forwardRIHR error", bundleAsyncInteractionId, tenantId, e);
}
} finally {
span.end();
}
}

private void registerStateFailed(org.jooq.Configuration jooqCfg, String bundleAsyncInteractionId,
String requestURI, String tenantId,
String response, String provenance) {
Span span = tracer.spanBuilder("FHIRService.registerStateFailed").startSpan();
try {
LOG.info("REGISTER State Fail : BEGIN for interaction id : {} tenant id : {}",
bundleAsyncInteractionId, tenantId);
final var forwardRIHR = new RegisterInteractionHttpRequest();
Expand Down Expand Up @@ -1374,17 +1331,12 @@ private void registerStateFailed(org.jooq.Configuration jooqCfg, String bundleAs
+ forwardRIHR.getName()
+ " forwardRIHR error", bundleAsyncInteractionId, tenantId, e);
}
} finally {
span.end();
}
}

private void registerStateFailure(org.jooq.Configuration jooqCfg, String dataLakeApiBaseURL,
String bundleAsyncInteractionId, Throwable error,
String requestURI, String tenantId,
String provenance) {
Span span = tracer.spanBuilder("FhirService.registerStateFailure").startSpan();
try {
LOG.error("Register State Failure - Exception while sending FHIR payload to datalake URL {} for interaction id {}",
dataLakeApiBaseURL, bundleAsyncInteractionId, error);
final var errorRIHR = new RegisterInteractionHttpRequest();
Expand Down Expand Up @@ -1468,9 +1420,6 @@ private void registerStateFailure(org.jooq.Configuration jooqCfg, String dataLak
tenantId,
e);
}
} finally {
span.end();
}
}

private String getBundleInteractionId(HttpServletRequest request) {
Expand Down
Loading

0 comments on commit 961b96e

Please sign in to comment.