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

Support gRPC for query service #1307

Merged
merged 33 commits into from
Apr 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ab4d728
Initial commit, grpc for query-service
Jan 29, 2019
650fc55
Re-evaluate fields in GRPCHandler
Jan 29, 2019
30033df
Use cmux, use stream in GetTraceResponse, regenerate *pb.go and swagg…
Feb 26, 2019
6467d44
Edit GetTrace HTTP verb
Feb 28, 2019
5a65f9f
Re-add query definitions in a new file
Mar 27, 2019
9dcfe08
Address comments, correct API endpoint for query grpc
Mar 29, 2019
114ddba
Add definitions for other query functions
Mar 31, 2019
c62ce29
Address comments, make API as close to plugin proto
Apr 2, 2019
39dc5d4
Fix api definitions
Apr 3, 2019
20f028e
Add dependency query utility
Apr 3, 2019
14645f9
Make fmt, add findtraces implementation
Apr 3, 2019
3bb4cb1
Correct rebase
Apr 3, 2019
2854624
Merge branch 'master' into query-service-grpc
Apr 4, 2019
b4f58cd
Use end_time instead of duration
Apr 4, 2019
472de89
dep ensure, fix build
Apr 4, 2019
e698953
Merge branch 'master' into query-service-grpc
Apr 4, 2019
4a85f6f
Addressed comments, fix proto tool versions
Apr 6, 2019
b03b497
Fix build
Apr 7, 2019
6ea3b82
Fix build
Apr 7, 2019
64b57da
Remove grpc-gateway code generation; use streaming
Apr 8, 2019
8a6f286
Implement streaming
Apr 8, 2019
63d5638
make fmt lint
Apr 8, 2019
8d2535d
Merge branch 'master' into query-service-grpc
yurishkuro Apr 8, 2019
289385b
dep update
Apr 8, 2019
86a771f
Start adding tests
Apr 9, 2019
86d770b
Add tests for GRPC handler
Apr 12, 2019
e7f0e0d
Fix grpc handler tests
Apr 13, 2019
612dc13
WIP fixing tests
Apr 14, 2019
9c3f1ee
Fix tests
Apr 15, 2019
c1d9abe
Fix tests
Apr 16, 2019
5a32ba0
Add test
Apr 16, 2019
b61fc18
Merge branch 'master' into query-service-grpc
Apr 16, 2019
8dfc90a
Merge branch 'master' into query-service-grpc
yurishkuro Apr 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dep ensure, fix build
Signed-off-by: Annanay <annanay.a@media.net>
  • Loading branch information
