Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move all tchannel packages to a single top level package #2112

Merged
merged 8 commits into from
Mar 4, 2020

Conversation

pavolloffay
Copy link
Member

@pavolloffay pavolloffay commented Mar 3, 2020

Related to #2105
Supersedes #2109

The top level package is ./tchannel. I have kept the original package structure. e.g. ./tchannel/agent/app/reporter/tchannel.

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
@pavolloffay pavolloffay requested a review from a team as a code owner March 3, 2020 14:51
@pavolloffay pavolloffay requested a review from vprithvi March 3, 2020 14:51
}

// AddFlagsWithCustomTypes adds types to use message.
func AddFlagsWithCustomTypes(types []string) func(*flag.FlagSet) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need types?

Also - if GRPC is the only supported reporter, we can deprecate the flag so that we can remove it later

Copy link
Member Author

Choose a reason for hiding this comment

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

I made it backwars compatible, so in Uber's custom build the type can be added back.

Also - if GRPC is the only supported reporter, we can deprecate the flag so that we can remove it later

I would leave it for now as it is. It gives us more flexibility to extend.

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure what the intent of this function, can you elaborate?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have added a better description to the signature

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
@codecov
Copy link

codecov bot commented Mar 3, 2020

Codecov Report

Merging #2112 into master will decrease coverage by 0.16%.
The diff coverage is 31.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2112      +/-   ##
==========================================
- Coverage   96.29%   96.12%   -0.17%     
==========================================
  Files         214      217       +3     
  Lines       10535    10541       +6     
==========================================
- Hits        10145    10133      -12     
- Misses        331      353      +22     
+ Partials       59       55       -4
Impacted Files Coverage Δ
tchannel/agent/app/reporter/tchannel/flags.go 100% <ø> (ø)
tchannel/agent/app/reporter/tchannel/builder.go 100% <ø> (ø)
cmd/collector/app/builder_flags.go 100% <ø> (ø) ⬆️
tchannel/agent/app/reporter/tchannel/reporter.go 100% <ø> (ø)
...hannel/agent/app/configmanager/tchannel/manager.go 100% <ø> (ø)
...nel/agent/app/reporter/tchannel/collector_proxy.go 100% <ø> (ø)
cmd/collector/app/collector.go 69.11% <0%> (-3.04%) ⬇️
tchannel/collector/app/collector.go 0% <0%> (ø)
tchannel/collector/app/server/thrift.go 0% <0%> (ø)
tchannel/collector/app/flags.go 0% <0%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf48066...0ec96ee. Read the comment docs.

@pavolloffay
Copy link
Member Author

The coverage is failing bc of the new files in tchannel package I will not cover those as It will be eventually removed.

}

// ProxyBuilder is a func which builds CollectorProxy.
type ProxyBuilder func(map[string]string, metrics.Factory, *zap.Logger) (CollectorProxy, error)
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'd prefer passing a ProxyBuilderParams struct

cmd/agent/app/reporter/grpc/builder.go Outdated Show resolved Hide resolved
}

