Skip to content

Commit

Permalink
[Metrics] Track latency under Search endpoint (#3850)
Browse files Browse the repository at this point in the history
* Add latency metric to one more search endpoint

* New test. Organizing tests alphabetically.
  • Loading branch information
fhibf committed May 13, 2024
1 parent e390c4e commit a26b9b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ public void WhenProvidedAFhirController_CheckIfAllExpectedServiceFilterAttribute
[Fact]
public void WhenProvidedAFhirController_CheckIfTheBundleEndpointHasTheLatencyMetricFilter()
{
const string methodName = "BatchAndTransactions";
Type expectedCustomAttribute = typeof(BundleEndpointMetricEmitterAttribute);

TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, methodName, _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "BatchAndTransactions", _targetFhirControllerClass);
}

[Fact]
public void WhenProvidedAFhirController_CheckIfTheSearchEndpointsHaveTheLatencyMetricFilter()
{
Type expectedCustomAttribute = typeof(SearchEndpointMetricEmitterAttribute);

TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "SearchCompartmentByResourceType", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "SearchByResourceType", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "History", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "TypeHistory", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "Search", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "SearchByResourceType", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "SearchCompartmentByResourceType", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "SystemHistory", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "TypeHistory", _targetFhirControllerClass);
}

[Fact]
Expand All @@ -77,10 +77,10 @@ public void WhenProvidedAFhirController_CheckIfTheCrudEndpointsHaveTheLatencyMet
Type expectedCustomAttribute = typeof(CrudEndpointMetricEmitterAttribute);

TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "Create", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "Update", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "Delete", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "Read", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "Update", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "VRead", _targetFhirControllerClass);
TestIfTargetMethodContainsCustomAttribute(expectedCustomAttribute, "Delete", _targetFhirControllerClass);
}

private static void TestIfTargetMethodContainsCustomAttribute(Type expectedCustomAttributeType, string methodName, Type targetClassType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ public async Task<IActionResult> ConditionalPatchFhir(string typeParameter, [Fro
[HttpGet]
[Route("", Name = RouteNames.SearchAllResources)]
[AuditEventType(AuditEventSubType.SearchSystem)]
[TypeFilter(typeof(SearchEndpointMetricEmitterAttribute))]
public async Task<IActionResult> Search()
{
return await SearchByResourceType(typeParameter: null);
Expand Down

0 comments on commit a26b9b3

Please sign in to comment.