This is an automated email from the ASF dual-hosted git repository. zqr10159 pushed a commit to branch 2.0.0 in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
commit fd6f5590bf6f8f5c1b36df9e69c3df13381cda14 Author: Logic <[email protected]> AuthorDate: Wed Aug 26 15:20:03 2026 +0800 feat: preserve observability backpressure signals --- .../error/OtlpIngestionBackpressureHeaders.java | 7 +++--- .../ingestion/forwarder/GreptimeOtlpForwarder.java | 20 ++++++++-------- .../ingestion/quota/OtlpIngestionQuotaService.java | 27 +++++++++++----------- .../controller/OtlpLogControllerTest.java | 5 +++- .../OtlpIngestionBackpressureHeadersTest.java | 10 ++++++++ .../forwarder/GreptimeOtlpForwarderTest.java | 7 +++--- .../quota/OtlpIngestionQuotaServiceTest.java | 4 ++++ .../impl/OtlpGrpcIngestionServiceImplTest.java | 4 ++-- .../warehouse/db/GreptimePromqlQueryExecutor.java | 13 +++++++++++ .../warehouse/db/PromqlQueryExecutor.java | 10 +++++--- .../db/GreptimePromqlQueryExecutorTest.java | 2 ++ 11 files changed, 72 insertions(+), 37 deletions(-) diff --git a/hertzbeat-observability/src/main/java/org/apache/hertzbeat/observability/ingestion/error/OtlpIngestionBackpressureHeaders.java b/hertzbeat-observability/src/main/java/org/apache/hertzbeat/observability/ingestion/error/OtlpIngestionBackpressureHeaders.java index f9f0ea9ba1..086fd01a96 100644 --- a/hertzbeat-observability/src/main/java/org/apache/hertzbeat/observability/ingestion/error/OtlpIngestionBackpressureHeaders.java +++ b/hertzbeat-observability/src/main/java/org/apache/hertzbeat/observability/ingestion/error/OtlpIngestionBackpressureHeaders.java @@ -34,6 +34,7 @@ import org.springframework.http.HttpHeaders; */ public final class OtlpIngestionBackpressureHeaders { + private static final String DEFAULT_RETRY_AFTER_SECONDS = "1"; private static final long MAX_RETRY_AFTER_SECONDS = 60L; public static final Metadata.Key<String> RETRY_AFTER_TRAILER_KEY = @@ -62,11 +63,9 @@ public final class OtlpIngestionBackpressureHeaders { private static Metadata retryAfterTrailers(HttpHeaders responseHeaders) { String retryAfter = retryAfter(responseHeaders); - if (retryAfter == null) { - return null; - } Metadata trailers = new Metadata(); - trailers.put(RETRY_AFTER_TRAILER_KEY, retryAfter); + trailers.put(RETRY_AFTER_TRAILER_KEY, + StringUtils.defaultIfBlank(retryAfter, DEFAULT_RETRY_AFTER_SECONDS)); return trailers; } diff --git a/hertzbeat-observability/src/main/java/org/apache/hertzbeat/observability/ingestion/forwarder/GreptimeOtlpForwarder.java b/hertzbeat-observability/src/main/java/org/apache/hertzbeat/observability/ingestion/forwarder/GreptimeOtlpForwarder.java index 3a555260f4..b0ab16f9d3 100644 --- a/hertzbeat-observability/src/main/java/org/apache/hertzbeat/observability/ingestion/forwarder/GreptimeOtlpForwarder.java +++ b/hertzbeat-observability/src/main/java/org/apache/hertzbeat/observability/ingestion/forwarder/GreptimeOtlpForwarder.java @@ -122,8 +122,8 @@ public class GreptimeOtlpForwarder { GreptimeProperties greptimeProperties = greptimePropertiesOrUnavailable(); if (greptimeProperties == null || !greptimeProperties.enabled() || StringUtils.isBlank(greptimeProperties.httpEndpoint())) { - throw io.grpc.Status.UNAVAILABLE.withDescription("OTLP backend is not configured.") - .asRuntimeException(); + throw OtlpIngestionBackpressureHeaders.statusRuntimeException( + io.grpc.Status.UNAVAILABLE, "OTLP backend is not configured.", null); } addGreptimeCommonHeaders(headers, greptimeProperties); addAuthenticationHeader(headers, greptimeProperties); @@ -136,8 +136,8 @@ public class GreptimeOtlpForwarder { ), retryableResponse -> retryableResponse == null || retryService.isRetryableStatus(retryableResponse.getStatusCode())); if (response == null) { - throw io.grpc.Status.UNAVAILABLE.withDescription("OTLP backend returned no response.") - .asRuntimeException(); + throw OtlpIngestionBackpressureHeaders.statusRuntimeException( + io.grpc.Status.UNAVAILABLE, "OTLP backend returned no response.", null); } if (!response.getStatusCode().is2xxSuccessful()) { throw backendStatusException(response.getStatusCode(), response.getHeaders()); @@ -148,10 +148,9 @@ public class GreptimeOtlpForwarder { throw backendStatusException(ex.getStatusCode(), ex.getResponseHeaders()); } catch (RestClientException ex) { log.error("Failed to forward OTLP payload to Greptime path {}: {}", path, ex.getMessage(), ex); - throw io.grpc.Status.UNAVAILABLE - .withDescription(StringUtils.defaultIfBlank(ex.getMessage(), "OTLP backend request failed.")) - .withCause(ex) - .asRuntimeException(); + throw OtlpIngestionBackpressureHeaders.statusRuntimeException( + io.grpc.Status.UNAVAILABLE.withCause(ex), + StringUtils.defaultIfBlank(ex.getMessage(), "OTLP backend request failed."), null); } } @@ -160,9 +159,8 @@ public class GreptimeOtlpForwarder { return greptimePropertiesProvider.getIfAvailable(); } catch (RuntimeException ex) { log.warn("Failed to resolve Greptime OTLP log backend properties: {}", ex.toString()); - throw io.grpc.Status.UNAVAILABLE.withDescription("OTLP backend is not configured.") - .withCause(ex) - .asRuntimeException(); + throw OtlpIngestionBackpressureHeaders.statusRuntimeException( + io.grpc.Status.UNAVAILABLE.withCause(ex), "OTLP backend is not configured.", null); } } diff --git a/hertzbeat-observability/src/main/java/org/apache/hertzbeat/observability/ingestion/quota/OtlpIngestionQuotaService.java b/hertzbeat-observability/src/main/java/org/apache/hertzbeat/observability/ingestion/quota/OtlpIngestionQuotaService.java index fa44ace57e..93fb4ace0d 100644 --- a/hertzbeat-observability/src/main/java/org/apache/hertzbeat/observability/ingestion/quota/OtlpIngestionQuotaService.java +++ b/hertzbeat-observability/src/main/java/org/apache/hertzbeat/observability/ingestion/quota/OtlpIngestionQuotaService.java @@ -18,6 +18,7 @@ package org.apache.hertzbeat.observability.ingestion.quota; import io.grpc.Status; +import io.grpc.StatusRuntimeException; import io.opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest; import io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest; import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest; @@ -36,6 +37,7 @@ import java.lang.management.MemoryUsage; import java.util.List; import java.util.function.DoubleSupplier; import org.apache.commons.lang3.StringUtils; +import org.apache.hertzbeat.observability.ingestion.error.OtlpIngestionBackpressureHeaders; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -81,10 +83,8 @@ public class OtlpIngestionQuotaService { public void checkRequestBytes(String signal, String protocol, long requestBytes) { if (maxRequestBytes > 0 && Math.max(requestBytes, 0L) > maxRequestBytes) { - throw Status.RESOURCE_EXHAUSTED - .withDescription("OTLP " + dimension(signal) + " " + dimension(protocol) - + " payload exceeds " + maxRequestBytes + " bytes.") - .asRuntimeException(); + throw resourceExhausted("OTLP " + dimension(signal) + " " + dimension(protocol) + + " payload exceeds " + maxRequestBytes + " bytes."); } checkMemoryPressure(signal, protocol); } @@ -118,10 +118,8 @@ public class OtlpIngestionQuotaService { checkMemoryPressure(signal, protocol); return; } - throw Status.RESOURCE_EXHAUSTED - .withDescription("OTLP " + dimension(signal) + " " + dimension(protocol) - + " batch exceeds " + maxSignalItems + " signal items.") - .asRuntimeException(); + throw resourceExhausted("OTLP " + dimension(signal) + " " + dimension(protocol) + + " batch exceeds " + maxSignalItems + " signal items."); } private void checkMemoryPressure(String signal, String protocol) { @@ -132,11 +130,14 @@ public class OtlpIngestionQuotaService { if (heapUsageRatio < maxHeapUsageRatio) { return; } - throw Status.RESOURCE_EXHAUSTED - .withDescription("OTLP " + dimension(signal) + " " + dimension(protocol) - + " ingestion paused because heap usage is " + percent(heapUsageRatio) - + "% (limit " + percent(maxHeapUsageRatio) + "%).") - .asRuntimeException(); + throw resourceExhausted("OTLP " + dimension(signal) + " " + dimension(protocol) + + " ingestion paused because heap usage is " + percent(heapUsageRatio) + + "% (limit " + percent(maxHeapUsageRatio) + "%)."); + } + + private StatusRuntimeException resourceExhausted(String description) { + return OtlpIngestionBackpressureHeaders.statusRuntimeException( + Status.RESOURCE_EXHAUSTED, description, null); } private boolean isValidHeapPressureLimit() { diff --git a/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/controller/OtlpLogControllerTest.java b/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/controller/OtlpLogControllerTest.java index c90eb56540..fe8d170791 100644 --- a/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/controller/OtlpLogControllerTest.java +++ b/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/controller/OtlpLogControllerTest.java @@ -26,6 +26,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import java.io.ByteArrayOutputStream; @@ -64,8 +65,9 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.http.MediaType; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; @@ -371,6 +373,7 @@ class OtlpLogControllerTest { .content(binaryContent) ) .andExpect(status().isTooManyRequests()) + .andExpect(header().string(HttpHeaders.RETRY_AFTER, "1")) .andExpect(content().contentType(CONTENT_TYPE_PROTOBUF)) .andReturn(); diff --git a/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/error/OtlpIngestionBackpressureHeadersTest.java b/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/error/OtlpIngestionBackpressureHeadersTest.java index edf0b0c22c..6ccdfb11ca 100644 --- a/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/error/OtlpIngestionBackpressureHeadersTest.java +++ b/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/error/OtlpIngestionBackpressureHeadersTest.java @@ -75,6 +75,16 @@ class OtlpIngestionBackpressureHeadersTest { assertEquals(retryAfter, OtlpIngestionBackpressureHeaders.retryAfter(exception)); } + @Test + void suppliesDefaultRetryAfterWhenBackendIsUnavailableWithoutHint() { + StatusRuntimeException exception = OtlpIngestionBackpressureHeaders.statusRuntimeException( + Status.UNAVAILABLE, "backend unavailable", null); + + assertEquals("1", exception.getTrailers() + .get(OtlpIngestionBackpressureHeaders.RETRY_AFTER_TRAILER_KEY)); + assertEquals("1", OtlpIngestionBackpressureHeaders.retryAfter(exception)); + } + @Test void dropsRetryAfterForNonBackpressureGrpcStatus() { HttpHeaders headers = new HttpHeaders(); diff --git a/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/forwarder/GreptimeOtlpForwarderTest.java b/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/forwarder/GreptimeOtlpForwarderTest.java index e5ae2fae61..246e4474fd 100644 --- a/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/forwarder/GreptimeOtlpForwarderTest.java +++ b/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/forwarder/GreptimeOtlpForwarderTest.java @@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; @@ -569,7 +568,7 @@ class GreptimeOtlpForwarderTest { } @Test - void logsGrpcBackendTooManyRequestsDropsMalformedRetryAfterTrailerAfterRetries() { + void logsGrpcBackendTooManyRequestsUsesDefaultForMalformedRetryAfter() { ExportLogsServiceRequest request = ExportLogsServiceRequest.getDefaultInstance(); configureGreptimeProperties(); when(restTemplate.exchange( @@ -586,7 +585,9 @@ class GreptimeOtlpForwarderTest { () -> forwarder.forwardLogsGrpc(request)); assertEquals(Status.Code.RESOURCE_EXHAUSTED, exception.getStatus().getCode()); - assertNull(exception.getTrailers()); + assertNotNull(exception.getTrailers()); + assertEquals("1", exception.getTrailers().get( + Metadata.Key.of("retry-after", Metadata.ASCII_STRING_MARSHALLER))); verify(restTemplate, times(2)).exchange( eq("http://greptime:4000/v1/otlp/v1/logs"), eq(HttpMethod.POST), diff --git a/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/quota/OtlpIngestionQuotaServiceTest.java b/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/quota/OtlpIngestionQuotaServiceTest.java index 8309339b48..1b7600cf8c 100644 --- a/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/quota/OtlpIngestionQuotaServiceTest.java +++ b/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/quota/OtlpIngestionQuotaServiceTest.java @@ -43,6 +43,7 @@ import io.opentelemetry.proto.metrics.v1.Sum; import io.opentelemetry.proto.trace.v1.ResourceSpans; import io.opentelemetry.proto.trace.v1.ScopeSpans; import io.opentelemetry.proto.trace.v1.Span; +import org.apache.hertzbeat.observability.ingestion.error.OtlpIngestionBackpressureHeaders; import org.junit.jupiter.api.Test; class OtlpIngestionQuotaServiceTest { @@ -64,6 +65,7 @@ class OtlpIngestionQuotaServiceTest { assertEquals(Status.Code.RESOURCE_EXHAUSTED, Status.fromThrowable(exception).getCode()); assertEquals("OTLP metrics grpc payload exceeds 2 bytes.", Status.fromThrowable(exception).getDescription()); + assertEquals("1", OtlpIngestionBackpressureHeaders.retryAfter(exception)); } @Test @@ -85,6 +87,7 @@ class OtlpIngestionQuotaServiceTest { assertEquals(Status.Code.RESOURCE_EXHAUSTED, Status.fromThrowable(exception).getCode()); assertEquals("OTLP logs http batch exceeds 1 signal items.", Status.fromThrowable(exception).getDescription()); + assertEquals("1", OtlpIngestionBackpressureHeaders.retryAfter(exception)); } @Test @@ -187,6 +190,7 @@ class OtlpIngestionQuotaServiceTest { assertEquals(Status.Code.RESOURCE_EXHAUSTED, Status.fromThrowable(exception).getCode()); assertEquals("OTLP metrics grpc ingestion paused because heap usage is 76% (limit 75%).", Status.fromThrowable(exception).getDescription()); + assertEquals("1", OtlpIngestionBackpressureHeaders.retryAfter(exception)); } @Test diff --git a/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/service/impl/OtlpGrpcIngestionServiceImplTest.java b/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/service/impl/OtlpGrpcIngestionServiceImplTest.java index cbd1aae90d..d5ee0335d8 100644 --- a/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/service/impl/OtlpGrpcIngestionServiceImplTest.java +++ b/hertzbeat-observability/src/test/java/org/apache/hertzbeat/observability/ingestion/service/impl/OtlpGrpcIngestionServiceImplTest.java @@ -2194,7 +2194,7 @@ class OtlpGrpcIngestionServiceImplTest { } @Test - void metricsHttpBackendTooManyRequestsDropsMalformedRetryAfterHeader() { + void metricsHttpBackendTooManyRequestsUsesDefaultForMalformedRetryAfter() { ExportMetricsServiceRequest request = ExportMetricsServiceRequest.newBuilder() .addResourceMetrics(ResourceMetrics.newBuilder() .addScopeMetrics(ScopeMetrics.newBuilder() @@ -2233,7 +2233,7 @@ class OtlpGrpcIngestionServiceImplTest { ResponseEntity<byte[]> response = service.ingestMetricsHttp(request.toByteArray(), requestHeaders); assertEquals(HttpStatus.TOO_MANY_REQUESTS, response.getStatusCode()); - assertNull(response.getHeaders().getFirst(HttpHeaders.RETRY_AFTER)); + assertEquals("1", response.getHeaders().getFirst(HttpHeaders.RETRY_AFTER)); OtlpIngestionAuditEvent event = auditService.recentEvents().getFirst(); assertEquals("RESOURCE_EXHAUSTED", event.statusCode()); verify(restTemplate, times(2)).exchange( diff --git a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/db/GreptimePromqlQueryExecutor.java b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/db/GreptimePromqlQueryExecutor.java index cf7c921d90..137408ded9 100644 --- a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/db/GreptimePromqlQueryExecutor.java +++ b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/db/GreptimePromqlQueryExecutor.java @@ -21,6 +21,7 @@ package org.apache.hertzbeat.warehouse.db; import java.util.List; import java.util.Map; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.hertzbeat.common.entity.dto.query.DatasourceQuery; import org.apache.hertzbeat.common.entity.dto.query.DatasourceQueryData; import org.apache.hertzbeat.warehouse.constants.WarehouseConstants; @@ -29,6 +30,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; /** @@ -43,6 +45,7 @@ public class GreptimePromqlQueryExecutor extends PromqlQueryExecutor { private static final String Datasource = "Greptime-promql"; + private final GreptimeProperties greptimeProperties; private final GreptimeQueryGuard queryGuard; public GreptimePromqlQueryExecutor(GreptimeProperties greptimeProperties, @@ -51,6 +54,7 @@ public class GreptimePromqlQueryExecutor extends PromqlQueryExecutor { GreptimeQueryGuard queryGuard) { super(restTemplate, new HttpPromqlProperties(greptimeProperties.httpEndpoint() + QUERY_PATH, greptimeProperties.username(), greptimeProperties.password())); + this.greptimeProperties = greptimeProperties; this.queryGuard = queryGuard; } @@ -69,4 +73,13 @@ public class GreptimePromqlQueryExecutor extends PromqlQueryExecutor { return Datasource; } + @Override + protected UriComponentsBuilder queryUri(String path) { + UriComponentsBuilder builder = super.queryUri(path); + if (StringUtils.isNotBlank(greptimeProperties.database())) { + builder.queryParam("db", greptimeProperties.database()); + } + return builder; + } + } diff --git a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/db/PromqlQueryExecutor.java b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/db/PromqlQueryExecutor.java index 642cec8e73..b970da724c 100644 --- a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/db/PromqlQueryExecutor.java +++ b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/db/PromqlQueryExecutor.java @@ -76,6 +76,10 @@ public abstract class PromqlQueryExecutor implements QueryExecutor { this.httpPromqlProperties = httpPromqlProperties; } + protected UriComponentsBuilder queryUri(String path) { + return UriComponentsBuilder.fromUriString(httpPromqlProperties.url() + path); + } + /** * record class for promql http connection */ @@ -118,7 +122,7 @@ public abstract class PromqlQueryExecutor implements QueryExecutor { } HttpEntity<Void> httpEntity = new HttpEntity<>(headers); - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(httpPromqlProperties.url + QUERY_PATH); + UriComponentsBuilder uriComponentsBuilder = queryUri(QUERY_PATH); uriComponentsBuilder.queryParam(HTTP_QUERY_PARAM, queryString); if (limitResult) { uriComponentsBuilder.queryParam(HTTP_LIMIT_PARAM, CommonConstants.ALERT_PREVIEW_RESULT_LIMIT); @@ -172,14 +176,14 @@ public abstract class PromqlQueryExecutor implements QueryExecutor { HttpEntity<Void> httpEntity = new HttpEntity<>(headers); URI uri; if (datasourceQuery.getTimeType().equals(RANGE)) { - uri = UriComponentsBuilder.fromUriString(httpPromqlProperties.url() + QUERY_RANGE_PATH) + uri = queryUri(QUERY_RANGE_PATH) .queryParam(HTTP_QUERY_PARAM, datasourceQuery.getExpr()) .queryParam(HTTP_START_PARAM, TimePeriodUtil.normalizeToSeconds(datasourceQuery.getStart())) .queryParam(HTTP_END_PARAM, TimePeriodUtil.normalizeToSeconds(datasourceQuery.getEnd())) .queryParam(HTTP_STEP_PARAM, datasourceQuery.getStep()) .build().toUri(); } else if (datasourceQuery.getTimeType().equals(INSTANT)) { - uri = UriComponentsBuilder.fromUriString(httpPromqlProperties.url() + QUERY_PATH) + uri = queryUri(QUERY_PATH) .queryParam(HTTP_QUERY_PARAM, datasourceQuery.getExpr()) .build().toUri(); } else { diff --git a/hertzbeat-warehouse/src/test/java/org/apache/hertzbeat/warehouse/db/GreptimePromqlQueryExecutorTest.java b/hertzbeat-warehouse/src/test/java/org/apache/hertzbeat/warehouse/db/GreptimePromqlQueryExecutorTest.java index ed555ede73..dbc3a9d5d2 100644 --- a/hertzbeat-warehouse/src/test/java/org/apache/hertzbeat/warehouse/db/GreptimePromqlQueryExecutorTest.java +++ b/hertzbeat-warehouse/src/test/java/org/apache/hertzbeat/warehouse/db/GreptimePromqlQueryExecutorTest.java @@ -72,6 +72,7 @@ class GreptimePromqlQueryExecutorTest { when(greptimeProperties.httpEndpoint()).thenReturn("http://127.0.0.1:4000"); when(greptimeProperties.username()).thenReturn("greptime"); when(greptimeProperties.password()).thenReturn("greptime"); + when(greptimeProperties.database()).thenReturn("public"); queryGuard = new GreptimeQueryGuard(2, Duration.ofSeconds(2), Duration.ofMillis(10)); greptimePromqlQueryExecutor = new GreptimePromqlQueryExecutor(greptimeProperties, restTemplate, queryGuard); } @@ -96,6 +97,7 @@ class GreptimePromqlQueryExecutorTest { when(restTemplate.exchange( argThat((URI uri) -> uri.toString().contains("start=1775034288") && uri.toString().contains("end=1775037888") + && uri.toString().contains("db=public") && uri.toString().contains("/v1/prometheus/api/v1/query_range")), eq(HttpMethod.GET), any(HttpEntity.class), --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
