-
Notifications
You must be signed in to change notification settings - Fork 11
Rework otel crud storage #826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
FrancesTwisk
wants to merge
49
commits into
wearefrank:master
Choose a base branch
from
FrancesTwisk:rework-otel-crud-storage
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 45 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
f051562
Rework CollectorApi to accept OTLP data.
FrancesTwisk a72eb5f
Process OTel spans not ladbug spans.
FrancesTwisk c2fbf1e
Sort spans in traces and then order traces in tree.
FrancesTwisk e979479
Add caching.
FrancesTwisk db5f31c
Add class for correct DFS processing.
FrancesTwisk 20aa659
Remove sorting before expiration from cache.
FrancesTwisk e5a868a
New class for DFS creation of checkpoints.
FrancesTwisk d56ed61
Orphan span handling + refactoring.
FrancesTwisk 4bb7c67
Only actual value in infopoint.
FrancesTwisk 6c7a611
Added unit tests for TraceTree.java.
FrancesTwisk e3d7ae8
Fix.
FrancesTwisk 49836c6
Quick fix for OTel export.
FrancesTwisk 8b2767b
Update reports.
FrancesTwisk cef18da
Refactor API's and the impl.
FrancesTwisk c359e2f
Delete unnecessary classes.
FrancesTwisk 834c462
Delete unnecessary classes.
FrancesTwisk 8173af9
Dependencies.
FrancesTwisk 9685edc
Logic for updating instead of storing.
FrancesTwisk 9396cba
Copyrights.
FrancesTwisk 9436816
Fix.
FrancesTwisk 956e0dd
Fix.
FrancesTwisk 6b3325e
Fix.
FrancesTwisk dd7b9d9
Fix.
FrancesTwisk 68facee
Orphan spans handling.
FrancesTwisk 6f1e0ac
Fix.
FrancesTwisk 86d90be
Complete refactor of logic.
FrancesTwisk b22986a
Fix.
FrancesTwisk 05eb209
Add cache back in.
FrancesTwisk 89b87d3
Add cache back in.
FrancesTwisk f4b195d
Rename.
FrancesTwisk de42b3e
Process OTel spans instead of Ladybug spans.
FrancesTwisk c1fe4de
Delete old Ladybug Span class.
FrancesTwisk 4dc8667
Fix.
FrancesTwisk 1f6f9e5
Fix for export.
FrancesTwisk e075f4b
Fix.
FrancesTwisk eac5efd
Merge branch 'refs/heads/refactor-for-otel' into rework-otel-crud-sto…
FrancesTwisk 1a8d066
Fix.
FrancesTwisk 521fcec
Tests.
FrancesTwisk 533528b
Tests.
FrancesTwisk 52538e7
Fix.
FrancesTwisk f1202b9
Add info points.
FrancesTwisk 557bc09
Fix.
FrancesTwisk 0648b10
Fix.
FrancesTwisk 584721b
Fix.
FrancesTwisk af958bc
Fix.
FrancesTwisk dea73d4
Fixes.
FrancesTwisk 17b4ca0
Merge branch 'refs/heads/refactor-for-otel' into rework-otel-crud-sto…
FrancesTwisk 87162a0
Fix.
FrancesTwisk 6a86046
Simplify logic on TestTool.
FrancesTwisk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
45 changes: 0 additions & 45 deletions
45
ladybug-backend-jaxrs/src/main/java/org/wearefrank/ladybug/web/jaxrs/api/CollectorApi.java
This file was deleted.
Oops, something went wrong.
87 changes: 87 additions & 0 deletions
87
ladybug-backend-jaxrs/src/main/java/org/wearefrank/ladybug/web/jaxrs/api/TracingApi.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* | ||
| Copyright 2021-2026 WeAreFrank! | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
| package org.wearefrank.ladybug.web.jaxrs.api; | ||
|
|
||
| import com.google.protobuf.InvalidProtocolBufferException; | ||
| import com.google.protobuf.util.JsonFormat; | ||
| import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest; | ||
| import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceResponse; | ||
| import io.opentelemetry.proto.trace.v1.ResourceSpans; | ||
| import io.opentelemetry.proto.trace.v1.ScopeSpans; | ||
| import io.opentelemetry.proto.trace.v1.Span; | ||
| import jakarta.annotation.PostConstruct; | ||
| import jakarta.ws.rs.*; | ||
| import jakarta.ws.rs.core.MediaType; | ||
| import jakarta.ws.rs.Path; | ||
| import jakarta.ws.rs.core.Response; | ||
| import lombok.Setter; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.wearefrank.ladybug.SpanBuffer; | ||
| import org.wearefrank.ladybug.web.common.TracingApiImpl; | ||
| import org.wearefrank.ladybug.web.common.Constants; | ||
|
|
||
| @Path("/" + Constants.LADYBUG_API_PATH + "/traces") | ||
| public class TracingApi extends ApiBase { | ||
| private SpanBuffer spanBuffer; | ||
|
|
||
| @Autowired | ||
| private @Setter TracingApiImpl delegate; | ||
|
|
||
| @PostConstruct | ||
| public void init() { | ||
| spanBuffer = new SpanBuffer(delegate); | ||
| } | ||
|
|
||
| @POST | ||
| @Consumes({"application/x-protobuf", "application/json"}) | ||
| public Response receiveSpans(@HeaderParam("Content-Type") String contentType, byte[] data) throws InvalidProtocolBufferException { | ||
| ExportTraceServiceRequest request; | ||
|
|
||
|
FrancesTwisk marked this conversation as resolved.
Outdated
|
||
| if (contentType != null && contentType.startsWith("application/x-protobuf")) { | ||
| request = ExportTraceServiceRequest.parseFrom(data); | ||
| } else if (contentType != null && contentType.startsWith("application/json")) { | ||
| String json = new String(data); | ||
| ExportTraceServiceRequest.Builder builder = ExportTraceServiceRequest.newBuilder(); | ||
| JsonFormat.parser().merge(json, builder); | ||
| request = builder.build(); | ||
| } else { | ||
| ExportTraceServiceResponse response = ExportTraceServiceResponse.newBuilder().build(); | ||
| return Response.status(Response.Status.UNSUPPORTED_MEDIA_TYPE) | ||
| .type(MediaType.APPLICATION_JSON) | ||
| .entity(JsonFormat.printer().print(response)) | ||
| .build(); | ||
| } | ||
|
|
||
| for (ResourceSpans resourceSpans : request.getResourceSpansList()) { | ||
| for (ScopeSpans scopeSpans : resourceSpans.getScopeSpansList()) { | ||
| for (Span span : scopeSpans.getSpansList()) { | ||
| spanBuffer.addSpan(span); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| ExportTraceServiceResponse response = ExportTraceServiceResponse.newBuilder().build(); | ||
| if (contentType.startsWith("application/x-protobuf")) { | ||
| return Response.ok(response.toByteArray()) | ||
| .type("application/x-protobuf") | ||
| .build(); | ||
| } else { | ||
| return Response.ok(JsonFormat.printer().print(response)) | ||
| .type(MediaType.APPLICATION_JSON) | ||
| .build(); | ||
| } | ||
| } | ||
| } | ||
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
49 changes: 0 additions & 49 deletions
49
...ackend-springmvc/src/main/java/org/wearefrank/ladybug/web/springmvc/api/CollectorApi.java
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
...-backend-springmvc/src/main/java/org/wearefrank/ladybug/web/springmvc/api/TracingApi.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| Copyright 2025, 2026 WeAreFrank! | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
| package org.wearefrank.ladybug.web.springmvc.api; | ||
|
|
||
| import com.google.protobuf.InvalidProtocolBufferException; | ||
| import com.google.protobuf.util.JsonFormat; | ||
| import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest; | ||
| import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceResponse; | ||
| import io.opentelemetry.proto.trace.v1.ResourceSpans; | ||
| import io.opentelemetry.proto.trace.v1.ScopeSpans; | ||
| import jakarta.annotation.security.RolesAllowed; | ||
| import lombok.Setter; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.*; | ||
| import org.wearefrank.ladybug.web.common.TracingApiImpl; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/traces") | ||
| @RolesAllowed("IbisWebService") | ||
| public class TracingApi { | ||
| @Autowired | ||
| private @Setter TracingApiImpl delegate; | ||
|
|
||
| @PostMapping(consumes = {"application/x-protobuf", MediaType.APPLICATION_JSON_VALUE}) | ||
| public ResponseEntity<?> receiveSpans(@RequestHeader("Content-Type") String contentType, @RequestBody byte[] data) throws InvalidProtocolBufferException { | ||
|
FrancesTwisk marked this conversation as resolved.
Outdated
|
||
| ExportTraceServiceRequest request; | ||
|
|
||
| if (contentType != null && contentType.startsWith("application/x-protobuf")) { | ||
| request = ExportTraceServiceRequest.parseFrom(data); | ||
| } else if (contentType != null && contentType.startsWith(MediaType.APPLICATION_JSON_VALUE)) { | ||
| String json = new String(data); | ||
| ExportTraceServiceRequest.Builder builder = ExportTraceServiceRequest.newBuilder(); | ||
| JsonFormat.parser().merge(json, builder); | ||
| request = builder.build(); | ||
| } else { | ||
| ExportTraceServiceResponse response = ExportTraceServiceResponse.newBuilder().build(); | ||
| return ResponseEntity.status(HttpStatus.UNSUPPORTED_MEDIA_TYPE) | ||
| .contentType(MediaType.APPLICATION_JSON) | ||
| .body(JsonFormat.printer().print(response)); | ||
| } | ||
|
|
||
| for (ResourceSpans resourceSpans : request.getResourceSpansList()) { | ||
| for (ScopeSpans scopeSpans : resourceSpans.getScopeSpansList()) { | ||
| delegate.processSpans(scopeSpans.getSpansList()); | ||
| } | ||
| } | ||
|
|
||
| ExportTraceServiceResponse response = ExportTraceServiceResponse.newBuilder().build(); | ||
| if (contentType.startsWith("application/x-protobuf")) { | ||
| return ResponseEntity.ok() | ||
| .contentType(org.springframework.http.MediaType.parseMediaType("application/x-protobuf")) | ||
| .body(response.toByteArray()); | ||
| } else { | ||
| return ResponseEntity.ok() | ||
| .contentType(MediaType.APPLICATION_JSON) | ||
| .body(JsonFormat.printer().print(response)); | ||
| } | ||
| } | ||
| } | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to have an end-to-end test some time with Cypress. I also would like to have end-to-end tests with openTelemetryEndpoint enabled and test environments with openTelemetryEndpoint disabled. Would be nice if that could be added to this PR, but in my opinion it can also be done in a later PR.