diff --git a/WORKSPACE b/WORKSPACE index b10f47cf7026d..ef120bc53d4ff 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,23 +1,17 @@ workspace(name = "envoy") +load("//bazel:api_binding.bzl", "envoy_api_binding") + +envoy_api_binding() + load("//bazel:api_repositories.bzl", "envoy_api_dependencies") envoy_api_dependencies() -load("//bazel:repositories.bzl", "GO_VERSION", "envoy_dependencies") +load("//bazel:repositories.bzl", "envoy_dependencies") envoy_dependencies() -load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies") - -rules_foreign_cc_dependencies() - -load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") - -go_rules_dependencies() - -go_register_toolchains(go_version = GO_VERSION) - -load("@envoy//bazel/toolchains:rbe_toolchains_config.bzl", "rbe_toolchains_config") +load("//bazel:dependency_imports.bzl", "envoy_dependency_imports") -rbe_toolchains_config() +envoy_dependency_imports() diff --git a/api/bazel/api_build_system.bzl b/api/bazel/api_build_system.bzl index 192fdfaa82212..9eb8e434a5319 100644 --- a/api/bazel/api_build_system.bzl +++ b/api/bazel/api_build_system.bzl @@ -1,4 +1,4 @@ -load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") +load("@com_google_protobuf//:protobuf.bzl", _py_proto_library = "py_proto_library") load("@com_envoyproxy_protoc_gen_validate//bazel:pgv_proto_library.bzl", "pgv_cc_proto_library") load("@io_bazel_rules_go//proto:def.bzl", "go_grpc_library", "go_proto_library") load("@io_bazel_rules_go//go:def.bzl", "go_test") @@ -24,21 +24,42 @@ def _LibrarySuffix(library_name, suffix): # https://github.com/bazelbuild/bazel/issues/3935 and/or # https://github.com/bazelbuild/bazel/issues/2626 are resolved. def api_py_proto_library(name, srcs = [], deps = [], has_services = 0): - py_proto_library( + _py_proto_library( name = _Suffix(name, _PY_SUFFIX), srcs = srcs, default_runtime = "@com_google_protobuf//:protobuf_python", protoc = "@com_google_protobuf//:protoc", deps = [_LibrarySuffix(d, _PY_SUFFIX) for d in deps] + [ "@com_envoyproxy_protoc_gen_validate//validate:validate_py", - "@googleapis//:api_httpbody_protos_py", - "@googleapis//:http_api_protos_py", - "@googleapis//:rpc_status_protos_py", + "@com_google_googleapis//google/rpc:status_py_proto", + "@com_google_googleapis//google/api:annotations_py_proto", + "@com_google_googleapis//google/api:http_py_proto", + "@com_google_googleapis//google/api:httpbody_py_proto", "@com_github_gogo_protobuf//:gogo_proto_py", ], visibility = ["//visibility:public"], ) +# This defines googleapis py_proto_library. The repository does not provide its definition and requires +# overriding it in the consuming project (see https://github.com/grpc/grpc/issues/19255 for more details). +def py_proto_library(name, deps = []): + srcs = [dep[:-6] + ".proto" if dep.endswith("_proto") else dep for dep in deps] + proto_deps = [] + + # py_proto_library in googleapis specifies *_proto rules in dependencies. + # By rewriting *_proto to *.proto above, the dependencies in *_proto rules are not preserved. + # As a workaround, manually specify the proto dependencies for the imported python rules. + if name == "annotations_py_proto": + proto_deps = proto_deps + [":http_py_proto"] + _py_proto_library( + name = name, + srcs = srcs, + default_runtime = "@com_google_protobuf//:protobuf_python", + protoc = "@com_google_protobuf//:protoc", + deps = proto_deps + ["@com_google_protobuf//:protobuf_python"], + visibility = ["//visibility:public"], + ) + def api_go_proto_library(name, proto, deps = []): go_proto_library( name = _Suffix(name, _GO_PROTO_SUFFIX), @@ -53,7 +74,7 @@ def api_go_proto_library(name, proto, deps = []): "@io_bazel_rules_go//proto/wkt:timestamp_go_proto", "@io_bazel_rules_go//proto/wkt:wrappers_go_proto", "@com_envoyproxy_protoc_gen_validate//validate:go_default_library", - "@googleapis//:rpc_status_go_proto", + "@com_google_googleapis//google/rpc:status_go_proto", ], ) @@ -70,7 +91,7 @@ def api_go_grpc_library(name, proto, deps = []): "@io_bazel_rules_go//proto/wkt:struct_go_proto", "@io_bazel_rules_go//proto/wkt:wrappers_go_proto", "@com_envoyproxy_protoc_gen_validate//validate:go_default_library", - "@googleapis//:http_api_go_proto", + "@com_google_googleapis//google/api:annotations_go_proto", ], ) @@ -109,8 +130,9 @@ def api_proto_library( "@com_google_protobuf//:struct_proto", "@com_google_protobuf//:timestamp_proto", "@com_google_protobuf//:wrappers_proto", - "@googleapis//:http_api_protos_proto", - "@googleapis//:rpc_status_protos_lib", + "@com_google_googleapis//google/api:http_proto", + "@com_google_googleapis//google/api:annotations_proto", + "@com_google_googleapis//google/rpc:status_proto", "@com_github_gogo_protobuf//:gogo_proto", "@com_envoyproxy_protoc_gen_validate//validate:validate_proto", ], @@ -121,8 +143,9 @@ def api_proto_library( linkstatic = linkstatic, cc_deps = [_LibrarySuffix(d, _CC_SUFFIX) for d in deps] + external_cc_proto_deps + [ "@com_github_gogo_protobuf//:gogo_proto_cc", - "@googleapis//:http_api_protos", - "@googleapis//:rpc_status_protos", + "@com_google_googleapis//google/api:http_cc_proto", + "@com_google_googleapis//google/api:annotations_cc_proto", + "@com_google_googleapis//google/rpc:status_cc_proto", ], deps = [":" + name], visibility = ["//visibility:public"], diff --git a/api/bazel/repositories.bzl b/api/bazel/repositories.bzl index 67d38c4fb57a8..3185d0f74072f 100644 --- a/api/bazel/repositories.bzl +++ b/api/bazel/repositories.bzl @@ -12,9 +12,8 @@ def api_dependencies(): locations = REPOSITORY_LOCATIONS, ) envoy_http_archive( - name = "googleapis", + name = "com_google_googleapis", locations = REPOSITORY_LOCATIONS, - build_file_content = GOOGLEAPIS_BUILD_CONTENT, ) envoy_http_archive( name = "com_github_gogo_protobuf", @@ -36,179 +35,6 @@ def api_dependencies(): build_file_content = KAFKASOURCE_BUILD_CONTENT, ) -GOOGLEAPIS_BUILD_CONTENT = """ -load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") -load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") -load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library") - -filegroup( - name = "api_httpbody_protos_src", - srcs = [ - "google/api/httpbody.proto", - ], - visibility = ["//visibility:public"], -) - -proto_library( - name = "api_httpbody_protos_proto", - srcs = [":api_httpbody_protos_src"], - deps = ["@com_google_protobuf//:descriptor_proto"], - visibility = ["//visibility:public"], -) - -cc_proto_library( - name = "api_httpbody_protos", - deps = [":api_httpbody_protos_proto"], - visibility = ["//visibility:public"], -) - -py_proto_library( - name = "api_httpbody_protos_py", - srcs = [ - "google/api/httpbody.proto", - ], - include = ".", - default_runtime = "@com_google_protobuf//:protobuf_python", - protoc = "@com_google_protobuf//:protoc", - visibility = ["//visibility:public"], - deps = ["@com_google_protobuf//:protobuf_python"], -) - -go_proto_library( - name = "api_httpbody_go_proto", - importpath = "google.golang.org/genproto/googleapis/api/httpbody", - proto = ":api_httpbody_protos_proto", - visibility = ["//visibility:public"], - deps = [ - ":descriptor_go_proto", - ], -) - -filegroup( - name = "http_api_protos_src", - srcs = [ - "google/api/annotations.proto", - "google/api/http.proto", - ], - visibility = ["//visibility:public"], -) - -go_proto_library( - name = "descriptor_go_proto", - importpath = "github.com/golang/protobuf/protoc-gen-go/descriptor", - proto = "@com_google_protobuf//:descriptor_proto", - visibility = ["//visibility:public"], -) - -proto_library( - name = "http_api_protos_proto", - srcs = [":http_api_protos_src"], - deps = ["@com_google_protobuf//:descriptor_proto"], - visibility = ["//visibility:public"], -) - -cc_proto_library( - name = "http_api_protos", - deps = [":http_api_protos_proto"], - visibility = ["//visibility:public"], -) - -py_proto_library( - name = "http_api_protos_py", - srcs = [ - "google/api/annotations.proto", - "google/api/http.proto", - ], - include = ".", - default_runtime = "@com_google_protobuf//:protobuf_python", - protoc = "@com_google_protobuf//:protoc", - visibility = ["//visibility:public"], - deps = ["@com_google_protobuf//:protobuf_python"], -) - -go_proto_library( - name = "http_api_go_proto", - importpath = "google.golang.org/genproto/googleapis/api/annotations", - proto = ":http_api_protos_proto", - visibility = ["//visibility:public"], - deps = [ - ":descriptor_go_proto", - ], -) - -filegroup( - name = "rpc_status_protos_src", - srcs = [ - "google/rpc/status.proto", - ], - visibility = ["//visibility:public"], -) - -proto_library( - name = "rpc_status_protos_lib", - srcs = [":rpc_status_protos_src"], - deps = ["@com_google_protobuf//:any_proto"], - visibility = ["//visibility:public"], -) - -cc_proto_library( - name = "rpc_status_protos", - deps = [":rpc_status_protos_lib"], - visibility = ["//visibility:public"], -) - -go_proto_library( - name = "rpc_status_go_proto", - importpath = "google.golang.org/genproto/googleapis/rpc/status", - proto = ":rpc_status_protos_lib", - visibility = ["//visibility:public"], - deps = [ - "@io_bazel_rules_go//proto/wkt:any_go_proto", - ], -) - -py_proto_library( - name = "rpc_status_protos_py", - srcs = [ - "google/rpc/status.proto", - ], - include = ".", - default_runtime = "@com_google_protobuf//:protobuf_python", - protoc = "@com_google_protobuf//:protoc", - visibility = ["//visibility:public"], - deps = ["@com_google_protobuf//:protobuf_python"], -) - -proto_library( - name = "tracing_proto_proto", - srcs = [ - "google/devtools/cloudtrace/v2/trace.proto", - "google/devtools/cloudtrace/v2/tracing.proto", - ], - deps = [ - ":http_api_protos_proto", - ":rpc_status_protos_lib", - "@com_google_protobuf//:timestamp_proto", - "@com_google_protobuf//:wrappers_proto", - "@com_google_protobuf//:empty_proto", - ], -) - -cc_proto_library( - name = "tracing_proto_cc", - deps = [":tracing_proto_proto"], -) - -cc_grpc_library( - name = "tracing_proto", - srcs = [":tracing_proto_proto"], - deps = [":tracing_proto_cc"], - grpc_only = True, - visibility = ["@io_opencensus_cpp//opencensus:__subpackages__"], -) - -""" - GOGOPROTO_BUILD_CONTENT = """ load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library", "py_proto_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") diff --git a/api/bazel/repository_locations.bzl b/api/bazel/repository_locations.bzl index e2bd881f03888..dd661b7d7886c 100644 --- a/api/bazel/repository_locations.bzl +++ b/api/bazel/repository_locations.bzl @@ -10,8 +10,8 @@ OPENCENSUS_PROTO_SHA256 = "a4e87a1da21d1b3a16674332c3ee6e2689d52f3532e2ff8cb4a62 PGV_GIT_SHA = "dd90514d96e35023ed20201f349542b0bc64461d" PGV_SHA256 = "f7d67677fbec5b0f561f6ee6788223fb535d3864b53a28b6678e319f5d1f4f25" -GOOGLEAPIS_GIT_SHA = "d642131a6e6582fc226caf9893cb7fe7885b3411" # May 23, 2018 -GOOGLEAPIS_SHA = "16f5b2e8bf1e747a32f9a62e211f8f33c94645492e9bbd72458061d9a9de1f63" +GOOGLEAPIS_GIT_SHA = "be480e391cc88a75cf2a81960ef79c80d5012068" # Jul 24, 2019 +GOOGLEAPIS_SHA = "c1969e5b72eab6d9b6cfcff748e45ba57294aeea1d96fd04cd081995de0605c2" PROMETHEUS_GIT_SHA = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c" # Nov 17, 2017 PROMETHEUS_SHA = "783bdaf8ee0464b35ec0c8704871e1e72afa0005c3f3587f65d9d6694bf3911b" @@ -28,7 +28,7 @@ REPOSITORY_LOCATIONS = dict( strip_prefix = "protoc-gen-validate-" + PGV_GIT_SHA, urls = ["https://github.com/envoyproxy/protoc-gen-validate/archive/" + PGV_GIT_SHA + ".tar.gz"], ), - googleapis = dict( + com_google_googleapis = dict( # TODO(dio): Consider writing a Skylark macro for importing Google API proto. sha256 = GOOGLEAPIS_SHA, strip_prefix = "googleapis-" + GOOGLEAPIS_GIT_SHA, diff --git a/bazel/api_binding.bzl b/bazel/api_binding.bzl new file mode 100644 index 0000000000000..bf4f304687c12 --- /dev/null +++ b/bazel/api_binding.bzl @@ -0,0 +1,36 @@ +def _default_envoy_api_impl(ctx): + ctx.file("WORKSPACE", "") + ctx.file("BUILD.bazel", "") + api_dirs = [ + "bazel", + "docs", + "envoy", + "examples", + "test", + "tools", + ] + for d in api_dirs: + ctx.symlink(ctx.path(ctx.attr.api).dirname.get_child(d), d) + +_default_envoy_api = repository_rule( + implementation = _default_envoy_api_impl, + attrs = { + "api": attr.label(default = "@envoy//api:BUILD"), + }, +) + +def envoy_api_binding(): + # Treat the data plane API as an external repo, this simplifies exporting the API to + # https://github.com/envoyproxy/data-plane-api. + if "envoy_api" not in native.existing_rules().keys(): + _default_envoy_api(name = "envoy_api") + + # TODO(https://github.com/envoyproxy/envoy/issues/7719) need to remove both bindings and use canonical rules + native.bind( + name = "api_httpbody_protos", + actual = "@com_google_googleapis//google/api:httpbody_cc_proto", + ) + native.bind( + name = "http_api_protos", + actual = "@com_google_googleapis//google/api:annotations_cc_proto", + ) diff --git a/bazel/api_repositories.bzl b/bazel/api_repositories.bzl index 016fb16c8a2ee..d4d2f1abd51d4 100644 --- a/bazel/api_repositories.bzl +++ b/bazel/api_repositories.bzl @@ -1,35 +1,4 @@ -def _default_envoy_api_impl(ctx): - ctx.file("WORKSPACE", "") - ctx.file("BUILD.bazel", "") - api_dirs = [ - "bazel", - "docs", - "envoy", - "examples", - "test", - "tools", - ] - for d in api_dirs: - ctx.symlink(ctx.path(ctx.attr.api).dirname.get_child(d), d) - -_default_envoy_api = repository_rule( - implementation = _default_envoy_api_impl, - attrs = { - "api": attr.label(default = "@envoy//api:BUILD"), - }, -) +load("@envoy_api//bazel:repositories.bzl", "api_dependencies") def envoy_api_dependencies(): - # Treat the data plane API as an external repo, this simplifies exporting the API to - # https://github.com/envoyproxy/data-plane-api. - if "envoy_api" not in native.existing_rules().keys(): - _default_envoy_api(name = "envoy_api") - - native.bind( - name = "api_httpbody_protos", - actual = "@googleapis//:api_httpbody_protos", - ) - native.bind( - name = "http_api_protos", - actual = "@googleapis//:http_api_protos", - ) + api_dependencies() diff --git a/bazel/dependency_imports.bzl b/bazel/dependency_imports.bzl new file mode 100644 index 0000000000000..3915eb1b553f7 --- /dev/null +++ b/bazel/dependency_imports.bzl @@ -0,0 +1,12 @@ +load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies") +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") +load("@envoy//bazel/toolchains:rbe_toolchains_config.bzl", "rbe_toolchains_config") + +# go version for rules_go +GO_VERSION = "1.12.5" + +def envoy_dependency_imports(go_version = GO_VERSION): + rules_foreign_cc_dependencies() + go_rules_dependencies() + go_register_toolchains(go_version) + rbe_toolchains_config() diff --git a/bazel/envoy_build_system.bzl b/bazel/envoy_build_system.bzl index 1a7ed4e98d578..4dc11e496c208 100644 --- a/bazel/envoy_build_system.bzl +++ b/bazel/envoy_build_system.bzl @@ -129,12 +129,13 @@ def envoy_proto_descriptor(name, out, srcs = [], external_deps = []): include_paths = [".", native.package_name()] if "api_httpbody_protos" in external_deps: - srcs.append("@googleapis//:api_httpbody_protos_src") - include_paths.append("external/googleapis") + srcs.append("@com_google_googleapis//google/api:httpbody.proto") + include_paths.append("external/com_google_googleapis") if "http_api_protos" in external_deps: - srcs.append("@googleapis//:http_api_protos_src") - include_paths.append("external/googleapis") + srcs.append("@com_google_googleapis//google/api:annotations.proto") + srcs.append("@com_google_googleapis//google/api:http.proto") + include_paths.append("external/com_google_googleapis") if "well_known_protos" in external_deps: srcs.append("@com_google_protobuf//:well_known_protos") diff --git a/bazel/envoy_library.bzl b/bazel/envoy_library.bzl index 33e9e93fc0491..b0f54ea64eb49 100644 --- a/bazel/envoy_library.bzl +++ b/bazel/envoy_library.bzl @@ -113,8 +113,8 @@ def envoy_proto_library(name, external_deps = [], **kwargs): external_proto_deps = [] external_cc_proto_deps = [] if "api_httpbody_protos" in external_deps: - external_cc_proto_deps.append("@googleapis//:api_httpbody_protos") - external_proto_deps.append("@googleapis//:api_httpbody_protos_proto") + external_cc_proto_deps.append("@com_google_googleapis//google/api:httpbody_cc_proto") + external_proto_deps.append("@com_google_googleapis//google/api:httpbody_proto") api_proto_library( name, external_cc_proto_deps = external_cc_proto_deps, diff --git a/bazel/foreign_cc/com_lightstep_tracer_cpp.patch b/bazel/foreign_cc/com_lightstep_tracer_cpp.patch index c0a4055ae4832..88e1a81ad8b27 100644 --- a/bazel/foreign_cc/com_lightstep_tracer_cpp.patch +++ b/bazel/foreign_cc/com_lightstep_tracer_cpp.patch @@ -5,7 +5,7 @@ srcs = ["collector.proto"], deps = [ - "@lightstep_vendored_googleapis//:googleapis_proto", -+ "@googleapis//:http_api_protos_proto", ++ "@com_google_googleapis//google/api:annotations_proto", "@com_google_protobuf//:timestamp_proto", ], visibility = ["//visibility:public"], diff --git a/bazel/foreign_cc/io_opencensus_cpp.patch b/bazel/foreign_cc/io_opencensus_cpp.patch deleted file mode 100644 index f814d6583d81e..0000000000000 --- a/bazel/foreign_cc/io_opencensus_cpp.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- BUILD 2019-06-03 18:30:58.511651926 -0700 -+++ opencensus/exporters/trace/stackdriver/BUILD 2019-06-03 18:32:38.107571186 -0700 -@@ -28,7 +28,7 @@ - copts = DEFAULT_COPTS, - visibility = ["//visibility:public"], - deps = [ -- "//google/devtools/cloudtrace/v2:tracing_proto", -+ "@googleapis//:tracing_proto", - "//opencensus/common:version", - "//opencensus/common/internal/grpc:status", - "//opencensus/common/internal/grpc:with_user_agent", diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index fe86b72263d81..9cb20ae5f0a3c 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -2,7 +2,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load(":genrule_repository.bzl", "genrule_repository") load("@envoy_api//bazel:envoy_http_archive.bzl", "envoy_http_archive") load(":repository_locations.bzl", "REPOSITORY_LOCATIONS") -load("@envoy_api//bazel:repositories.bzl", "api_dependencies") +load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") # dict of {build recipe name: longform extension name,} PPC_SKIP_TARGETS = {"luajit": "envoy.filters.http.lua"} @@ -15,9 +15,6 @@ NOBORINGSSL_SKIP_TARGETS = { "tls_inspector": "envoy.filters.listener.tls_inspector", } -# go version for rules_go -GO_VERSION = "1.12.5" - # Make all contents of an external repository accessible under a filegroup. Used for external HTTP # archives, e.g. cares. BUILD_ALL_CONTENT = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])""" @@ -161,7 +158,16 @@ def envoy_dependencies(skip_targets = []): _python_deps() _cc_deps() _go_deps(skip_targets) - api_dependencies() + + switched_rules_by_language( + name = "com_google_googleapis_imports", + cc = True, + go = True, + grpc = True, + rules_override = { + "py_proto_library": "@envoy_api//bazel:api_build_system.bzl", + }, + ) def _boringssl(): _repository_impl("boringssl") @@ -516,8 +522,6 @@ def _io_opencensus_cpp(): location = REPOSITORY_LOCATIONS["io_opencensus_cpp"] http_archive( name = "io_opencensus_cpp", - patch_args = ["-p0"], - patches = ["@envoy//bazel/foreign_cc:io_opencensus_cpp.patch"], **location ) native.bind( diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index a9db5ba2a0aca..1ff6299a65ba6 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -233,9 +233,9 @@ REPOSITORY_LOCATIONS = dict( urls = ["https://files.pythonhosted.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz"], ), io_opencensus_cpp = dict( - sha256 = "d6d68704c419a9e892bd1f942e09509ebc5a318499a1abcf2c09734e5dc56e19", - strip_prefix = "opencensus-cpp-1145dd77ffb7a2845c71c8e6ca188ef55e4ff607", - urls = ["https://github.com/census-instrumentation/opencensus-cpp/archive/1145dd77ffb7a2845c71c8e6ca188ef55e4ff607.tar.gz"], + sha256 = "9223b4d54af4151910dede03aa58247e90df72167fcc91d5f75e73a141568036", + strip_prefix = "opencensus-cpp-e292a374fb42c6cb2743f1689234bd409f4fda20", + urls = ["https://github.com/census-instrumentation/opencensus-cpp/archive/e292a374fb42c6cb2743f1689234bd409f4fda20.tar.gz"], ), com_github_curl = dict( sha256 = "821aeb78421375f70e55381c9ad2474bf279fc454b791b7e95fc83562951c690", diff --git a/ci/WORKSPACE.filter.example b/ci/WORKSPACE.filter.example index f11c8e7911be0..db20a3146ac9a 100644 --- a/ci/WORKSPACE.filter.example +++ b/ci/WORKSPACE.filter.example @@ -5,21 +5,18 @@ local_repository( path = "{ENVOY_SRCDIR}", ) +load("@envoy//bazel:api_binding.bzl", "envoy_api_binding") + +envoy_api_binding() + load("@envoy//bazel:api_repositories.bzl", "envoy_api_dependencies") + envoy_api_dependencies() -load("@envoy//bazel:repositories.bzl", "envoy_dependencies", "GO_VERSION") +load("@envoy//bazel:repositories.bzl", "envoy_dependencies") envoy_dependencies() -# TODO(htuch): Roll this into envoy_dependencies() -load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies") -rules_foreign_cc_dependencies() - -load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") -go_rules_dependencies() -go_register_toolchains(go_version = GO_VERSION) - -load("@envoy//bazel/toolchains:rbe_toolchains_config.bzl", "rbe_toolchains_config") +load("@envoy//bazel:dependency_imports.bzl", "envoy_dependency_imports") -rbe_toolchains_config() +envoy_dependency_imports() diff --git a/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc b/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc index 12c0cfd19f54f..154e5903fe83b 100644 --- a/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc +++ b/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc @@ -135,9 +135,7 @@ Span::Span(const envoy::config::trace::v2::OpenCensusConfig& oc_config, ::opencensus::trace::Span&& span) : span_(std::move(span)), oc_config_(oc_config) {} -void Span::setOperation(absl::string_view operation) { - span_.AddAnnotation("setOperation", {{"operation", operation}}); -} +void Span::setOperation(absl::string_view operation) { span_.SetName(operation); } void Span::setTag(absl::string_view name, absl::string_view value) { span_.AddAttribute(name, value); diff --git a/test/extensions/tracers/opencensus/tracer_test.cc b/test/extensions/tracers/opencensus/tracer_test.cc index 83d622b70bcfc..2c7cf5695fec6 100644 --- a/test/extensions/tracers/opencensus/tracer_test.cc +++ b/test/extensions/tracers/opencensus/tracer_test.cc @@ -134,18 +134,17 @@ TEST(OpenCensusTracerTest, Span) { const auto& sd = (spans[0].name() == operation_name) ? spans[0] : spans[1]; ENVOY_LOG_MISC(debug, "{}", sd.DebugString()); - EXPECT_EQ("my_operation_1", sd.name()); + EXPECT_EQ("different_name", sd.name()); EXPECT_TRUE(sd.context().IsValid()); EXPECT_TRUE(sd.context().trace_options().IsSampled()); ::opencensus::trace::SpanId zeros; EXPECT_EQ(zeros, sd.parent_span_id()); parent_span_id = sd.context().span_id(); - ASSERT_EQ(4, sd.annotations().events().size()); - EXPECT_EQ("setOperation", sd.annotations().events()[0].event().description()); - EXPECT_EQ("my annotation", sd.annotations().events()[1].event().description()); - EXPECT_EQ("spawnChild", sd.annotations().events()[2].event().description()); - EXPECT_EQ("setSampled", sd.annotations().events()[3].event().description()); + ASSERT_EQ(3, sd.annotations().events().size()); + EXPECT_EQ("my annotation", sd.annotations().events()[0].event().description()); + EXPECT_EQ("spawnChild", sd.annotations().events()[1].event().description()); + EXPECT_EQ("setSampled", sd.annotations().events()[2].event().description()); EXPECT_TRUE(sd.has_ended()); }