Annanay committed Apr 4, 2019
commit 472de89509df911aa9f78db570fd2167d9583dee
12 changes: 10 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,7 @@ required = [
[[constraint]]
name = "github.com/grpc-ecosystem/go-grpc-middleware"
version = "1.0.0"

[[constraint]]
name = "github.com/soheilhy/cmux"
version = "0.1.4"
38 changes: 18 additions & 20 deletions cmd/query/app/grpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ package app

import (
"context"
"time"

"github.com/opentracing/opentracing-go"
"go.uber.org/zap"
"google.golang.org/grpc"

"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc"
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
"github.com/jaegertracing/jaeger/storage/dependencystore"
"github.com/jaegertracing/jaeger/storage/spanstore"
)

Expand All @@ -46,7 +44,7 @@ func NewGRPCHandler(queryService querysvc.QueryService, logger *zap.Logger, trac
return gH
}

// GetTrace is the GRPC handler to fetch traces based on TraceID.
// GetTrace is the GRPC handler to fetch traces based on TraceId.
func (g *GRPCHandler) GetTrace(ctx context.Context, r *api_v2.GetTraceRequest) (*api_v2.GetTraceResponseStream, error) {
ID := r.TraceId

Expand Down Expand Up @@ -88,16 +86,16 @@ func (g *GRPCHandler) ArchiveTrace(ctx context.Context, r *api_v2.ArchiveTraceRe
// FindTraces is the GRPC handler to fetch traces based on TraceQueryParameters.
func (g *GRPCHandler) FindTraces(ctx context.Context, r *api_v2.FindTracesRequest) (*api_v2.FindTracesResponse, error) {
queryParams := spanstore.TraceQueryParameters{
ServiceName: r.service_name,
OperationName: r.operation_name,
Tags: r.tags,
StartTimeMin: r.start_time_min,
StartTimeMax: r.start_time_max,
DurationMin: r.duration_min,
DurationMax: r.duration_max,
NumTraces: r.num_traces,
ServiceName: r.ServiceName,
OperationName: r.OperationName,
Tags: r.Tags,
StartTimeMin: r.StartTimeMin,
StartTimeMax: r.StartTimeMax,
DurationMin: r.DurationMin,
DurationMax: r.DurationMax,
NumTraces: r.NumTraces,
}
traces, err := g.queryService.FindTraces(ctx, queryParams)
traces, err := g.queryService.FindTraces(ctx, &queryParams)
if err != nil {
g.logger.Error("Error fetching traces", zap.Error(err))
return nil, err
Expand All @@ -109,7 +107,7 @@ func (g *GRPCHandler) FindTraces(ctx context.Context, r *api_v2.FindTracesReques
spans.append(*span)
}
}
return &api_v2.SpansResponseChunk{spans: spans}, nil
return &api_v2.SpansResponseChunk{Spans: spans}, nil
}

// GetServices is the GRPC handler to fetch services.
Expand All @@ -120,30 +118,30 @@ func (g *GRPCHandler) GetServices(ctx context.Context, r *api_v2.GetServicesRequ
return nil, err
}

return &api_v2.GetServicesReponse{services: services}, nil
return &api_v2.GetServicesReponse{Services: services}, nil
}

// GetOperations is the GRPC handler to fetch operations.
func (g *GRPCHandler) GetOperations(ctx context.Context, r *api_v2.GetOperationsRequest) (*api_v2.GetOperationsReponse, error) {
service := r.service
service := r.Service
operations, err := g.queryService.GetOperations(ctx, service)
if err != nil {
g.logger.Error("Error fetching operations", zap.Error(err))
return nil, err
}

return &api_v2.GetOperationsReponse{operations: operations}, nil
return &api_v2.GetOperationsReponse{Operations: operations}, nil
}

// GetDependencies is the GRPC handler to fetch dependencies.
func (g *GRPCHandler) GetDependencies(ctx context.Context, r *api_v2.GetDependenciesRequest) (*api_v2.GetDependenciesResponse, error) {
startTime := r.start_time
endTime := r.end_time
startTime := r.StartTime
endTime := r.EndTime
dependencies, err := g.queryService.GetDependencies(startTime, endTime.Sub(startTime))
if err != nil {
g.logger.Error("Error fetching dependencies", zap.Error(err))
return nil, err
}

return &api_v2.GetDependenciesReponse{dependencies: dependencies}, nil
return &api_v2.GetDependenciesReponse{Dependencies: dependencies}, nil
}
10 changes: 3 additions & 7 deletions cmd/query/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
"os"
"strconv"

"github.com/gorilla/handlers"
"github.com/opentracing/opentracing-go"
Expand All @@ -44,6 +44,7 @@ import (
"github.com/jaegertracing/jaeger/pkg/version"
"github.com/jaegertracing/jaeger/plugin/storage"
"github.com/jaegertracing/jaeger/ports"
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
istorage "github.com/jaegertracing/jaeger/storage"
storageMetrics "github.com/jaegertracing/jaeger/storage/spanstore/metrics"
)
Expand Down Expand Up @@ -120,11 +121,6 @@ func main() {
apiHandler.RegisterRoutes(r)
app.RegisterStaticHandler(r, logger, queryOpts)

if h := mBldr.Handler(); h != nil {
logger.Info("Registering metrics handler with HTTP server", zap.String("route", mBldr.HTTPRoute))
r.Handle(mBldr.HTTPRoute, h)
}

compressHandler := handlers.CompressHandler(r)
recoveryHandler := recoveryhandler.NewRecoveryHandler(logger, true)

Expand All @@ -138,7 +134,7 @@ func main() {

grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, os.Stderr, os.Stderr))
annanay25 marked this conversation as resolved.
Show resolved Hide resolved

grpcHandler := app.NewGRPCHandler(queryService, logger, tracer)
grpcHandler := app.NewGRPCHandler(*queryService, logger, tracer)
api_v2.RegisterQueryServiceHandler(grpcServer, grpcHandler)

// Prepare cmux conn.
Expand Down