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

feature(backend): Adding support for HTTP OTLP server #2412

Conversation

xoscar
Copy link
Collaborator

@xoscar xoscar commented Apr 19, 2023

This PR enables the tracetest server to spin off an OTLP http port that listens to incoming spans

Changes

Fixes

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

https://www.loom.com/share/e05c8a794a3c47dcb660121f23ca58ee

Copy link
Member

@mathnogueira mathnogueira left a comment

Choose a reason for hiding this comment

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

Some changes are needed, but overall, very good.

server/app/app.go Outdated Show resolved Hide resolved
server/app/app.go Outdated Show resolved Hide resolved
server/otlp/http_server.go Outdated Show resolved Hide resolved
server/otlp/http_server.go Outdated Show resolved Hide resolved
server/otlp/exporter.go Outdated Show resolved Hide resolved
@xoscar xoscar changed the title creating http otlp server feature(backend): Adding support for HTTP OTLP server Apr 21, 2023
@xoscar xoscar self-assigned this Apr 21, 2023
@xoscar xoscar added the backend label Apr 21, 2023
@xoscar xoscar marked this pull request as ready for review April 21, 2023 17:37
server/otlp/http_server.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@schoren schoren left a comment

Choose a reason for hiding this comment

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

This is great work oscar! my main concern is that the HTTP server is not following the same patterns as the main http service, which leads to a lot of code that can be replaced by libraries, and having 2 ways of doing the same thing

db model.Repository

gServer *grpc.Server
type IExporter interface {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We usually don't prefix interfaces with I in go. Also it looks like this interface is not really required. You can just reference the actual struct. And given that this is only used internally within this package, you can even unexport it (a.k.a lowercasing the first letter)

addr: addr,
db: db,
}
type Exporter struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a bit weird that an Exporter only exposes an Ingest method. I would rename either the struct or the method to look a bit more consistent

Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, you can unexport this struct, since it's only directly referenced within the package

server/app/app.go Show resolved Hide resolved
server/otlp/grpc_server.go Outdated Show resolved Hide resolved
server/otlp/http_server.go Outdated Show resolved Hide resolved
server/otlp/http_server.go Outdated Show resolved Hide resolved
server/otlp/http_server.go Outdated Show resolved Hide resolved
server/otlp/http_server.go Outdated Show resolved Hide resolved
server/otlp/http_server.go Outdated Show resolved Hide resolved
server/otlp/http_server.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@schoren schoren left a comment

Choose a reason for hiding this comment

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

This is looking really awesome. My only remaining question is about what I think is a duplicated gzip compression handler in the http server. Am I reading that wrong?


func (s *httpServer) Start() error {
r := mux.NewRouter()
r.HandleFunc("/v1/traces", s.Export).Methods("POST")
Copy link
Collaborator

Choose a reason for hiding this comment

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

niceee

server/otlp/http_server.go Show resolved Hide resolved
@xoscar xoscar merged commit d1f0b31 into main Apr 24, 2023
27 checks passed
@xoscar xoscar deleted the 2383-network-improvements-ease-networking-knowledge-needed-to-use-tracetest-1 branch April 24, 2023 16:16
schoren pushed a commit that referenced this pull request Jun 5, 2023
* creating http otlp server

* cleanup changes

* cleanup changes

* fixing example

* enabling JSON request body for the OTLP HTTP endpoint

* PR comments

* PR comments

* test

* manually installing dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Network Improvements] Ease networking knowledge needed to use Tracetest
3 participants