Skip to content

Commit

Permalink
TraceQL Parser (grafana#1436)
Browse files Browse the repository at this point in the history
* parse ast

Signed-off-by: Joe Elliott <[email protected]>

* stringer

Signed-off-by: Joe Elliott <[email protected]>

* Union and sibling

Signed-off-by: Joe Elliott <[email protected]>

* disallow static/static comparisons

Signed-off-by: Joe Elliott <[email protected]>

* added status type

Signed-off-by: Joe Elliott <[email protected]>

* attributes

Signed-off-by: Joe Elliott <[email protected]>

* test cleanup

Signed-off-by: Joe Elliott <[email protected]>

* made names slightly less bad

Signed-off-by: Joe Elliott <[email protected]>

* stringer tests

Signed-off-by: Joe Elliott <[email protected]>

* removed empty {}

Signed-off-by: Joe Elliott <[email protected]>

* started validate. stringer

Signed-off-by: Joe Elliott <[email protected]>

* Unwound recursive relationships in grammar

Signed-off-by: Joe Elliott <[email protected]>

* Added TestAll

Signed-off-by: Joe Elliott <[email protected]>

* Validate

Signed-off-by: Joe Elliott <[email protected]>

* Fix attribute parsing

Signed-off-by: Joe Elliott <[email protected]>

* cleaned up image definitions

Signed-off-by: Joe Elliott <[email protected]>

* vendor check

Signed-off-by: Joe Elliott <[email protected]>

* go.mod

Signed-off-by: Joe Elliott <[email protected]>

* enums

Signed-off-by: Joe Elliott <[email protected]>

* removed stringer maps

Signed-off-by: Joe Elliott <[email protected]>

* nolint

Signed-off-by: Joe Elliott <[email protected]>

* Improved tests and cleanup

Signed-off-by: Joe Elliott <[email protected]>

* Added static expressions in scalar filters

Signed-off-by: Joe Elliott <[email protected]>

* adjusted examples

Signed-off-by: Joe Elliott <[email protected]>

* regenerated expr.y

Signed-off-by: Joe Elliott <[email protected]>

* require aggregates and grouping expressions to reference the span

Signed-off-by: Joe Elliott <[email protected]>

* added todo

Signed-off-by: Joe Elliott <[email protected]>
  • Loading branch information
joe-elliott authored Jun 13, 2022
1 parent cd21a9a commit 91673c8
Show file tree
Hide file tree
Showing 20 changed files with 4,478 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
.DS_Store
/tempodb/encoding/benchmark_block
/cmd/tempo-serverless/vendor/
/pkg/traceql/y.output
39 changes: 29 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ GOARCH ?= $(shell go env GOARCH)
GOPATH := $(shell go env GOPATH)
GORELEASER := $(GOPATH)/bin/goreleaser

# Build Images
DOCKER_PROTOBUF_IMAGE ?= otel/build-protobuf:0.2.1
FLATBUFFERS_IMAGE ?= neomantra/flatbuffers
LOKI_BUILD_IMAGE ?= grafana/loki-build-image:0.15.0
DOCS_IMAGE ?= grafana/docs-base:latest

# More exclusions can be added similar with: -not -path './testbed/*'
ALL_SRC := $(shell find . -name '*.go' \
-not -path './vendor*/*' \
Expand Down Expand Up @@ -128,9 +134,10 @@ ifndef COMPONENT
$(error COMPONENT variable was not defined)
endif

### 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}
# #########
# Gen Proto
# #########
PROTOC = docker run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD} ${DOCKER_PROTOBUF_IMAGE} --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)
Expand Down Expand Up @@ -181,15 +188,29 @@ gen-proto:

rm -rf $(PROTO_INTERMEDIATE_DIR)

# ##############
# Gen Flatbuffer
# ##############
.PHONY: gen-flat
gen-flat:
# -o /pkg generates into same folder as tempo.fbs for simpler imports.
docker run --rm -v${PWD}:/opt/src neomantra/flatbuffers flatc --go -o /opt/src/pkg /opt/src/pkg/tempofb/tempo.fbs
docker run --rm -v${PWD}:/opt/src ${FLATBUFFERS_IMAGE} flatc --go -o /opt/src/pkg /opt/src/pkg/tempofb/tempo.fbs

# ##############
# Gen Traceql
# ##############
.PHONY: gen-traceql
gen-traceql:
docker run --rm -v${PWD}:/src/loki ${LOKI_BUILD_IMAGE} gen-traceql-local

### Check vendored files and generated proto
.PHONY: gen-traceql-local
gen-traceql-local:
goyacc -o pkg/traceql/expr.y.go pkg/traceql/expr.y && rm y.output

### Check vendored and generated files are up to date
.PHONY: vendor-check
vendor-check: gen-proto gen-flat update-mod
git diff --exit-code -- **/go.sum **/go.mod vendor/ pkg/tempopb/ pkg/tempofb/
vendor-check: gen-proto gen-flat update-mod gen-traceql
git diff --exit-code -- **/go.sum **/go.mod vendor/ pkg/tempopb/ pkg/tempofb/ pkg/traceql/

### Tidy dependencies for tempo and tempo-serverless modules
.PHONY: update-mod
Expand All @@ -213,8 +234,6 @@ release-snapshot: $(GORELEASER)
$(GORELEASER) build --skip-validate --rm-dist --snapshot

### Docs
DOCS_IMAGE = grafana/docs-base:latest

.PHONY: docs
docs:
docker pull ${DOCS_IMAGE}
Expand Down Expand Up @@ -257,7 +276,7 @@ drone:
# piggyback on Loki's build image, this image contains a newer version of drone-cli than is
# released currently (1.4.0). The newer version of drone-clie keeps drone.yml human-readable.
# This will run 'make drone-jsonnet' from within the container
docker run --rm -v $(shell pwd):/src/loki grafana/loki-build-image:0.15.0 drone-jsonnet
docker run --rm -v $(shell pwd):/src/loki ${LOKI_BUILD_IMAGE} drone-jsonnet

drone lint .drone/drone.yml
@make drone-signature
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/cespare/xxhash v1.1.0
github.com/cespare/xxhash/v2 v2.1.2
github.com/cristalhq/hedgedhttp v0.7.0
github.com/davecgh/go-spew v1.1.1
github.com/drone/envsubst v1.0.3
github.com/dustin/go-humanize v1.0.0
github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb
Expand Down Expand Up @@ -116,7 +117,6 @@ require (
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dennwc/varint v1.0.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
Expand Down
Loading

0 comments on commit 91673c8

Please sign in to comment.