optimizely / optimizely/java-sdk

[ENHANCEMENT] Add Support for Custom `HttpRequestExecutor` in `OptimizelyHttpClient`

未关闭
#564 1 条评论 16 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Java
星标
44
派生
32
平均合并
8 小时 39 分钟
30 天内合并 PR
1

描述

Description

Currently, the OptimizelyHttpClient in the Optimizely Java SDK uses a default HttpRequestExecutor provided by Apache HttpComponents library for handling HTTP requests. However, there is no extension point to allow developers to supply a custom HttpRequestExecutor.

Adding the ability to inject a custom HttpRequestExecutor would provide greater flexibility, enabling users to replace or extend the default behavior. For example, the inclusion of tools such as the MicrometerHttpRequestExecutor allows the collection of execution metrics, including latency, errors, and throughput.

While upgrading to Apache HttpComponents 5 would modernize the library and bring advanced features, adding this extension point would still be valuable. It ensures that developers can adapt or enhance the HTTP client behavior for monitoring and observability, regardless of which version of Apache HttpComponents is used.

Benefits
  • Increased Observability: Developers can use custom executors, like the MicrometerHttpRequestExecutor, to capture valuable execution metrics such as request duration, HTTP status distribution, and network errors. These metrics can be sent to monitoring systems like Prometheus or Datadog.
  • Enhanced Extensibility: A configurable HttpRequestExecutor provides an extension point for more advanced use cases, empowering developers to customize the HTTP behavior without requiring changes to the base SDK.
  • Future-Proof Design: Introducing this flexibility ensures that users have control over HTTP execution behavior, making it easier to adopt library upgrades in the future, including potential transitions to Apache HttpComponents 5.
Detail
  1. Add a configurable property to OptimizelyHttpClient to allow injection of a custom HttpRequestExecutor.
  2. Provide a fallback to the existing default HttpRequestExecutor if no custom request executor is supplied.
  3. Update documentation to highlight this new extensibility feature and provide examples of using custom executors such as MicrometerHttpRequestExecutor.
Examples

Not right now

Risks/Downsides

Not right now

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先定位 OptimizelyHttpClient 及其当前的 HttpRequestExecutor 默认设置,然后查看相关的 HTTP 客户端测试和文档。当可以提供自定义 executor、现有默认 executor 仍作为 fallback,并且文档包含类似 MicrometerHttpRequestExecutor 的使用示例时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
backend, observability
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。