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

Adds support for agent level tag #1396

Merged
merged 18 commits into from
Mar 18, 2019
Merged

Conversation

annanay25
Copy link
Member

@annanay25 annanay25 commented Mar 3, 2019

Signed-off-by: Annanay annanay.a@media.net

Which problem is this PR solving?

Short description of the changes

  • Uses a --jaeger.tags flag to enable tag addition (Ex: --jaeger.tags=key=value). This can be used with env variables.

}

// AddFlags adds flags for Options.
func AddFlags(flags *flag.FlagSet) {
flags.String(reporterType, string(GRPC), fmt.Sprintf("Reporter type to use e.g. %s, %s", string(GRPC), string(TCHANNEL)))
flags.String(agentTags, "", fmt.Sprintf("Add agent-based tags. Ex: --jaeger.tags key1=value1,${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.

what does ,${envVar:defaultValue} mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copied over from https://github.com/jaegertracing/jaeger-client-go/blob/c58709fe19d793cdd40ad8bfa6e645a40a2eccf8/config/config_env.go#L195-L199 -

// parseTags parses the given string into a collection of Tags.
// Spec for this value:
// - comma separated list of key=value
// - value can be specified using the notation ${envVar:defaultValue}, where `envVar`
// is an environment variable and `defaultValue` is the value to use in case the env var is not set

cmd/agent/app/reporter/flags.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/flags.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/grpc/reporter.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/grpc/reporter.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/grpc/reporter.go Outdated Show resolved Hide resolved
func addAgentTags(spans []*model.Span, agentTags []model.KeyValue) []*model.Span {
for _, span := range spans {
for _, tag := range agentTags{
span.Tags = append(span.Tags, tag)
Copy link
Member

Choose a reason for hiding this comment

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

top-level question for the PR: should these be added to Span tags or Process tags?

Copy link
Member

Choose a reason for hiding this comment

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

It might depend. For example in k8s we support deploying agent as a side-car but also as daemon set (1 agent per k8s node).

I think we would need an additional flag to be able to add it to process tags

Copy link
Member Author

@annanay25 annanay25 Mar 5, 2019

Choose a reason for hiding this comment

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

I think we would need an additional flag to be able to add it to process tags

Is this the consensus?

@annanay25 annanay25 changed the title WIP - Adds support for agent level tag Adds support for agent level tag Mar 4, 2019
@annanay25 annanay25 marked this pull request as ready for review March 4, 2019 18:13
func addAgentTags(spans []*model.Span, agentTags []model.KeyValue) []*model.Span {
for _, span := range spans {
for _, tag := range agentTags{
span.Tags = append(span.Tags, tag)
Copy link
Member

Choose a reason for hiding this comment

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

It might depend. For example in k8s we support deploying agent as a side-car but also as daemon set (1 agent per k8s node).

I think we would need an additional flag to be able to add it to process tags

cmd/agent/app/reporter/tchannel/reporter.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/tchannel/reporter.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/tchannel/reporter.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/tchannel/reporter.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/tchannel/reporter.go Outdated Show resolved Hide resolved
@annanay25
Copy link
Member Author

Thanks for the reviews. Addressed comments. Just the top level question remains.

@annanay25 annanay25 force-pushed the agent-tags branch 2 times, most recently from 3cd2caf to 82ba1d3 Compare March 10, 2019 20:10
@codecov
Copy link

codecov bot commented Mar 12, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@1157a7d). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #1396   +/-   ##
========================================
  Coverage          ?    100%           
========================================
  Files             ?     165           
  Lines             ?    7538           
  Branches          ?       0           
========================================
  Hits              ?    7538           
  Misses            ?       0           
  Partials          ?       0
Impacted Files Coverage Δ
cmd/agent/app/builder.go 100% <100%> (ø)
cmd/agent/app/reporter/flags.go 100% <100%> (ø)
cmd/agent/app/reporter/grpc/collector_proxy.go 100% <100%> (ø)
cmd/agent/app/reporter/grpc/reporter.go 100% <100%> (ø)

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 1157a7d...b8b7c5d. Read the comment docs.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

The change is not particularly complex, I think the coverage can be kept at 100.

We may want to consider excluding changes to TChannel reporter dealing with jaeger.thrift/zipkin.thrift, because we're planning to deprecate & remove TChannel reporter in the near future, so this will reduce the amount of tests needed to keep the coverage. But ok to keep too.

cmd/agent/app/reporter/flags.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/grpc/reporter.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/grpc/reporter.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/tchannel/reporter.go Outdated Show resolved Hide resolved
Annanay added 10 commits March 13, 2019 23:59
Signed-off-by: Annanay <annanay.a@media.net>
Signed-off-by: Annanay <annanay.a@media.net>
Signed-off-by: Annanay <annanay.a@media.net>
Signed-off-by: Annanay <annanay.a@media.net>
Signed-off-by: Annanay <annanay.a@media.net>
Signed-off-by: Annanay <annanay.a@media.net>

nit, fix function call

Signed-off-by: Annanay <annanay.a@media.net>

nit, fix function call

Signed-off-by: Annanay <annanay.a@media.net>

fix fmt, gosimple

Signed-off-by: Annanay <annanay.a@media.net>

make fmt
Signed-off-by: Annanay <annanay.a@media.net>

Fix tag names

Signed-off-by: Annanay <annanay.a@media.net>
Signed-off-by: Annanay <annanay.a@media.net>
Signed-off-by: Annanay <annanay.a@media.net>
Signed-off-by: Annanay <annanay.a@media.net>
Signed-off-by: Annanay <annanay.a@media.net>
@annanay25
Copy link
Member Author

Thanks for the review @yurishkuro!

I've added tests only for the grpc reporter for now, but do let me know if TChannel reporter tests are also required.

@yurishkuro
Copy link
Member

If we're not adding tchannel tests, we shouldn't change tchannel code either, otherwise coverage will go down (which I can't see now because the bloody crossdock test failed again).

@annanay25
Copy link
Member Author

Codecov is at 73%, let me remove all changes to tchannel reporter.

Signed-off-by: Annanay <annanay.a@media.net>
@annanay25
Copy link
Member Author

Crossdock again 😅

@yurishkuro
Copy link
Member

the main addition seems to be untested

image

Signed-off-by: Annanay <annanay.a@media.net>
cmd/agent/app/reporter/grpc/reporter.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/flags.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/flags_test.go Outdated Show resolved Hide resolved
Signed-off-by: Annanay <annanay.a@media.net>
cmd/agent/app/reporter/flags.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/flags_test.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/flags_test.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/grpc/reporter_test.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/grpc/reporter_test.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/grpc/reporter_test.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/grpc/reporter.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/grpc/reporter.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/flags.go Outdated Show resolved Hide resolved
cmd/agent/app/reporter/grpc/reporter.go Outdated Show resolved Hide resolved
Annanay added 2 commits March 18, 2019 19:50
Signed-off-by: Annanay <annanay.a@media.net>
Signed-off-by: Annanay <annanay.a@media.net>
Annanay and others added 2 commits March 19, 2019 00:37
Signed-off-by: Annanay <annanay.a@media.net>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

🎉

@yurishkuro yurishkuro merged commit 8e76a50 into jaegertracing:master Mar 18, 2019
@annanay25
Copy link
Member Author

Thanks! :)

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