Skip to content

tracing: update opencensus and googleapis, use SetName for operation name#7622

Merged
lizan merged 17 commits intoenvoyproxy:masterfrom
kyessenov:update_opencensus
Jul 26, 2019
Merged

tracing: update opencensus and googleapis, use SetName for operation name#7622
lizan merged 17 commits intoenvoyproxy:masterfrom
kyessenov:update_opencensus

Conversation

@kyessenov
Copy link
Copy Markdown
Contributor

Description:
Un-pin opencensus and googleapis to use master versions
Use SetName span method to set route operation names (aligning with other tracers).

Risk Level: low
Testing: Unit tests
Docs Changes: None
Release Notes: None

Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
@kyessenov
Copy link
Copy Markdown
Contributor Author

cc @htuch @g-easy FYI

Signed-off-by: Kuat Yessenov <kuat@google.com>
@kyessenov
Copy link
Copy Markdown
Contributor Author

How do we update envoy-filter-example repo in lock-step? I need to update the WORKSPACE, since I can't load googleapis rules in the existing bazel/repositories.bzl (since it loads the googleapis).

@kyessenov
Copy link
Copy Markdown
Contributor Author

Prepared envoyproxy/envoy-filter-example#94. I'm not sure how this can be done step-by-step since the two builds are coupled.

