Otel metrics source http service#6604
Otel metrics source http service#6604KarstenSchnitter merged 6 commits intoopensearch-project:mainfrom
Conversation
b702577 to
7083df5
Compare
|
Note: I added the E2E Test for the metrics source to the It seemed a bit of an overkill to me to create a new module. Especially, since the already present tests for logs really just cover the happy path of the process. I'd suggest to rename the More specialized/complex use cases can still be put into separate modules. |
7083df5 to
48d9981
Compare
bed11cb to
117d402
Compare
Integrates an HTTP (non-gRPC) service into the OTel metrics source plugin, mirroring the existing pattern from otel_trace_source and otel_logs_source. Both gRPC and HTTP services now run on the same Armeria server. Key changes: - Add ArmeriaHttpService for handling HTTP metric export requests - Add HttpExceptionHandler for HTTP-specific error handling - Support compression, authentication, throttling, and health checks for HTTP - Add configurable http_path option - Refactor OTelMetricsSource to directly configure the server - Remove ConvertConfiguration (inlined into source) - Split monolithic test into focused test classes (gRPC, HTTP, RetryInfo) - Add E2E tests for HTTP, gRPC, protobuf, and unframed requests Signed-off-by: Tomas Longo <tlongo@sternad.de> Signed-off-by: Kai Sternad <kai@sternad.de>
d7121b8 to
01df9df
Compare
Signed-off-by: Kai Sternad <kai@sternad.de>
1. createServer() — configureHttpService() is now guarded with if (getHttpPath() != null), preventing the NPE 2. HTTP health check — moved from configureHttpService() into createServer(), so it registers when either httpPath or enableUnframedRequests is set (matching the OTelLogsSource pattern) 3. configureHttpService() — removed the duplicate health check registration Signed-off-by: Kai Sternad <kai@sternad.de>
Signed-off-by: Kai Sternad <kai@sternad.de>
KarstenSchnitter
left a comment
There was a problem hiding this comment.
Thanks for providing this PR. This already looks pretty good. I found some minor issues with that.
| public static final int DEFAULT_REQUEST_TIMEOUT_MS = 10000; | ||
| public static final int DEFAULT_PORT = 21891; | ||
| public static final int DEFAULT_THREAD_COUNT = 200; | ||
| public static final int DEFAULT_MAX_CONNECTION_COUNT = 500; | ||
| public static final boolean DEFAULT_SSL = true; | ||
| public static final boolean DEFAULT_ENABLED_UNFRAMED_REQUESTS = false; | ||
| public static final boolean DEFAULT_HEALTH_CHECK = false; | ||
| public static final boolean DEFAULT_PROTO_REFLECTION_SERVICE = false; | ||
| public static final boolean DEFAULT_USE_ACM_CERT_FOR_SSL = false; | ||
| public static final int DEFAULT_ACM_CERT_ISSUE_TIME_OUT_MILLIS = 120000; |
There was a problem hiding this comment.
Why do these constants need to be public now? Can't they keep the scope they had before?
| @JsonProperty(RETRY_INFO) | ||
| private RetryInfoConfig retryInfo; | ||
|
|
||
| @JsonProperty("http_path") |
There was a problem hiding this comment.
"http_path" should probably be extracted to a constant similar to all other property names.
| ScheduledThreadPoolExecutor executor = configureServer(serverBuilder); | ||
|
|
||
| configureGrpcService(serverBuilder, buffer); | ||
| if (oTelMetricsSourceConfig.getHttpPath() != null) { |
There was a problem hiding this comment.
Do I understand correctly, that the gRPC endpoint is always created but the HTTP endpoint relies on the definition of a path? Or is there alway a default path making this check pass always? I am wondering on the different checks for logs, metrics and traces to configure the HTTP endpoint:
- metrics: see above
- logs: always
- traces: if unframed requests is not true
There was a problem hiding this comment.
Yes, we should unify http-service creation.
If I'm not mistaken, we haven't had a discussion for the trace-source to flesh out the exact mechanic how we want to treat the creation of the two services:
- should both be mandatory?
- should they be optional, in which case we would need to make sure that at least one service is configured?
- [other approaches]
Any preferences?
There was a problem hiding this comment.
Let's create an issue in this project to discuss this. The behaviour should be aligned. This will be necessary for adding the support to the OTelSource later on.
There was a problem hiding this comment.
@KarstenSchnitter Regarding the inconsistency across the three sources: metrics and logs have been aligned with the latest commit. Both gate the HTTP endpoint on httpPath != null:
if (!oTelTraceSourceConfig.enableUnframedRequests()) HTTP is created by default, when unframed_requests is enabled, the gRPC service itself accepts plain HTTP/JSON requests, making a separate HTTP endpoint redundant.
The HTTP health check condition is also aligned now between metrics and logs: both use (enableUnframedRequests || httpPath != null) && healthCheck.
| /** | ||
| * Returns the used thread pool. Can be used by other parts of the server configuration | ||
| */ | ||
| private @NonNull ScheduledThreadPoolExecutor configureServer(ServerBuilder serverBuilder) { |
There was a problem hiding this comment.
This is strange naming considering the return value.
There was a problem hiding this comment.
Yes, wasn't happy either.
I pulled out the creation of the task executor.
| .exceptionHandler(createGrpcExceptionHandler(oTelMetricsSourceConfig)); | ||
| final OTelMetricsGrpcService oTelmetricsGrpcService = new OTelMetricsGrpcService( | ||
| (int) (oTelMetricsSourceConfig.getRequestTimeoutInMillis() * 0.8), | ||
| oTelMetricsSourceConfig.getOutputFormat() == OTelOutputFormat.OPENSEARCH ? new OTelProtoOpensearchCodec.OTelProtoDecoder() : new OTelProtoStandardCodec.OTelProtoDecoder(), |
There was a problem hiding this comment.
| oTelMetricsSourceConfig.getOutputFormat() == OTelOutputFormat.OPENSEARCH ? new OTelProtoOpensearchCodec.OTelProtoDecoder() : new OTelProtoStandardCodec.OTelProtoDecoder(), | |
| createOtelProtoDecoder(), |
| } | ||
|
|
||
| @Test | ||
| void start_with_Health_configured_includes_HealthCheck_service() throws IOException { |
There was a problem hiding this comment.
please use CamelCase naming adjust the other tests as well.
|
|
||
| @ParameterizedTest | ||
| @MethodSource("getPathParams") | ||
| void httpRequest_writesToBuffer_returnsSuccessfulResponse(String givenPath, String resolvedRequestPath) throws Exception { |
There was a problem hiding this comment.
please use CamelCase naming. Please adjust the other tests as well.
Signed-off-by: Tomas Longo <tlongo@sternad.de>
bd48863 to
a818f7a
Compare
KarstenSchnitter
left a comment
There was a problem hiding this comment.
Thanks for applying the latest changes. There are still two open comments, can you address those as well? Please also comment on the failing tests: Is this caused by this PR or by other factors?
| ScheduledThreadPoolExecutor executor = configureServer(serverBuilder); | ||
|
|
||
| configureGrpcService(serverBuilder, buffer); | ||
| if (oTelMetricsSourceConfig.getHttpPath() != null) { |
There was a problem hiding this comment.
Let's create an issue in this project to discuss this. The behaviour should be aligned. This will be necessary for adding the support to the OTelSource later on.
| #### Update the version of DataPrepperVersion | ||
|
|
||
| If you have just created a release branch, you should also create a PR on the `main` branch to bump the version in `DataPrepperVersion`. | ||
|
|
||
| Steps: | ||
| 1. Modify the `DataPrepperVersion` class to update `CURRENT_VERSION` to the next version. | ||
| 2. Create a PR targeting `main` | ||
|
|
||
| Note: This step can be automated through [#4877](https://github.com/opensearch-project/data-prepper/issues/4877). | ||
|
|
There was a problem hiding this comment.
This still looks like an accidental change. Are you sure this should be contained in this PR?
There was a problem hiding this comment.
I'm confused. The file doesn't appear in the changeset.
I thought the accidental change was the removal of the section.
| .exceptionHandler(createGrpcExceptionHandler(oTelMetricsSourceConfig)); | ||
| final OTelMetricsGrpcService oTelmetricsGrpcService = new OTelMetricsGrpcService( | ||
| (int) (oTelMetricsSourceConfig.getRequestTimeoutInMillis() * 0.8), | ||
| oTelMetricsSourceConfig.getOutputFormat() == OTelOutputFormat.OPENSEARCH ? new OTelProtoOpensearchCodec.OTelProtoDecoder() : new OTelProtoStandardCodec.OTelProtoDecoder(), |
Signed-off-by: Kai Sternad <kai@sternad.de>
KarstenSchnitter
left a comment
There was a problem hiding this comment.
This looks good to me. @dlvenable or @kkondaka do you have anything against this?
bb61dbe
into
opensearch-project:main
This reverts commit bb61dbe.
Signed-off-by: Taylor Gray <tylgry@amazon.com> This reverts commit bb61dbe.

Description
Introduce HTTP/protobuf and HTTP/JSON support for OTel Metrics source.
Adds endpoint to receive OTLP data over HTTP. Aligns with similar support
for OTelTraceSource.
Issues Resolved
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.