Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Run the tests
timeout-minutes: 90 # We need a long timeout here
env:
MAVEN_OPTS: -Xmx12g -Xms4g -XX:MaxMetaspaceSize=1g
MAVEN_OPTS: -Xmx20g
run: mvn --batch-mode --no-transfer-progress --update-snapshots -Dmatchbox.version="${{ env.MATCHBOX_VERSION }}" verify site
working-directory: matchbox-int-tests

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
cache: maven

- name: Run the tests in Maven
timeout-minutes: 15
timeout-minutes: 30
# We need a timeout here
env:
MAVEN_OPTS: -Xmx12g
MAVEN_OPTS: -Xmx20g
run: mvn --batch-mode --no-transfer-progress --update-snapshots verify

- uses: actions/upload-artifact@v4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ca.uhn.fhir.jpa.starter;

import ch.ahdis.matchbox.MatchboxRestfulServer;
import ch.ahdis.matchbox.config.MatchboxMetricsConfig;
import ch.ahdis.matchbox.config.MatchboxStaticResourceConfig;
import ch.ahdis.matchbox.config.MatchboxTxConfig;
import ch.ahdis.matchbox.spring.MatchboxEventListener;
Expand Down Expand Up @@ -39,7 +40,8 @@
RegistryWs.class,
MatchboxStaticResourceConfig.class,
McpServerConfig.class,
MatchboxTxConfig.class
MatchboxTxConfig.class,
MatchboxMetricsConfig.class
})
public class Application extends SpringBootServletInitializer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,10 @@ public int hashCode() {
return result;
}

public String sessionId() {
return String.valueOf(this.hashCode());
}

@Override
public String toString() {
return "CliContext{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import ch.ahdis.matchbox.packages.*;
import ch.ahdis.matchbox.providers.*;
import ch.ahdis.matchbox.questionnaire.*;
import ch.ahdis.matchbox.util.MatchboxEngineCache;
import ch.ahdis.matchbox.util.MatchboxEngineSupport;
import ch.ahdis.matchbox.util.MatchboxPackageInstallerImpl;
import ch.ahdis.matchbox.validation.ValidationProvider;
Expand Down Expand Up @@ -242,11 +243,17 @@ public CliContext getCliContext(final Environment environment) {
return new CliContext(environment);
}

@Bean
public MatchboxEngineCache matchboxEngineCache() {
return new MatchboxEngineCache();
}

@Bean
public MatchboxEngineSupport getMatchboxEngineSupport(final MatchboxFhirContextProperties matchboxFhirContextProperties,
final CliContext cliContext,
@Value("${hapi.fhir.fhir_version}") final FhirVersionEnum serverFhirVersion) {
return new MatchboxEngineSupport(matchboxFhirContextProperties, cliContext, serverFhirVersion);
@Value("${hapi.fhir.fhir_version}") final FhirVersionEnum serverFhirVersion,
final MatchboxEngineCache matchboxEngineCache) {
return new MatchboxEngineSupport(matchboxFhirContextProperties, cliContext, serverFhirVersion, matchboxEngineCache);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package ch.ahdis.matchbox.config;

import ch.ahdis.matchbox.packages.MatchboxImplementationGuideProvider;
import ch.ahdis.matchbox.util.MatchboxEngineCache;
import ch.ahdis.matchbox.util.metrics.MatchboxMetrics;
import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.MeterBinder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* Configuration for collecting Matchbox metrics and exposing them via Micrometer.
**/
@Configuration
public class MatchboxMetricsConfig {
private static final String ENGINE_UNIT = "engines";

@Bean
public MeterBinder exposeNumberOfCachedEngines(final MatchboxEngineCache engineCache) {
return registry -> {
Gauge.builder("matchbox.engines.cached.transient.number", engineCache::numberOfTransientEngines)
.description("Number of cached expiring Matchbox engines in the server")
.baseUnit(ENGINE_UNIT)
.register(registry);
Gauge.builder("matchbox.engines.cached.permanent.number", engineCache::numberOfPermanentEngines)
.description("Number of cached immutable Matchbox engines in the server")
.baseUnit(ENGINE_UNIT)
.register(registry);
};
}

@Bean
public MeterBinder exposeNumberOfIgs(final MatchboxImplementationGuideProvider implementationGuideProvider) {
return registry -> Gauge.builder("matchbox.igs.number", implementationGuideProvider::count)
.description("Number of installed ImplementationGuides")
.baseUnit("ImplementationGuides")
.register(registry);
}

@Bean
public MatchboxMetrics matchboxMetrics(final MeterRegistry meterRegistry) {
return new MatchboxMetrics(meterRegistry);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Set;
import java.util.*;

import ch.ahdis.matchbox.util.metrics.MatchboxMetrics;
import jakarta.servlet.ServletOutputStream;
/*
* #%L
Expand Down Expand Up @@ -59,8 +59,6 @@
import org.hl7.fhir.r5.model.*;

import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;

/**
* StructureMapTransformProvider
Expand All @@ -70,6 +68,9 @@ public class StructureMapTransformProvider extends StructureMapResourceProvider
@Autowired
protected MatchboxEngineSupport matchboxEngineSupport;

@Autowired(required = false)
private Optional<MatchboxMetrics> matchboxMetrics;

private final FhirContext fhirR5Context = FhirContext.forR5Cached();

@Override
Expand Down Expand Up @@ -97,6 +98,7 @@ public MethodOutcome update(final HttpServletRequest theRequest,
@Operation(name = "$transform", type = StructureMap.class, manualResponse = true, manualRequest = true)
public void manualInputAndOutput(final HttpServletRequest theServletRequest,
final HttpServletResponse theServletResponse) throws IOException {
this.matchboxMetrics.ifPresent(MatchboxMetrics::addTransformation);
// Parse the request body, it is either a Parameters resource, or any resource
final String body = new String(theServletRequest.getInputStream().readAllBytes()).trim();
@Nullable String resource = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,4 +539,8 @@ public void installFromInternetRegistry(final String packageId, final String pac
.setVersion(packageVersion)
);
}

public long count() {
return this.myPackageVersionDao.count();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,8 @@ public void installFromInternetRegistry(final String packageId, final String pac
.setVersion(packageVersion)
);
}

public long count() {
return this.myPackageVersionDao.count();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -525,4 +525,8 @@ public void installFromInternetRegistry(final String packageId, final String pac
.setVersion(packageVersion)
);
}

public long count() {
return this.myPackageVersionDao.count();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ public interface MatchboxImplementationGuideProvider {
* Installs the given ImplementationGuide from the internet registry.
*/
void installFromInternetRegistry(final String packageId, final String packageVersion);

/**
* Counts the number of installed ImplementationGuides.
*/
long count();
}

This file was deleted.

Loading
Loading