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

[WIP] [query] use otel's implementation for constructing http and grpc servers #6055

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

mahadzaryab1
Copy link
Contributor

Which problem is this PR solving?

Description of the changes

How was this change tested?

Checklist

Copy link

codecov bot commented Oct 5, 2024

Codecov Report

Attention: Patch coverage is 80.24691% with 16 lines in your changes missing coverage. Please review.

Project coverage is 96.81%. Comparing base (f411b3c) to head (0a7d837).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
cmd/query/app/server.go 79.74% 13 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6055      +/-   ##
==========================================
- Coverage   96.91%   96.81%   -0.11%     
==========================================
  Files         349      349              
  Lines       16587    16648      +61     
==========================================
+ Hits        16076    16117      +41     
- Misses        328      343      +15     
- Partials      183      188       +5     
Flag Coverage Δ
badger_v1 7.99% <ø> (-0.01%) ⬇️
badger_v2 1.82% <ø> (-0.01%) ⬇️
cassandra-4.x-v1 15.79% <ø> (+0.01%) ⬆️
cassandra-4.x-v2 ?
cassandra-5.x-v1 15.79% <ø> (+0.01%) ⬆️
cassandra-5.x-v2 1.74% <ø> (-0.01%) ⬇️
elasticsearch-6.x-v1 18.68% <ø> (-0.03%) ⬇️
elasticsearch-7.x-v1 18.74% <ø> (-0.04%) ⬇️
elasticsearch-8.x-v1 18.95% <ø> (-0.03%) ⬇️
elasticsearch-8.x-v2 1.80% <ø> (-0.02%) ⬇️
grpc_v1 9.37% <ø> (-0.02%) ⬇️
grpc_v2 ?
kafka-v1 9.69% <ø> (-0.02%) ⬇️
kafka-v2 1.82% <ø> (-0.01%) ⬇️
memory_v2 1.82% <ø> (-0.01%) ⬇️
opensearch-1.x-v1 18.80% <ø> (-0.02%) ⬇️
opensearch-2.x-v1 18.79% <ø> (-0.04%) ⬇️
opensearch-2.x-v2 1.82% <ø> (+<0.01%) ⬆️
tailsampling-processor 0.46% <ø> (-0.01%) ⬇️
unittests 95.60% <80.24%> (-0.11%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mahadzaryab1
Copy link
Contributor Author

@yurishkuro do you have any thoughts on how to handle the sharing of ports problem?

@yurishkuro
Copy link
Member

We should follow our deprecation policy of two versions notice. It means for v2 we can go to new method and distinct port. For v1 we need to print a warning if the same port is used telling the user this will not be supported in the future (call it out in release notes). Then two releases later we switch default to not allow same port but still support it via a special flag (deprecated from start), and then two releases later remove that too.

This also means we should have another release tag "deprecated" and change release notes script to have a separate section for it.

@mahadzaryab1
Copy link
Contributor Author

We should follow our deprecation policy of two versions notice. It means for v2 we can go to new method and distinct port. For v1 we need to print a warning if the same port is used telling the user this will not be supported in the future (call it out in release notes). Then two releases later we switch default to not allow same port but still support it via a special flag (deprecated from start), and then two releases later remove that too.

This also means we should have another release tag "deprecated" and change release notes script to have a separate section for it.

Got it! Let me make some changes.

@mahadzaryab1
Copy link
Contributor Author

@yurishkuro do you have any thoughts so far? it looks pretty messy but i'm not sure if there's a cleaner way to do this.

metricsQuerySvc querysvc.MetricsQueryService,
options *QueryOptions,
tm *tenancy.Manager,
telset telemetery.Setting,
allowSamePort bool,
Copy link
Member

Choose a reason for hiding this comment

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

rather add it to QueryOptions

func NewServer(querySvc *querysvc.QueryService,
func NewServer(
ctx context.Context,
host component.Host,
Copy link
Member

Choose a reason for hiding this comment

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

maybe we can wrap it into telemetery.Setting

return nil, err
}
} else {
telset.Logger.Error("using the same port for gRPC and HTTP is deprecated; please use dedicated host ports intead")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
telset.Logger.Error("using the same port for gRPC and HTTP is deprecated; please use dedicated host ports intead")
telset.Logger.Warning("using the same port for gRPC and HTTP is deprecated; please use dedicated ports instead")

var grpcServer *grpc.Server
var httpServer *httpServer
if separatePorts {
grpcServer, err = createGRPCServer(ctx, host, querySvc, metricsQuerySvc, options, tm, telset)
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 this is unnecessary bifurcation at this point. I would instead spit this function into two, create and registerEndpoints(server). Pass legacy=separatePorts argument to create

func createGRPCServer(legacy bool, ... {
  if !legacy {
    return otel.Create...
  }
  // legacy code
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yurishkuro how would we register the endpoints after creating the server?

Copy link
Member

Choose a reason for hiding this comment

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

Same way they are currently registered in the create() function. My point is that we're only changing how the server is created, not how endpoints are mounted into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yurishkuro otel's ToServer takes in a handler, which has the routes registered to it. So how would we register the routes after creating the server using ToServer?

Copy link
Member

@yurishkuro yurishkuro Oct 6, 2024

Choose a reason for hiding this comment

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

ok, so for grpc the order is (1) create server, (2) register handlers. For HTTP it's (1) create the root handler with all sub-handlers registered, and (2) create server. In both cases we can factor out the handlers creation, which are not different between v1/v2.

Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
@mahadzaryab1
Copy link
Contributor Author

@yurishkuro do you know why the all in one test is failing by any chance?

Signed-off-by: Mahad Zaryab <[email protected]>
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.

[query] Switch to use OTEL's http/grpc servers
2 participants