// AddFlagsWithCustomTypes adds types to use message.
func AddFlagsWithCustomTypes(types []string) func(*flag.FlagSet) {
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure what the intent of this function, can you elaborate?

flags.String(reporterType, string(GRPC), fmt.Sprintf("Reporter type to use e.g. %s", types))
if !setupcontext.IsAllInOne() {
flags.String(agentTagsDeprecated, "", "(deprecated) see --"+agentTags)
flags.String(agentTags, "", "One or more tags to be added to the Process tags of all spans passing through this agent. Ex: key1=value1,key2=${envVar:defaultValue}")
Copy link
Member

Choose a reason for hiding this comment

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

if the intent is to do something with different reporters, why do agent tags need to be here, and not in the main function?

cmd/agent/app/reporter/flags.go Outdated Show resolved Hide resolved
cp, err := app.CreateCollectorProxy(rOpts, tchanBuilder, grpcBuilder, logger, mFactory)
builders := map[reporter.Type]app.ProxyBuilder{}
builders[reporter.GRPC] = func(m map[string]string, factory metrics.Factory, logger *zap.Logger) (app.CollectorProxy, error) {
return grpc.NewCollectorProxy(grpcBuilder, rOpts.AgentTags, mFactory, logger)
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to have a function in each package that matches the ProxyBuilder signature, rather than using lambdas here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have created proxy_builders.go in agent/app package. They cannot live in the reporter's package bc it creates cyclic imports

# github.com/jaegertracing/jaeger/cmd/agent/app/processors
FAIL	github.com/jaegertracing/jaeger/cmd/agent/app/processors [setup failed]
import cycle not allowed in test
FAIL
package github.com/jaegertracing/jaeger/cmd/agent/app/processors (test)
	imports github.com/jaegertracing/jaeger/tchannel/agent/app/reporter/tchannel
	imports github.com/jaegertracing/jaeger/cmd/agent/app
	imports github.com/jaegertracing/jaeger/cmd/agent/app/processors



GOROOT=/home/ploffay/bin/go #gosetup
GOPATH=/home/ploffay/projects/golang #gosetup
/home/ploffay/bin/go/bin/go test -c -o /tmp/___go_test_github_com_jaegertracing_jaeger_cmd_agent_app github.com/jaegertracing/jaeger/cmd/agent/app #gosetup
FAIL	github.com/jaegertracing/jaeger/cmd/agent/app [setup failed]
# github.com/jaegertracing/jaeger/cmd/agent/app
FAIL
import cycle not allowed in test
package github.com/jaegertracing/jaeger/cmd/agent/app (test)
	imports github.com/jaegertracing/jaeger/tchannel/agent/app/reporter
	imports github.com/jaegertracing/jaeger/cmd/agent/app

Copy link
Member

Choose a reason for hiding this comment

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

I wasn't suggesting importing the function type, just having functions in tch/grpc packages that match it on the signature.

Copy link
Member Author

Choose a reason for hiding this comment

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

There was also a suggestion to pass pass Options instead of listing the parameters. That creates cycle too.

Copy link
Member

Choose a reason for hiding this comment

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

oh, but the struct, I see...

cmd/agent/main.go Outdated Show resolved Hide resolved
const (
// CollectorTChannel is the default port for TChannel server for sending spans
CollectorTChannel = 14267
collectorPort = "collector.port"
Copy link
Member

Choose a reason for hiding this comment

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

It looks like we're going back to the deprecated flag name? Maybe we can remove the old one, as it's been quite a while since we deprecated it.

Copy link
Member Author

Choose a reason for hiding this comment

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

The intent of this PR is to just move tchannel code to a separate package. The component itself will be removed in the follow-up PR along with flags bindings.

Copy link
Member

Choose a reason for hiding this comment

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

nvm, I though we had another option similar to

      --collector.grpc-port int                         The gRPC port for the collector service (default 14250)

cmd/agent/app/builder.go Outdated Show resolved Hide resolved
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
flags.String(reporterType, string(GRPC), fmt.Sprintf("Reporter type to use e.g. %s, %s[%s]", string(GRPC), string(TCHANNEL), "NOTE: Deprecated since 1.16"))
func (f Flags) AddFlags(flags *flag.FlagSet) {
reps := append([]string{string(GRPC)}, f.Reporters...)
flags.String(reporterType, string(GRPC), fmt.Sprintf("Reporter type to use e.g. %s", reps))
Copy link
Member

Choose a reason for hiding this comment

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

if all this complication just to include tchannel in the possible reporter types in the help string, I would say it's not worth it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes just for the help message, I am removing it

@@ -31,7 +31,7 @@ type ProxyBuilder struct {
conn *grpc.ClientConn
}

// NewCollectorProxy creates ProxyBuilder
// NewCollectorProxy creates CollectorProxyBuilder
Copy link
Member

Choose a reason for hiding this comment

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

should revert this

cmd/agent/main.go Outdated Show resolved Hide resolved
const (
// CollectorTChannel is the default port for TChannel server for sending spans
CollectorTChannel = 14267
collectorPort = "collector.port"
Copy link
Member

Choose a reason for hiding this comment

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

nvm, I though we had another option similar to

      --collector.grpc-port int                         The gRPC port for the collector service (default 14250)

cmd/all-in-one/main.go Outdated Show resolved Hide resolved
cmd/all-in-one/main.go Outdated Show resolved Hide resolved
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
@pavolloffay
Copy link
Member Author

@yurishkuro comments addressed and PR updated

@pavolloffay pavolloffay merged commit cc283fb into jaegertracing:master Mar 4, 2020
@yurishkuro
Copy link
Member

close #2109 ?

I am waiting on our RPC team to resolve the conflict with grpc 1.26, then we can pull in this change to test, and then switch to the internal copy of the new tchannel package.

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.

3 participants