Skip to content
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

Update gateway to avoid an extra gRPC call #1174

Closed
wants to merge 1 commit into from

Conversation

bogdandrutu
Copy link
Member

Same change cannot be done for opencensus because it uses an old version of the protoc-gen-frpc-gateway. @nilebox or @james-bebbington can you please regenerate protos in opencensus-proto repository?

@codecov
Copy link

codecov bot commented Jun 24, 2020

Codecov Report

Merging #1174 into master will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1174      +/-   ##
==========================================
+ Coverage   86.87%   86.91%   +0.03%     
==========================================
  Files         201      201              
  Lines       14524    14516       -8     
==========================================
- Hits        12618    12616       -2     
+ Misses       1456     1452       -4     
+ Partials      450      448       -2     
Impacted Files Coverage Δ
receiver/otlpreceiver/otlp.go 89.52% <100.00%> (+2.79%) ⬆️
service/service.go 52.75% <0.00%> (+0.68%) ⬆️

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 e193fa5...9bc2c9f. Read the comment docs.

return
// Register the grpc-gateway on the HTTP server mux
if r.traceReceiver != nil {
// Cannot return error, impossible to test
Copy link
Member

Choose a reason for hiding this comment

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

If it cannot return error then it's safer to panic in case the impossible does happen than ignoring the error

if err != nil {
  panic(err)
}

Copy link
Member Author

Choose a reason for hiding this comment

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

See the comment, I did this because of test coverage :(. And panic will not help. If you have any idea (I would avoid adding a func pointer just to test an impossible to fail function)

Copy link
Member

@nilebox nilebox Jun 24, 2020

Choose a reason for hiding this comment

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

I did this because of test coverage :(

Well, this really seems like a code smell just to make the code coverage happy :(
Go linters normally complain about the incorrect error handling like this.

Looks like the only way to exclude this block from code coverage is to extract it to a separate file and exclude from the file list for go tool cover. I agree that's not worth it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I know also that API smells a bit because returns an error that never happens. :(

Will give a shot tomorrow to have something more reasonable

return
if r.metricsReceiver != nil {
// Cannot return error, impossible to test
_ = collectormetrics.RegisterMetricsServiceHandlerServer(context.Background(), r.gatewayMux, r.metricsReceiver)
}

// Start the gRPC and HTTP/JSON (grpc-gateway) servers on the same port.
Copy link
Member

Choose a reason for hiding this comment

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

The comment about JSON is probably misleading now, given the recent change #1021 introducing support for application/x-protobuf and your comment https://github.com/open-telemetry/opentelemetry-proto/issues/129#issuecomment-630413454.

It seems that grpc-gateway still supports JSON as a default serialization format, see https://github.com/grpc-ecosystem/grpc-gateway/blob/ee3ef70b7777cde4e61e4e224cb11e92beecee6a/runtime/marshaler_registry.go#L78
To disable JSON completely, we need to register protobuf handler for * (fallback wildcard) in addition to application/x-protobuf.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the gRPC over HTTP (with the limitation of the trace/span id) from my comment. I am confused why to disable, also this PR does not change anything related to that, please make a different PR if you think there is a different problem.

Copy link
Member

Choose a reason for hiding this comment

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

I am confused why to disable

In your comment I linked above, you say that we don't want to support JSON yet, but we already do, and there is a known issue with encoding of trace and span IDs.

So to prevent people from using the JSON format until we decide to officially support it, we need to override the default marshaller in gRPC Gateway.

You're right that this is out of scope of this PR, I just made a comment to clarify the desired behaviour since you've touched the gRPC Gateway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Please file an issue to not forget about this. As you said is not in the scope so don't want to focus on other things.

Copy link
Member

Choose a reason for hiding this comment

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

@nilebox
Copy link
Member

nilebox commented Jun 24, 2020

Same change cannot be done for opencensus because it uses an old version of the protoc-gen-frpc-gateway. @nilebox or @james-bebbington can you please regenerate protos in opencensus-proto repository?

I'm afraid this won't work for OpenCensus. See comment on RegisterTraceServiceHandlerServer() function you are switching to:

// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.

/cc @james-bebbington

@bogdandrutu
Copy link
Member Author

@nilebox ack on the opencensus not being able to support this. we should still regenerate the files and update the proto deps etc.

@bogdandrutu
Copy link
Member Author

Done. in #1223

@bogdandrutu bogdandrutu deleted the otlpimpr branch June 29, 2020 22:39
hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this pull request Apr 27, 2023
Troels51 pushed a commit to Troels51/opentelemetry-collector that referenced this pull request Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants