Break api into 2 parts#36
Open
edeandrea wants to merge 3 commits into
Open
Conversation
Author
|
Hi @Steffen911 Please see my initial implementation of the separation. Its a lot and I'm happy to iterate on it. The biggest thing I tried to achieve is to keep as much build-time auto-generation as possible. Fern itself is not very customizeable, so I started from an OpenAPI document, which can be generated from fern. There is very little code actually checked into version control - most of the power comes from the fact it is generated at build time. Happy to answer any questions you may have. You might think that 491 file changes is a lot, but more than half of that is simply moving what was there (generated by fern) into a subdirectory so it can be preserved. |
…guration options, and testing setup with Testcontainers Add integration tests for all major APIs, including async and legacy modes Refactor configuration handling and improve ingestion-related tests Add async tests for all major APIs Enable Bean Validation support in `langfuse-java-api`. Define module-info files for `langfuse-java-api` and `langfuse-java-client`. Tests Adding request/response logging Adding testcontainers Adding additional apis Initial separation
…ames for improved clarity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Separates the Langfuse Java SDK into a multi-module Maven project with generated API interfaces, a reference HTTP client, and Testcontainers support for integration testing.
It is mostly dependency-free. It does not use/require OkHttp, instead using Java's built-in
HttpClient. It requires either Jackson 2 or 3, but does not force a user into one over the other, nor does it force which version to use.The API has been completely decoupled to the underlying http transport, meaning the api can be re-used with other http transports.
New modules
build time and never checked into version control.
java.net.http.HttpClientwith dual Jackson 2/3 support, request/response logging with sensitive header masking, and automatic HTTP/1.1 fallback for plain HTTP connections.LangfuseContainerthat orchestrates a full Langfuse environment (PostgreSQL, ClickHouse, Redis, MinIO, web server, worker) for testing via Testcontainers.Key design decisions
LangfuseApi.builder()usesServiceLoaderto find the client implementation, allowing framework-specific implementations (Spring, Quarkus) without depending on the reference client.useSingleRequestParameter), eliminating long parameter lists (e.g.scoresGetManyhad 21 parameters).protected; all creation goes throughbuilder().@JsonInclude(NON_EMPTY)at the class level so empty optional containers are omitted from serialized JSON.@NotNull,@Size, etc. annotations generated from OpenAPI schema constraints.com.fasterxml.jacksonandtools.jacksonannotations. The client auto-detects which Jackson version is on the classpath at runtime.CompletionStage-based async variant.Testcontainers
Startables.deepStartgetAllLogs()returns aMap<String, String>of all container logs for diagnosticsdocker-compose.ymlOptional<Duration>for ingestion queue delay and ClickHouse write interval settingsTest coverage
tests (sync + async) across 19 API areas, all running against a real Langfuse environment via Testcontainers:
Health, Ingestion, Traces, Prompts, Prompt Versions, Scores, Score Configs, Datasets, Dataset Items, Dataset Run Items, Models, Projects, Observations, Sessions, Comments, Annotation Queues, plus LegacyScoreV1 and LegacyObservationsV1 used as helpers.
Other changes
module-info.javafor API and client moduleslogRequests(),logResponses(),prettyPrint()builder optionsApiClientfor plainhttpURLs (avoids HTTP/2 upgrade issues)com.langfuse.testcontainers.service) on all Docker containersCloses #31