Conversation
|
My thoughts about this PR:
What do you think about it? Do you like the current solution, where we send |
avatus
left a comment
There was a problem hiding this comment.
I only had a chance to look at the types today. Will finish my review tomorrow. Super neat so far tho!
| } | ||
| } | ||
|
|
||
| message SubmitConnectEventResponse {} |
There was a problem hiding this comment.
We can reuse our EmptyResponse for this in service.proto instead of creating a new empty response here. Like this here
There was a problem hiding this comment.
We could use google.protobuf.Empty here, as long as it doesn't return linter errors (I'm not sure about this).
Historically, I haven't been consistent with it inside lib/teleterm. tshd_events_service.proto explicitly defines custom empty messages in order to keep backwards compatibility.
But I did a quick search right now and it turns out reusing google.protobuf.Empty (or something similar) is not a problem for backwards compatibility. Eric Anderson from the gRPC team says that old clients will not have a problem with this and the only thing it breaks is the generated types.
So I think going forward we could use google.protobuf.Empty, as we already do in the project. Unless the linter is now set up to require you to define a custom message for each RPC.
There was a problem hiding this comment.
The .proto is imported from gravitational/prehog, which enforces the default Buf lint rules RPC_REQUEST_STANDARD_NAME and RPC_RESPONSE_STANDARD_NAME.
| ConnectUsageEventOneOf event = 3; | ||
| } | ||
|
|
||
| message EventReportedResponse {} |
There was a problem hiding this comment.
This can also be an EmptyResponse
There was a problem hiding this comment.
Done, I think it's ok to use our common EmptyResponse instead of google.protobuf.Empty.
| // Note: this results in retrying the entire batch, which probably | ||
| // isn't ideal. | ||
| req := connect.NewRequest(event.Event) | ||
| if _, err := client.SubmitConnectEvent(ctx, req); err != nil { | ||
| errors = append(errors, err) | ||
| } |
There was a problem hiding this comment.
Do we need to address this before merging?
There was a problem hiding this comment.
No, it works this way for Teleport events too, we can fix it later.
|
|
||
| option go_package = "github.com/gravitational/teleport/lib/teleterm/v1"; | ||
|
|
||
| message ReportEventRequest { |
There was a problem hiding this comment.
I’m considering getting rid of tshd's
usage_events.protoand instead operating only prehog's events. It would require:
Performing anonymization before event leaves electron - shouldn’t be difficult, I can add a gRPC call that will run our anonymizer against the provided value
Importing prehog's
connect.prototo teleterm'sservice.proto- for some reason it doesn’t work, I get an error saying that imported proto doesn't existGenerating JS files for
connect.protoWhat do you think about it? Do you like the current solution, where we send
authClusterIdwith every event that needs to be anonymized? I'm afraid it can be confusing, as we create almost complete events in Electron and then we perform one more thing intshd:/
For me it's not confusing as much as it's just a lot of boilerplate.
From the side of the Electron app, I think the API looks pretty much alright – the Electron app should just send events and I don't think it wants to care about anonymization, especially since it's unable to anonymize anything on its own.
Could the Electron app send prehog's events to tshd through TerminalService and then tshd would anonymize the required fields before passing the events further?
If that would be possible, theoretically we could then do the minimal amount of work possible instead of having to rewrap every event.
There was a problem hiding this comment.
As for importing connect.proto to service.proto:
The protocol compiler searches for imported files in a set of directories specified on the protocol compiler command line using the -I/--proto_path flag. If no flag was given, it looks in the directory in which the compiler was invoked. In general you should set the --proto_path flag to the root of your project and use fully qualified names for all imports.
https://developers.google.com/protocol-buffers/docs/proto3#importing_definitions
AFAIK we now use buf instead of protoc, so maybe enabling that requires changes to buf's config.
There was a problem hiding this comment.
Could the Electron app send prehog's events to tshd through TerminalService and then tshd would anonymize the required fields before passing the events further?
Unfortunately, it is not possible as tshd events (the ones that need to be anonymized) have one additional field - auth_cluster_id. It is needed to create the anonymizer. The prehog events don't have this field.
EDIT: we can send event + auth cluster id
There was a problem hiding this comment.
I just pushed the changes, so we don't have tshd usage events anymore and there is much less boilerplate.
We should merge changes to the protobuf generation first, @ravicious promised to create a PR for that :)
# Conflicts: # e
f140eff to
00769c1
Compare
|
I opened #19774 which reorganizes protos into a single workspace. I made a couple of small changes compared to #19700. Once #19774 is merged, you will need to do the following in this PR:
lib/prehog/buf-teleterm.gen.yaml# buf-teleterm.gen.yaml is identical to buf.gen.yaml,
# with the exception of three addidiotal JS plugins.
version: v1
managed:
enabled: true
go_package_prefix:
default: github.com/gravitational/teleport/lib/prehog/gen
plugins:
- name: go
path: lib/prehog/bin/protoc-gen-go
out: lib/prehog/gen
opt:
- paths=source_relative
- name: connect-go
path: lib/prehog/bin/protoc-gen-connect-go
out: lib/prehog/gen
opt:
- paths=source_relative
- name: js
out: lib/prehog/gen-js
opt:
- import_style=commonjs,binary
- name: grpc
out: lib/prehog/gen-js
opt: grpc_js
path: grpc_tools_node_protoc_plugin
- name: ts
out: lib/prehog/gen-js
opt: "service=grpc-node"
grpc-teleterm/host: protos/all
$(BUF) generate --template=lib/prehog/buf-teleterm.gen.yaml lib/prehog/proto
$(BUF) generate --template=lib/teleterm/buf.gen.yaml lib/teleterm/api/proto
option go_package = "github.com/gravitational/teleport/lib/prehog/gen/prehog/v1alpha"; |
|
License check was failing on the following files: I added |
805c4ec to
c7b59a0
Compare
|
I updated the PR:
|
| string cluster_name = 1; | ||
| // anonymized | ||
| string user_name = 2; | ||
| bool is_upload = 3; |
There was a problem hiding this comment.
What's the advantage of doing it this way vs using a string with "upload"/"download"?
There was a problem hiding this comment.
I followed Edoardo suggestion, I think isUpload is easier to understand than direction.
There was a problem hiding this comment.
Let's put it below DaemonCertsDir and above DatabaseService.
There was a problem hiding this comment.
Right, I meant to put it like that.
Part of #19000
Requires #19378 to be merged first. ✅
Requires #19774 to be merged first (see #19564 (comment)) ✅
This PR adds actual events sending mechanism, it receives events from Electron,
converts them to prehog modelanonyzmies them and then sends in batches.EDIT:
In the first attempt I had separate definitions for prehog events in tshd. It was ineffective approach and resulted in quite a lot of boilerplate (maintaining two, very similar protos and then having to convert one model to another). After a discussion with Rafał, we decided to use prehog protos directly in tshd protos.