c++bazelstackdriveropencensus

Setting up OpenCensus to work with Stackdriver


I'm trying to setup OpenCensus for our project, but I'm running into Bazel issues.

error loading package '@com_google_googleapis//google/devtools/cloudtrace/v2': Unable to find package for @com_google_googleapis_imports//:imports.bzl: The repository '@com_google_googleapis_imports' could not be resolved. and referenced by '@io_opencensus_cpp//opencensus/exporters/trace/stackdriver:stackdriver_exporter'

This happens when trying to use the version at HEAD. Does anyone know how to fix this? Googleapis indeed does not seem to have any file named imports.bzl.


Solution

  • So for people that run into this, the problem was me missing the GoogleAPIs repo. This is the final import I ended up with.

    # googleapis
    http_archive(
        name = "com_google_googleapis",
        sha256 = "0744d1a1834ab350126b12ebe2b4bb1c8feb5883bd1ba0a6e876cb741d569994",
        strip_prefix = "googleapis-bcc476396e799806d3355e87246c6becf6250a70",
        urls = ["https://github.com/googleapis/googleapis/archive/bcc476396e799806d3355e87246c6becf6250a70.tar.gz"],
    )
    
    load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
    switched_rules_by_language(
        name = "com_google_googleapis_imports",
        cc = True,
        grpc = True,
    )
    
    # opencensus
    http_archive(
        name = "io_opencensus_cpp",
        sha256 = "193ffb4e13bd7886757fd22b61b7f7a400634412ad8e7e1071e73f57bedd7fc6",
        strip_prefix = "opencensus-cpp-04ed0211931f12b03c1a76b3907248ca4db7bc90",
        urls = ["https://github.com/census-instrumentation/opencensus-cpp/archive/04ed0211931f12b03c1a76b3907248ca4db7bc90.tar.gz"],
    )
    
    load("@io_opencensus_cpp//bazel:deps.bzl", "opencensus_cpp_deps")
    
    opencensus_cpp_deps()