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

POC: Add GraphQL API for query service #3051

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "jaeger-ui"]
path = jaeger-ui
url = https://github.com/jaegertracing/jaeger-ui.git
[submodule "opentelemetry-proto"]
path = opentelemetry-proto
url = https://github.com/open-telemetry/opentelemetry-proto.git
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -564,3 +564,43 @@ certs:
.PHONY: certs-dryrun
certs-dryrun:
cd pkg/config/tlscfg/testdata && ./gen-certs.sh -d


### Dependencies
DOCKER_PROTOBUF ?= otel/build-protobuf:0.2.1
PROTOC = docker run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD} ${DOCKER_PROTOBUF} --proto_path=${PWD}
PROTO_INTERMEDIATE_DIR = pkg/.patched-proto
PROTO_INCLUDES = -I$(PROTO_INTERMEDIATE_DIR)
PROTO_GEN = $(PROTOC) $(PROTO_INCLUDES) --gogofaster_out=plugins=grpc,paths=source_relative:$(2) $(1)

.PHONY: gen-proto
gen-proto:
@echo --
@echo -- Copying to $(PROTO_INTERMEDIATE_DIR)
@echo --
mkdir -p $(PROTO_INTERMEDIATE_DIR)
cp -R opentelemetry-proto/opentelemetry/proto/* $(PROTO_INTERMEDIATE_DIR)

@echo --
@echo -- Editing proto
@echo --

@# Update package and types from opentelemetry.proto.* -> tempopb.*
@# giving final types like "tempopb.common.v1.InstrumentationLibrary" which
@# will not conflict with other usages of opentelemetry proto in downstream apps.
find $(PROTO_INTERMEDIATE_DIR) -name "*.proto" | xargs -L 1 sed -i $(SED_OPTS) 's+ opentelemetry.proto+ jaeger+g'

@# Update go_package
find $(PROTO_INTERMEDIATE_DIR) -name "*.proto" | xargs -L 1 sed -i $(SED_OPTS) 's+github.com/open-telemetry/opentelemetry-proto/gen/go+github.com/jaegertracing/jaeger/pkg/otel+g'

@# Update import paths
find $(PROTO_INTERMEDIATE_DIR) -name "*.proto" | xargs -L 1 sed -i $(SED_OPTS) 's+import "opentelemetry/proto/+import "+g'

@echo --
@echo -- Gen proto --
@echo --
$(call PROTO_GEN,$(PROTO_INTERMEDIATE_DIR)/common/v1/common.proto,./pkg/otel/)
$(call PROTO_GEN,$(PROTO_INTERMEDIATE_DIR)/resource/v1/resource.proto,./pkg/otel/)
$(call PROTO_GEN,$(PROTO_INTERMEDIATE_DIR)/trace/v1/trace.proto,./pkg/otel/)

rm -rf $(PROTO_INTERMEDIATE_DIR)
67 changes: 67 additions & 0 deletions cmd/query/app/gqlgen/gqlgen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Where are all the schema files located? globs are supported eg src/**/*.graphqls
schema:
- graph/*.graphqls

# Where should the generated server code go?
exec:
filename: graph/generated/generated.go
package: generated

# Where should any generated models go?
model:
filename: graph/model/models_gen.go
package: model

# Where should the resolver implementations go?
resolver:
layout: follow-schema
dir: graph
package: graph

# Optional: turn on use `gqlgen:"fieldName"` tags in your models
# struct_tag: json

# Optional: turn on to use []Thing instead of []*Thing
# omit_slice_element_pointers: false

# Optional: set to speed up generation time by not performing a final validation pass.
# skip_validation: true

# gqlgen will search for any type names in the schema in these go packages
# if they match it will use them, otherwise it will generate them.
autobind:
- "github.com/jaegertracing/jaeger/cmd/query/app/gqlgen/graph/model"

# This section declares type mapping between the GraphQL and go type systems
#
# The first line in each type will be used as defaults for resolver arguments and
# modelgen, the others will be allowed when binding to fields. Configure them to
# your liking
models:
Span:
model:
- github.com/jaegertracing/jaeger/pkg/otel/trace/v1.Span
ResourceSpans:
model:
- github.com/jaegertracing/jaeger/pkg/otel/trace/v1.ResourceSpans
InstrumentatationLibrarySpans:
model:
- github.com/jaegertracing/jaeger/pkg/otel/trace/v1.InstrumentationLibrarySpans
Resource:
model:
- github.com/jaegertracing/jaeger/pkg/otel/resource/v1.Resource
InstrumentationLibrary:
model:
- github.com/jaegertracing/jaeger/pkg/otel/common/v1.InstrumentationLibrary

# TODO remove following if not used
ID:
model:
- github.com/99designs/gqlgen/graphql.ID
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.IntID
Int:
model:
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32
Loading