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

Enable JAEGER_SERVICE_NAME and JAEGER_PROPAGATION env vars to be set … #128

Merged
merged 2 commits into from
Nov 27, 2018
Merged

Conversation

objectiser
Copy link
Contributor

…on containers with injected agent

Resolves #29
Resolves #74

Signed-off-by: Gary Brown gary@brownuk.com

…on containers with injected agent

Signed-off-by: Gary Brown <gary@brownuk.com>
@jpkrohling
Copy link
Contributor

This change is Reviewable

@codecov
Copy link

codecov bot commented Nov 23, 2018

Codecov Report

Merging #128 into master will increase coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #128      +/-   ##
==========================================
+ Coverage   95.99%   96.07%   +0.07%     
==========================================
  Files          27       27              
  Lines        1148     1171      +23     
==========================================
+ Hits         1102     1125      +23     
  Misses         36       36              
  Partials       10       10
Impacted Files Coverage Δ
pkg/inject/sidecar.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 624b342...163fa63. Read the comment docs.

@objectiser
Copy link
Contributor Author

Ran e2e tests - daemonset still failing but all other tests fine. Want to try it out on a real example before merge - hopefully first thing next week.

One point - setting JAEGER_PROPAGATION to jaeger,b3 to enable services to work in Istio environment (requiring b3) as well as non-Istio environments using the jaeger propagation format. If we had a way to know that we are running in Istio, or have Istio specific platform values (e.g. istio for Istio on k8s, openshift+istio for Istio running on openshift) then we could just specify the b3 format in those Istio cases - and not set the env var otherwise?

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Ran e2e tests - daemonset still failing but all other tests fine. Want to try it out on a real example before merge - hopefully first thing next week.

Strange, the e2e test should be passing. Could you confirm that you are able to get a clean run with all tests passing with the latest master?

I'm not sure I understood your question, though. The env vars are still applied to the target application, aren't they? Shouldn't then we always allow both env vars, as we don't know how the application itself is using Jaeger?

Reviewed 2 of 2 files at r1.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @objectiser)


pkg/inject/sidecar.go, line 22 at r1 (raw file):

const (
	serviceName = "JAEGER_SERVICE_NAME"

How about adding a prefix, to make it clear that it's about an env var name, and not the service name itself?


pkg/inject/sidecar.go, line 33 at r1 (raw file):

		logrus.Debugf("Skipping sidecar injection for deployment %v", dep.Name)
	} else {
		decorate(dep)

+1


pkg/inject/sidecar.go, line 109 at r1 (raw file):

	if app, found := dep.Spec.Template.Labels["app"]; found {
		if len(dep.Namespace) > 0 {
			app += "." + dep.Namespace

We need to document this. Bonus points if you can add a word or two about why the order is ${name}.${namespace} (DNS-like) and not ${namespace}.${name} (qualifier-like) .


pkg/inject/sidecar_test.go, line 52 at r1 (raw file):

func TestInjectSidecarWithEnvVarsWithNamespace(t *testing.T) {
	jaeger := v1alpha1.NewJaeger("TestInjectSidecarWithEnvVars")

nit: copy/paste? The instance names are usually following the test name, to avoid one test having an influence on other tests.


pkg/inject/sidecar_test.go, line 77 at r1 (raw file):

	assert.Len(t, dep.Spec.Template.Spec.Containers[0].Env, 2)
	assert.Equal(t, serviceName, dep.Spec.Template.Spec.Containers[0].Env[0].Name)
	assert.Equal(t, "otherapp", dep.Spec.Template.Spec.Containers[0].Env[0].Value)

We should document this as well: the namespace isn't used at all when app is present.

Copy link
Contributor Author

@objectiser objectiser left a comment

Choose a reason for hiding this comment

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

Reran and it was clear, so no problem with daemonset test on master. Will rerun on this branch once have done updates.

True - but the environment variables can always be overridden - so was thinking about having sensible defaults. The issue with including both jaeger and b3 propagation formats, is that it increases the number of headers being propagated between services (possibly unnecessarily).

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @jpkrohling)


pkg/inject/sidecar.go, line 22 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

How about adding a prefix, to make it clear that it's about an env var name, and not the service name itself?

Done.


pkg/inject/sidecar.go, line 109 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

We need to document this. Bonus points if you can add a word or two about why the order is ${name}.${namespace} (DNS-like) and not ${namespace}.${name} (qualifier-like) .

Done.


pkg/inject/sidecar_test.go, line 77 at r1 (raw file):

Previously, jpkrohling (Juraci Paixão Kröhling) wrote…

We should document this as well: the namespace isn't used at all when app is present.

Added some comments - but it isn't related to namespace or app - if the deployment includes an explicit env var for JAEGER_SERVICE_NAME, then that value will be used.

Signed-off-by: Gary Brown <gary@brownuk.com>
@objectiser objectiser changed the title WIP: Enable JAEGER_SERVICE_NAME and JAEGER_PROPAGATION env vars to be set … Enable JAEGER_SERVICE_NAME and JAEGER_PROPAGATION env vars to be set … Nov 26, 2018
Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

I ran the tests against this PR and it was clear:

ok  	github.com/jaegertracing/jaeger-operator/test/e2e	177.028s

Perhaps your minikube is having some troubles? For the record, here's how I run it:

minikube start --vm-driver kvm2 --cpus 2 --memory 8192

Reviewed 2 of 2 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved


pkg/inject/sidecar.go, line 109 at r1 (raw file):

Previously, objectiser (Gary Brown) wrote…

Done.

Sorry, I meant to document this for the end user. This might be too technical for the readme, so, perhaps we just need to open an issue to remember to document it in the future.

Question: do you think we need a flag to disable this feature? The reasoning being that applications might set their service names if there's no env var, which won't be the case with this change if the deployment has the app annotation.

@objectiser
Copy link
Contributor Author

Created #130 for the doc issue.

How realistic do you think that use case would be? If a service developer took that approach, not sure where they would get the service name from, except a custom config property - in which case, they would probably just use that approach anyway, instead of the Jaeger env vars?

@jpkrohling
Copy link
Contributor

How realistic do you think that use case would be?

Good question. Let's record it and see if there's demand for that.

@jpkrohling jpkrohling merged commit 08b45de into jaegertracing:master Nov 27, 2018
@objectiser objectiser deleted the injectenv branch January 29, 2019 12:36
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.

2 participants