http_archive(
name = "io_opencensus_cpp",
patch_args = ["-p0"],
patches = ["@envoy//bazel/foreign_cc:io_opencensus_cpp.patch"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thank you.

Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this is great, just one comment.

WORKSPACE Outdated

go_register_toolchains(go_version = GO_VERSION)

load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to roll this into api_dependencies in bazel/repositories.bzl (not api/bazel/repositories.bzl).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api_dependencies has http_archive for com_google_googleapis, so that won't work. We can't load from a repo before it's http_archive.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the naming is confusing. bazel/api_repositories.bzl does not actually load API repositories, so I get why one might get confused (I did).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Lizan, do you still think it's possible to add a load from googleapis without WORKSPACE change? I don't see a way, since googleapis is loaded as one of the last calls in there.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I see what you're saying, I think we want to somehow roll this into a bzl file, @htuch do you have any idea? Just roll additional dependencies (those WORKSPACE rules after envoy_dependencies) in an additional bzl file should work but still somewhat ugly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gentle ping?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think that would work, do you mind take a stab?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the envoy_api hack well, I'd hope @htuch can help there. Either way, this is going to cause churn in importing repositories, even if we change from 2 calls to 3 calls.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but less churning in in the future :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, PTAL

void Span::setOperation(absl::string_view operation) {
span_.AddAnnotation("setOperation", {{"operation", operation}});
}
void Span::setOperation(absl::string_view operation) { span_.SetName(operation); }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
Took a lot of Bazel magic to get this change through !

Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix ci/WORKSPACE.filter.example to pass CI.

WORKSPACE Outdated

go_register_toolchains(go_version = GO_VERSION)

load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I see what you're saying, I think we want to somehow roll this into a bzl file, @htuch do you have any idea? Just roll additional dependencies (those WORKSPACE rules after envoy_dependencies) in an additional bzl file should work but still somewhat ugly.

Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
@kyessenov
Copy link
Copy Markdown
Contributor Author

Thanks for the pointer. I've updated the example filter workspace.

@kyessenov
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🔨 rebuilding ci/circleci: tsan (failed build)

🐱

Caused by: a #7622 (comment) was created by @kyessenov.

see: more, trace.

Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
@kyessenov
Copy link
Copy Markdown
Contributor Author

Is there any concern with this PR? We'd really benefit from this being in the upstream, since it simplifies bazel hacking in downstream projects.

Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking rolling everything else (foreign_cc / go_rules / rbe / googleapi_import) into a new bzl so there will be less churn. defer to @htuch

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the upgrade, I have a few questions.

if "envoy_api" not in native.existing_rules().keys():
_default_envoy_api(name = "envoy_api")

native.bind(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to still do this bind? Can we replace the bind uses inside the API tree with the canonical @com_google_apis//... labels? Same below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be fine as long as none of downstream envoy repositories refer to the bind. I don't have confidence that is the case, so I left it as-is for backwards compatibility reasons.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to say "go ahead" on this, we don't provide stability guarantees around WORKSPACE and you're moving towards the long-term stable canonical naming convention in Bazel.

This is where recursive workspaces would be great.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, grpc_json_transcoder depends on this binding, so I can't remove it without making changes to that repository. Can this be done later since we'll have to make changes to other repositories first?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, can you file an issue for cleanup here and tag the site with TODO?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #7719 and referenced it here.

@kyessenov
Copy link
Copy Markdown
Contributor Author

@lizan I still don't get what you are trying to suggest. Bazel requires load to be first in every .bzl file. That means you have to have multiple .bzl files as you load your dependent repositories with their .bzl files. How would folding everything into one file avoid this issue?

@kyessenov
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🔨 rebuilding ci/circleci: compile_time_options (failed build)

🐱

Caused by: a #7622 (comment) was created by @kyessenov.

see: more, trace.

Signed-off-by: Kuat Yessenov <kuat@google.com>
@lizan
Copy link
Copy Markdown
Member

lizan commented Jul 24, 2019

My intention was rolling everything after

load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
to a new .bzl file where you can load bzl from repositories which are already loaded by envoy_dependencies, thus we have smaller WORKSPACE` and future changes can just made there.

@htuch
Copy link
Copy Markdown
Member

htuch commented Jul 25, 2019

@lizan @kyessenov I would be in favor of shrinking down to the smallest possible WORKSPACE. The question is how few lines can we get away with. @kyessenov is correct that load must be at the top of any .bzl. I wonder if we could transform:

WORKSPACE:

load("a.bzl", a)
a()
load("b.bzl", b)
b()

to

WORKSPACE:

load("c.bzl", c)
c()

c.bzl:

load("a.bzl", "a")
load("b.bzl", "b")
a()
b()

I.e. can we arbitrarily reorder the loads?

@kyessenov
Copy link
Copy Markdown
Contributor Author

load("//bazel:api_binding.bzl", "envoy_api_binding")
load("//bazel:api_repositories.bzl", "envoy_api_dependencies")

envoy_api_binding()
envoy_api_dependencies()

gives an error:

ERROR: Failed to load Starlark extension '@envoy_api//bazel:repositories.bzl'.
Cycle in the workspace file detected. This indicates that a repository is used prior to being defined.
The following chain of repository dependencies lead to the missing definition.
 - @envoy_api

I guess the answer is no, the order of loads is important.

@htuch
Copy link
Copy Markdown
Member

htuch commented Jul 25, 2019

Crap, I see the issue. We have load statements that rely on .bzl from earlier imported dependencies.

@lizan I don't think we can do this in a .bzl, given this dependency. I think we should go with things as they are.

@dslomov this seems to be a pretty big limitation without recursive workspaces. I recall that recurisve workspaces had issues, do you have the latest best practice here?

Signed-off-by: Kuat Yessenov <kuat@google.com>
htuch
htuch previously approved these changes Jul 25, 2019
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM given constraints, @lizan are you good to merge?

@lizan
Copy link
Copy Markdown
Member

lizan commented Jul 25, 2019

@htuch @kyessenov this is what I meant (and it works): e45ad99

so we only have 3 load + function calls, and the WORKSPACE shouldn't grow more...

@kyessenov
Copy link
Copy Markdown
Contributor Author

@lizan What happens when we need to import from something loaded in envoy_dependency_imports? :) I think this is pretty arbitrary to have 4 top-level calls, and it happens to work because our load-import chain is only 3-long. But we need a systematic solution here...

@lizan
Copy link
Copy Markdown
Member

lizan commented Jul 25, 2019

Yeah it is theoretically possible, but I think this is best we can have before recursive workspace. I don't think we should or want to have an external dependency with that complexity (i.e. 3-level dependency from) by then.

@kyessenov
Copy link
Copy Markdown
Contributor Author

@lizan updated to make workspaces smaller.

@lizan
Copy link
Copy Markdown
Member

lizan commented Jul 25, 2019

Do we still need the api_binding / api_dependencies split? I'm fine with the renaming original api_dependencies -> api_binding, but the split seems unnecessary.

@kyessenov
Copy link
Copy Markdown
Contributor Author

I'd prefer to keep api_dependencies distinct from dependencies since I want to be able to build just APIs. The binding trick should also be kept separate since I may not want to do the local bind that envoy does. Since any two of the three things cannot be placed into one bzl file, I think it's fair to keep them separate.

Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to keep api_dependencies distinct from dependencies since I want to be able to build just APIs. The binding trick should also be kept separate since I may not want to do the local bind that envoy does. Since any two of the three things cannot be placed into one bzl file, I think it's fair to keep them separate.

OK that's fair.

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")

def envoy_dependency_imports(go_version = "1.12.5"):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just move GO_VERSION from bazel/repositories.bzl to here? It is not used anywhere else.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Kuat Yessenov <kuat@google.com>
@lizan lizan merged commit ef054f0 into envoyproxy:master Jul 26, 2019
@Mythra
Copy link
Copy Markdown
Member

Mythra commented Jul 26, 2019

I believe these changes broke envoy-filter-example (as well as our internal projects that use a similar workspace to envoy-filter-example).

As of this PR being out envoy-filter-example & others now fail with:

ERROR: Failed to load Starlark extension '@envoy_api//bazel:repositories.bzl'.
Cycle in the workspace file detected. This indicates that a repository is used prior to being defined.
The following chain of repository dependencies lead to the missing definition.
 - @envoy_api
This could either mean you have to add the '@envoy_api' repository with a statement like `http_archive` in your WORKSPACE file (note that transitive dependencies are not added automatically), or move an existing definition earlier in your WORKSPACE file.
ERROR: cycles detected during target parsing
INFO: Elapsed time: 0.040s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

Even with applying the PR: envoyproxy/envoy-filter-example#94 locally, it still fails to build.

@kyessenov
Copy link
Copy Markdown
Contributor Author

kyessenov commented Jul 26, 2019

Please take a look at the diff in ci/WORKSPACE.filter.example for the change required in the workspace. You can read the discussion above about why it is hard to keep it backwards compatible.

@Mythra
Copy link
Copy Markdown
Member

Mythra commented Jul 26, 2019

Yeah, I missed that originally, but it was mentioned in slack. There’s now a PR to the filter example that fixed it, and we’ve fixed internally.

Sorry for missing that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants