Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

feat: Api for log event#87

Merged
findingrish merged 19 commits intomainfrom
log-api
Apr 22, 2021
Merged

feat: Api for log event#87
findingrish merged 19 commits intomainfrom
log-api

Conversation

@findingrish
Copy link
Copy Markdown

@findingrish findingrish commented Apr 15, 2021

Adds LogEvents api

hypertrace/hypertrace#224

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2021

Codecov Report

Merging #87 (3c049f4) into main (27c0e47) will decrease coverage by 0.06%.
The diff coverage is 75.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main      #87      +/-   ##
============================================
- Coverage     77.08%   77.02%   -0.07%     
- Complexity     1082     1094      +12     
============================================
  Files           105      106       +1     
  Lines          4884     4980      +96     
  Branches        416      424       +8     
============================================
+ Hits           3765     3836      +71     
- Misses          936      955      +19     
- Partials        183      189       +6     
Flag Coverage Δ Complexity Δ
unit 77.02% <75.00%> (-0.07%) 1094.00 <12.00> (+12.00) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
...hypertrace/gateway/service/GatewayServiceImpl.java 18.45% <5.55%> (-1.55%) 3.00 <0.00> (ø)
...ace/gateway/service/logevent/LogEventsService.java 89.61% <89.61%> (ø) 11.00 <11.00> (?)
...way/service/common/util/AttributeMetadataUtil.java 83.33% <100.00%> (+0.47%) 8.00 <1.00> (+1.00)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 27c0e47...3c049f4. Read the comment docs.

@github-actions

This comment has been minimized.

@findingrish findingrish marked this pull request as ready for review April 15, 2021 18:41
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.


message LogEventResponse {
repeated LogEvent logEvents = 1;
int32 total = 2;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is this needs to be fetched separately, so we've kind of retrofitted an "includeTotal" flag on other APIs. Since this is a new one, it may be worth looking at those and if it makes sense, splitting fetching total into its own API.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does total needs to be fetched separately? and if that is added, should the existing api also return total?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a perf optimization. In many contexts (for example, showing the log events in the sequence diagram), we don't need the total - but under the hood, the gateway service had to make a separate query (which I believe was sequential, although that could be fixed) to fetch it and it slowed down the queries that didn't need it. By keeping it separate, we can fetch it in parallel if needed and leave it be if it's not requested. @skjindal93 may have more context.

Copy link
Copy Markdown
Contributor

@skjindal93 skjindal93 Apr 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does total needs to be fetched separately? and if that is added, should the existing api also return total?

I think there are 2 questions here

  1. Why does total needs to be fetched separately?
    If the request has support for limit and offset, which usually gets pushed down to the data store, you cannot count number of log events in the response and call it as total (since the count of log events would just be bounded by the limit)
    A separate request needs to be made to get the total value, by just passing the filters sent in the request (And, that's why I personally prefer to have a separate total request API entirely)

  2. What if you don't need total in the response?
    That's the perf optimization which @aaron-steinfeld was mentioning about. Since, in order to fetch total, you need to make a separate request, but if the consumer does not need it, we should skip fetching the total entirely (by either having a boolean flag like this https://github.com/hypertrace/gateway-service/blob/main/gateway-service-api/src/main/proto/org/hypertrace/gateway/service/v1/entities.proto#L50 or a separate total request API)

Copy link
Copy Markdown
Author

@findingrish findingrish Apr 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, since I didn't add support for limit and order, calculating total was trivial. But, yeah with limit and order it needs another query.
For this change, I will remove total from the api.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.


message LogEventsRequest {
// todo change this to nano
sfixed64 start_time_nanos = 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm - to keep this in nanos or millis? My gut is millis so this becomes more of an implementation detail (since the unit on the attribute itself will be handled generically), but I'm on the fence.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I can do that. Currently I am just converting timestamp to nanos in gql request builder.

public static Filter addTimeAndSpaceFiltersAndConvertToQueryFilter(
long startTimeMillis,
long endTimeMillis,
long startTime,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this util cares about units, but just to be aware, others do (anything using datetimeconvert). We'll probably want to lookup the timestamp unit when we get to that point.

@findingrish findingrish requested a review from a team April 21, 2021 16:52
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

repeated double double_array = 13;
repeated bool boolean_array = 14;
map<string, string> string_map = 15;
string timestamp_unit = 16;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this in the value? The requester has access to the metadata anyway so should have this info (which saves us from repeating the unit in every response value - we already do this for all other units)

Copy link
Copy Markdown
Author

@findingrish findingrish Apr 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that can also be done. But I will then need a different converter for Timestamp in gql, here hypertrace/hypertrace-core-graphql#56 (comment) since the convert method only has access to the Value object.

  • we already do this for all other units)

where do we do this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My response from offline:

So GQL will need changes to support timestamps as instants in attributes - right now it only works that way for top level APIs. The value converter needs to be changed to a biconverter I believe to take in the attribute metadata. Or we may need both the Converter and Biconverter flavors if there’s some places we call it where we don’t have that metadata at hand (probably just implement both methods and have an internal implementation, for example). The 400 error is due to the serialization side. Attributes right now use an UnknownScalar type, which needs to add support for instants - right now it treats them as plain objects.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As to where we do this, I actually confused units and types. The units being joined in happens in the UI today - the types being joined in we do in GQL explorer results.

}

message LogEventResponse {
repeated LogEvent log_events = 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no total? since, we have offset and limit now, I believe it will have pagination. That will need a total in the response

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, that would need a parallel query I guess

Copy link
Copy Markdown
Contributor

@skjindal93 skjindal93 Apr 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That works too. Definitely, we can defer it as a separate PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 that's what I was thinking - separate api entirely since we have the luxury of doing it here.

@github-actions

This comment has been minimized.

.
Co-authored-by: Aaron Steinfeld <45047841+aaron-steinfeld@users.noreply.github.com>
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@findingrish findingrish merged commit 9e7f586 into main Apr 22, 2021
@findingrish findingrish deleted the log-api branch April 22, 2021 16:58
@github-actions
Copy link
Copy Markdown

Unit Test Results

  55 files  +1    55 suites  +1   6s ⏱️ -1s
315 tests +1  315 ✔️ +1  0 💤 ±0  0 ❌ ±0 

Results for commit 9e7f586. ± Comparison against base commit 27c0e47.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants