optimizely / optimizely/java-sdk

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

Open
#564 1 comment 16 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
44
Forks
32
Avg merge
8h 39m
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating OptimizelyHttpClient and its current default HttpRequestExecutor setup, then review the surrounding HTTP client tests and documentation. Done means a custom executor can be supplied, the existing default remains the fallback, and documentation includes a usage example such as MicrometerHttpRequestExecutor.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.