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

Implement OTLP/HTTP X-Protobuf Receiver #982

Closed
wants to merge 3 commits into from

Conversation

kirbyquerby
Copy link
Member

@kirbyquerby kirbyquerby commented May 17, 2020

Description: This change adds application/x-protobuf support to the existing
grpc-gateway mux in the OTLP receiver.

Protocol spec: https://github.com/open-telemetry/oteps/blob/master/text/0099-otlp-http.md

What currently works:

  • The receiver will correctly process HTTP requests with the
    Content-Type application/x-protobuf.
  • The receiver will respond with Content-Type application/x-protobuf.
  • The receiver will respond with status code HTTP 200 OK on success.
  • The receiver can handle gzip-encoded requests (Content-Encoding
    gzip) (http.Server natively supports gzip decoding).

What doesn't work yet:

  • The receiver will not gzip-encode responses to requests with
    Accept-Encoding: gzip.

Link to tracking Issue: #881

Testing: A test was added to verify that the receiver accepts application/x-protobuf requests.

Documentation:

Copy link
Member

@james-bebbington james-bebbington left a comment

Choose a reason for hiding this comment

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

Overall, LGTM

},
},
},
}
Copy link
Member

Choose a reason for hiding this comment

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

Since this test largely replicates the test above that uses application/json (which is good since they're just testing different protocols), I'd refactor this so that both tests get the data from the same function/variable. And in general, maybe the tests could be refactored to share some other code as well.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this refactoring something I can do in this PR or should it be done in a separate PR?

Copy link
Member

Choose a reason for hiding this comment

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

Separate PR is good.

},
},
},
}
Copy link
Member

Choose a reason for hiding this comment

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

receiver/otlpreceiver/otlphttp.go Outdated Show resolved Hide resolved
@@ -80,7 +80,9 @@ func New(
r := &Receiver{
ln: ln,
corsOrigins: []string{}, // Disable CORS by default.
gatewayMux: gatewayruntime.NewServeMux(),
gatewayMux: gatewayruntime.NewServeMux(
gatewayruntime.WithMarshalerOption("application/x-protobuf", &xProtobufMarshaler{}),
Copy link
Member

Choose a reason for hiding this comment

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

Should this be controlled by a config?

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 think it should be fine being on by default since it's just adding support for a new content-type to the existing HTTP server. When gzipped responses are added, though, maybe it could be useful to have the option to enable or disable them.

Copy link
Member

Choose a reason for hiding this comment

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

I think it is fine to enable all transports in the receiver. I do not see why we would want to reject OTLP/HTTP incoming requests. However if we see that need for it we can add a config option in the future.

Copy link
Member

Choose a reason for hiding this comment

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

I feel that defaults are fine but no option to disable, which may not be a problem now.

@bogdandrutu
Copy link
Member

Can you please rebase?

This change adds application/x-protobuf support to the existing
grpc-gateway mux in the OTLP receiver.

See: https://github.com/open-telemetry/oteps/blob/master/text/0099-otlp-http.md

What currently works:
* The receiver will correctly process HTTP requests with the
  Content-Type application/x-protobuf.
* The receiver will respond with Content-Type application/x-protobuf.
* The receiver will respond with status code HTTP 200 OK on success.
What doesn't work yet:
* The receiver cannot handle gzip-encoded requests (Content-Encoding
  gzip).
* The receiver will not gzip-encode responses to requests with
  Accept-Encoding: gzip.


Updates open-telemetry#881
runtime.ProtoMarshaller is now embedded in xProtoBufMarshaler so that only ContentType() needs to be implemented.
@kirbyquerby
Copy link
Member Author

Can you please rebase?

Done.

kirbyquerby added a commit to kirbyquerby/opentelemetry-collector that referenced this pull request May 23, 2020
This change decreases the amount of duplicate code in the OTLP receiver tests.

Context: open-telemetry#982 (comment)
kirbyquerby added a commit to kirbyquerby/opentelemetry-collector that referenced this pull request May 23, 2020
This change decreases the amount of duplicate code in the OTLP receiver tests.

Context: open-telemetry#982 (comment)
kirbyquerby added a commit to kirbyquerby/opentelemetry-collector that referenced this pull request May 23, 2020
This change decreases the amount of duplicate code in the OTLP receiver tests.

Context: open-telemetry#982 (comment)
kirbyquerby added a commit to kirbyquerby/opentelemetry-collector that referenced this pull request May 23, 2020
This change decreases the amount of duplicate code in the OTLP receiver tests.

Context: open-telemetry#982 (comment)
kirbyquerby added a commit to kirbyquerby/opentelemetry-collector that referenced this pull request May 23, 2020
This change decreases the amount of duplicate code in the OTLP receiver tests.

Context: open-telemetry#982 (comment)
@bogdandrutu bogdandrutu reopened this May 26, 2020
@tigrannajaryan
Copy link
Member

@kirbyquerby can you amend the commit and push to force CircleCI build?

@tigrannajaryan
Copy link
Member

@kirbyquerby I am not sure why but CircleCI does not want to build this PR. Can you close the PR and create a new one?

@kirbyquerby
Copy link
Member Author

It looks like CircleCI wasn't triggering because i had set it up on my own fork:
https://support.circleci.com/hc/en-us/articles/360008097173-Why-aren-t-pull-requests-triggering-jobs-on-my-organization-

MovieStoreGuy pushed a commit to atlassian-forks/opentelemetry-collector that referenced this pull request Nov 11, 2021
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
swiatekm pushed a commit to swiatekm/opentelemetry-collector that referenced this pull request Oct 9, 2024
* Set webhook port correctly

* whoops
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.

4 participants