diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..5b00fd6b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: weekly + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: weekly diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..17123c88 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,76 @@ +FROM otel/build-protobuf:0.17.0 as go-builder + +RUN --mount=type=bind,source=.,target=/opencensus-proto,rw \ + protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --go_out=plugins=grpc:/opencensus-proto/gen-go opencensus/proto/agent/common/v1/common.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --go_out=plugins=grpc:/opencensus-proto/gen-go opencensus/proto/resource/v1/resource.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --go_out=plugins=grpc:/opencensus-proto/gen-go opencensus/proto/metrics/v1/metrics.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --go_out=plugins=grpc:/opencensus-proto/gen-go opencensus/proto/stats/v1/stats.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --go_out=plugins=grpc:/opencensus-proto/gen-go opencensus/proto/trace/v1/trace.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --go_out=plugins=grpc:/opencensus-proto/gen-go opencensus/proto/trace/v1/trace_config.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --go_out=plugins=grpc:/opencensus-proto/gen-go opencensus/proto/agent/common/v1/common.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --go_out=plugins=grpc:/opencensus-proto/gen-go opencensus/proto/agent/metrics/v1/metrics_service.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --go_out=plugins=grpc:/opencensus-proto/gen-go opencensus/proto/agent/trace/v1/trace_service.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --grpc-gateway_out=logtostderr=true,grpc_api_configuration=/opencensus-proto/src/opencensus/proto/agent/trace/v1/trace_service_http.yaml:/opencensus-proto/gen-go opencensus/proto/agent/trace/v1/trace_service.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --grpc-gateway_out=logtostderr=true,grpc_api_configuration=/opencensus-proto/src/opencensus/proto/agent/metrics/v1/metrics_service_http.yaml:/opencensus-proto/gen-go opencensus/proto/agent/metrics/v1/metrics_service.proto \ + && /bin/mv /opencensus-proto/gen-go/github.com/census-instrumentation/opencensus-proto/gen-go gen-go + + +FROM otel/build-protobuf:0.17.0 as python-builder + +RUN --mount=type=bind,source=.,target=/opencensus-proto,rw \ + /bin/mkdir /gen-python \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --python_out=/gen-python opencensus/proto/agent/common/v1/common.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --python_out=/gen-python opencensus/proto/resource/v1/resource.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --python_out=/gen-python opencensus/proto/metrics/v1/metrics.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --python_out=/gen-python opencensus/proto/stats/v1/stats.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --python_out=/gen-python opencensus/proto/trace/v1/trace.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --python_out=/gen-python opencensus/proto/trace/v1/trace_config.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --python_out=/gen-python opencensus/proto/agent/common/v1/common.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --python_out=/gen-python --grpc-python_out=/gen-python opencensus/proto/agent/metrics/v1/metrics_service.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --python_out=/gen-python --grpc-python_out=/gen-python opencensus/proto/agent/trace/v1/trace_service.proto + + +FROM otel/build-protobuf:0.17.0 as ruby-builder + +RUN --mount=type=bind,source=.,target=/opencensus-proto,rw \ + /bin/mkdir /gen-ruby \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --ruby_out=/gen-ruby opencensus/proto/agent/common/v1/common.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --ruby_out=/gen-ruby opencensus/proto/resource/v1/resource.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --ruby_out=/gen-ruby opencensus/proto/metrics/v1/metrics.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --ruby_out=/gen-ruby opencensus/proto/stats/v1/stats.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --ruby_out=/gen-ruby opencensus/proto/trace/v1/trace.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --ruby_out=/gen-ruby opencensus/proto/trace/v1/trace_config.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --ruby_out=/gen-ruby opencensus/proto/agent/common/v1/common.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --ruby_out=/gen-ruby --grpc-ruby_out=/gen-ruby opencensus/proto/agent/metrics/v1/metrics_service.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --ruby_out=/gen-ruby --grpc-ruby_out=/gen-ruby opencensus/proto/agent/trace/v1/trace_service.proto + + +FROM otel/build-protobuf:0.17.0 as openapi-builder + +RUN --mount=type=bind,source=.,target=/opencensus-proto,rw \ + /bin/mkdir /gen-openapi \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --openapiv2_out=logtostderr=true,grpc_api_configuration=/opencensus-proto/src/opencensus/proto/agent/trace/v1/trace_service_http.yaml:/gen-openapi opencensus/proto/agent/trace/v1/trace_service.proto \ + && protoc-wrapper -I/usr/include --proto_path=/opencensus-proto/src --openapiv2_out=logtostderr=true,grpc_api_configuration=/opencensus-proto/src/opencensus/proto/agent/metrics/v1/metrics_service_http.yaml:/gen-openapi opencensus/proto/agent/metrics/v1/metrics_service.proto + + +FROM scratch as go +COPY --from=go-builder /gen-go /gen-go + + +FROM scratch as python +COPY --from=python-builder /gen-python /gen-python + + +FROM scratch as ruby +COPY --from=ruby-builder /gen-ruby /gen-ruby + + +FROM scratch as openapi +COPY --from=openapi-builder /gen-openapi /gen-openapi + + +FROM scratch as all +COPY --from=go-builder /gen-go /gen-go +COPY --from=python-builder /gen-python /gen-python +COPY --from=ruby-builder /gen-ruby /gen-ruby +COPY --from=openapi-builder /gen-openapi /gen-openapi diff --git a/Makefile b/Makefile index bbcb2537..130440c7 100644 --- a/Makefile +++ b/Makefile @@ -1,59 +1,32 @@ -OTEL_DOCKER_PROTOBUF ?= otel/build-protobuf:0.11.0 -BUF_DOCKER ?= bufbuild/buf:1.7.0 - -PROTOC := docker run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD} ${OTEL_DOCKER_PROTOBUF} --proto_path=${PWD}/src - - -PROTO_GEN_GO_DIR ?= gen-go -PROTO_GEN_PYTHON_DIR ?= gen-python -PROTO_GEN_RUBY_DIR ?= gen-ruby -PROTO_GEN_OPENAPI_DIR ?= gen-openapi +DEFAULT_GOAL := all # Generate gRPC/Protobuf implementation for Go. .PHONY: gen-go gen-go: - $(PROTOC) --go_out=plugins=grpc:./$(PROTO_GEN_GO_DIR) opencensus/proto/agent/common/v1/common.proto - $(PROTOC) --go_out=plugins=grpc:./$(PROTO_GEN_GO_DIR) opencensus/proto/resource/v1/resource.proto - $(PROTOC) --go_out=plugins=grpc:./$(PROTO_GEN_GO_DIR) opencensus/proto/metrics/v1/metrics.proto - $(PROTOC) --go_out=plugins=grpc:./$(PROTO_GEN_GO_DIR) opencensus/proto/stats/v1/stats.proto - $(PROTOC) --go_out=plugins=grpc:./$(PROTO_GEN_GO_DIR) opencensus/proto/trace/v1/trace.proto - $(PROTOC) --go_out=plugins=grpc:./$(PROTO_GEN_GO_DIR) opencensus/proto/trace/v1/trace_config.proto - $(PROTOC) --go_out=plugins=grpc:./$(PROTO_GEN_GO_DIR) opencensus/proto/agent/common/v1/common.proto - $(PROTOC) --go_out=plugins=grpc:./$(PROTO_GEN_GO_DIR) opencensus/proto/agent/metrics/v1/metrics_service.proto - $(PROTOC) --go_out=plugins=grpc:./$(PROTO_GEN_GO_DIR) opencensus/proto/agent/trace/v1/trace_service.proto - $(PROTOC) --grpc-gateway_out=logtostderr=true,grpc_api_configuration=src/opencensus/proto/agent/trace/v1/trace_service_http.yaml:./$(PROTO_GEN_GO_DIR) opencensus/proto/agent/trace/v1/trace_service.proto - $(PROTOC) --grpc-gateway_out=logtostderr=true,grpc_api_configuration=src/opencensus/proto/agent/metrics/v1/metrics_service_http.yaml:./$(PROTO_GEN_GO_DIR) opencensus/proto/agent/metrics/v1/metrics_service.proto - mv $(PROTO_GEN_GO_DIR)/github.com/census-instrumentation/opencensus-proto/gen-go/* $(PROTO_GEN_GO_DIR) - rm -fr $(PROTO_GEN_GO_DIR)/github.com + @rm -rf gen-go/* + docker build -t opencensus-proto-gen . --output . --target go -# Generate gRPC/Protobuf implementation for Go. +# Generate gRPC/Protobuf implementation for Python. .PHONY: gen-python gen-python: - $(PROTOC) --python_out=./$(PROTO_GEN_PYTHON_DIR) opencensus/proto/agent/common/v1/common.proto - $(PROTOC) --python_out=./$(PROTO_GEN_PYTHON_DIR) opencensus/proto/resource/v1/resource.proto - $(PROTOC) --python_out=./$(PROTO_GEN_PYTHON_DIR) opencensus/proto/metrics/v1/metrics.proto - $(PROTOC) --python_out=./$(PROTO_GEN_PYTHON_DIR) opencensus/proto/stats/v1/stats.proto - $(PROTOC) --python_out=./$(PROTO_GEN_PYTHON_DIR) opencensus/proto/trace/v1/trace.proto - $(PROTOC) --python_out=./$(PROTO_GEN_PYTHON_DIR) opencensus/proto/trace/v1/trace_config.proto - $(PROTOC) --python_out=./$(PROTO_GEN_PYTHON_DIR) opencensus/proto/agent/common/v1/common.proto - $(PROTOC) --python_out=./$(PROTO_GEN_PYTHON_DIR) --grpc-python_out=./$(PROTO_GEN_PYTHON_DIR) opencensus/proto/agent/metrics/v1/metrics_service.proto - $(PROTOC) --python_out=./$(PROTO_GEN_PYTHON_DIR) --grpc-python_out=./$(PROTO_GEN_PYTHON_DIR) opencensus/proto/agent/trace/v1/trace_service.proto + docker build -t opencensus-proto-gen . --output . --target python -# Generate gRPC/Protobuf implementation for Go. +# Generate gRPC/Protobuf implementation for Ruby. .PHONY: gen-ruby gen-ruby: - $(PROTOC) --ruby_out=./$(PROTO_GEN_RUBY_DIR) opencensus/proto/agent/common/v1/common.proto - $(PROTOC) --ruby_out=./$(PROTO_GEN_RUBY_DIR) opencensus/proto/resource/v1/resource.proto - $(PROTOC) --ruby_out=./$(PROTO_GEN_RUBY_DIR) opencensus/proto/metrics/v1/metrics.proto - $(PROTOC) --ruby_out=./$(PROTO_GEN_RUBY_DIR) opencensus/proto/stats/v1/stats.proto - $(PROTOC) --ruby_out=./$(PROTO_GEN_RUBY_DIR) opencensus/proto/trace/v1/trace.proto - $(PROTOC) --ruby_out=./$(PROTO_GEN_RUBY_DIR) opencensus/proto/trace/v1/trace_config.proto - $(PROTOC) --ruby_out=./$(PROTO_GEN_RUBY_DIR) opencensus/proto/agent/common/v1/common.proto - $(PROTOC) --ruby_out=./$(PROTO_GEN_RUBY_DIR) --grpc-ruby_out=./$(PROTO_GEN_RUBY_DIR) opencensus/proto/agent/metrics/v1/metrics_service.proto - $(PROTOC) --ruby_out=./$(PROTO_GEN_RUBY_DIR) --grpc-ruby_out=./$(PROTO_GEN_RUBY_DIR) opencensus/proto/agent/trace/v1/trace_service.proto + @rm -rf gen-ruby/* + docker build -t opencensus-proto-gen . --output . --target ruby # Generate OpenApi (Swagger) documentation file for grpc-gateway endpoints. .PHONY: gen-openapi gen-openapi: - $(PROTOC) --openapiv2_out=logtostderr=true,grpc_api_configuration=src/opencensus/proto/agent/trace/v1/trace_service_http.yaml:$(PROTO_GEN_OPENAPI_DIR) opencensus/proto/agent/trace/v1/trace_service.proto - $(PROTOC) --openapiv2_out=logtostderr=true,grpc_api_configuration=src/opencensus/proto/agent/metrics/v1/metrics_service_http.yaml:$(PROTO_GEN_OPENAPI_DIR) opencensus/proto/agent/metrics/v1/metrics_service.proto \ No newline at end of file + @rm -rf gen-openapi/* + docker build -t opencensus-proto-gen . --output . --target openapi + +# Generate all gRPC/Protobuf implementations. +.PHONY: all +all: + @rm -rf gen-go/* + @rm -rf gen-ruby/* + @rm -rf gen-openapi/* + docker build -t opencensus-proto-gen . --output . --target all diff --git a/RELEASING.md b/RELEASING.md index 67f036d6..c24ab07b 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -10,15 +10,10 @@ Other systems may also work, but we haven't verified them. ## Release Go files -To generate the Go files from protos, you'll need to install protoc, protoc-gen-go and grpc-gateway plugins first. -Follow the instructions [here](http://google.github.io/proto-lens/installing-protoc.html), -[here](https://github.com/golang/protobuf#installation) and [here](https://github.com/grpc-ecosystem/grpc-gateway#installation). - -Then run the following commands to re-generate the gen-go files: +Run the following commands to re-generate the gen-go files: ```bash $ git checkout -b update-gen-go -$ rm -rf gen-go/* $ make gen-go $ git add -A $ git commit -m "Update gen-go files." @@ -28,11 +23,10 @@ Go through PR review and merge the changes to GitHub. ## Release OpenAPI files -Then run the following commands to re-generate the gen-openapi files: +Run the following commands to re-generate the gen-openapi files: ```bash $ git checkout -b update-gen-ruby -$ rm -rf gen-openapi/* $ make gen-openapi $ git add -A $ git commit -m "Update gen-openapi files." @@ -42,11 +36,10 @@ Go through PR review and merge the changes to GitHub. ## Release Ruby files -Then run the following commands to re-generate the gen-ruby files: +Run the following commands to re-generate the gen-ruby files: ```bash $ git checkout -b update-gen-ruby -$ rm -rf gen-ruby/* $ make gen-ruby $ git add -A $ git commit -m "Update gen-ruby files." @@ -56,10 +49,10 @@ Go through PR review and merge the changes to GitHub. ## Release Python files -Then run the following commands to re-generate the gen-python files: +Run the following commands to re-generate the gen-python files: ```bash -$ git checkout -b update-gen-python # Assume you're under opencensus-proto/ +$ git checkout -b update-gen-python $ make gen-python $ git add -A $ git commit -m "Update gen-python files." diff --git a/go.mod b/go.mod index 18d98337..74912cf2 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,15 @@ module github.com/census-instrumentation/opencensus-proto go 1.18 require ( - github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 - google.golang.org/grpc v1.49.0 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 + google.golang.org/grpc v1.53.0 google.golang.org/protobuf v1.28.1 ) require ( github.com/golang/protobuf v1.5.2 // indirect - golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect - golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d // indirect - golang.org/x/text v0.3.7 // indirect - google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect + google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 // indirect ) diff --git a/go.sum b/go.sum index 17bbf19f..635326cd 100644 --- a/go.sum +++ b/go.sum @@ -3,20 +3,20 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 h1:lLT7ZLSzGLI08vc9cpd+tYmNWjdKDqyr/2L+f6U12Fk= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= -golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e h1:TsQ7F31D3bUCLeqPT0u+yjp1guoArKaNKmCr22PYgTQ= -golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d h1:Zu/JngovGLVi6t2J3nmAf3AoTDwuzw85YZ3b9o4yU7s= -golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 h1:gDLXvp5S9izjldquuoAhDzccbskOL6tDC5jMSyx3zxE= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2/go.mod h1:7pdNwVWBBHGiCxa9lAszqCJMbfTISJ7oMftp8+UGV08= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc h1:Nf+EdcTLHR8qDNN/KfkQL0u0ssxt9OhbaWCl5C0ucEI= -google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 h1:znp6mq/drrY+6khTAlJUDNFFcDGV2ENLYKpMq8SyCds= +google.golang.org/genproto v0.0.0-20230223222841-637eb2293923/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= +google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= +google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=