diff --git a/backend_go/surface_query/handlers/handle_sample_in_points.go b/backend_go/surface_query/handlers/handle_sample_in_points.go index 054928ade..f8e716317 100644 --- a/backend_go/surface_query/handlers/handle_sample_in_points.go +++ b/backend_go/surface_query/handlers/handle_sample_in_points.go @@ -30,8 +30,9 @@ type RealizationSampleResult struct { } type PointSamplingResponse struct { - SampleResultArr []RealizationSampleResult `json:"sampleResultArr" binding:"required"` - UndefLimit float32 `json:"undefLimit" binding:"required"` + SampleResultArr []RealizationSampleResult `json:"sampleResultArr" binding:"required"` + UndefLimit float32 `json:"undefLimit" binding:"required"` + CalculationTime_ms int `json:"calculationTime_ms" binding:"required"` } func HandleSampleInPoints(c *gin.Context) { @@ -66,14 +67,16 @@ func HandleSampleInPoints(c *gin.Context) { // TO-DISCUSS: // Must check this out in relation to the xtgeo code // Undef value and limit seem to be misaligned!!! + duration_ms := (time.Now().Sub(startTime)) / time.Millisecond retResultArr := make([]RealizationSampleResult, len(perRealSamplesArr)) for i := range retResultArr { retResultArr[i] = RealizationSampleResult(perRealSamplesArr[i]) } responseBody := PointSamplingResponse{ - SampleResultArr: retResultArr, - UndefLimit: 0.99e30, + SampleResultArr: retResultArr, + UndefLimit: 0.99e30, + CalculationTime_ms: int(duration_ms), } c.JSON(http.StatusOK, responseBody) diff --git a/backend_py/primary/primary/services/surface_query_service/surface_query_service.py b/backend_py/primary/primary/services/surface_query_service/surface_query_service.py index 38a9c4f1b..179072b94 100644 --- a/backend_py/primary/primary/services/surface_query_service/surface_query_service.py +++ b/backend_py/primary/primary/services/surface_query_service/surface_query_service.py @@ -38,6 +38,7 @@ class _PointSamplingRequestBody(BaseModel): class _PointSamplingResponseBody(BaseModel): sampleResultArr: List[RealizationSampleResult] undefLimit: float + calculationTime_ms: int # URL of the Go server endpoint @@ -96,6 +97,9 @@ async def batch_sample_surface_in_points_async( json_data: bytes = response.content response_body = _PointSamplingResponseBody.model_validate_json(json_data) + perf_metrics.set_metric("inner-go-call", response_body.calculationTime_ms) + + # Replace values above the undefLimit with np.nan for res in response_body.sampleResultArr: values_np = np.asarray(res.sampledValues)