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

Add the enable tracing opt-in flag #4685

Merged
merged 2 commits into from
Aug 18, 2023

Conversation

albertteoh
Copy link
Contributor

Which problem is this PR solving?

Resolves #4680

Description of the changes

  • Add an opt-in option --query.enable-tracing to enable tracing for the jaeger-query component.
  • The jaeger all-in-one component does not expose this flag since traces are emitted to port 4317 by default, which all-in-one listens on.

How was this change tested?

# Run jaeger-query component with tracing enabled and verify that the connection errors are appearing in stdout.
$ SPAN_STORAGE_TYPE=memory go run -tags ui ./cmd/query/main.go --query.enable-tracing
...
{"level":"info","ts":1692363754.9049716,"caller":"grpc/clientconn.go:1301","msg":"[core][Channel #1 SubChannel #2] Subchannel Connectivity change to CONNECTING","system":"grpc","grpc_log":true}
{"level":"info","ts":1692363754.9050152,"caller":"grpc/clientconn.go:1414","msg":"[core][Channel #1 SubChannel #2] Subchannel picks a new address \"localhost:4317\" to connect","system":"grpc","grpc_log":true}
{"level":"warn","ts":1692363754.9058733,"caller":"grpc/clientconn.go:1476","msg":"[core][Channel #1 SubChannel #2] grpc: addrConn.createTransport failed to connect to {Addr: \"localhost:4317\", ServerName: \"localhost:4317\", }. Err: connection error: desc = \"transport: Error while dialing: dial tcp 127.0.0.1:4317: connect: connection refused\"","system":"grpc","grpc_log":true}
{"level":"info","ts":1692363754.9067123,"caller":"grpc/clientconn.go:1303","msg":"[core][Channel #1 SubChannel #2] Subchannel Connectivity change to TRANSIENT_FAILURE, last error: connection error: desc = \"transport: Error while dialing: dial tcp 127.0.0.1:4317: connect: connection refused\"","system":"grpc","grpc_log":true}
...

# Run jaeger-query component with tracing disabled and verify that the connection errors no longer appear.
# Of course, we can't see traces in Jaeger UI because there's nothing to receive the traces.
$ SPAN_STORAGE_TYPE=memory go run -tags ui ./cmd/query/main.go

# Start an all-in-one instance just as a quick and dirty way to bring up an in-memory jaeger stack to
# receive traces from jaeger-query
$ make run-all-in-one

# Run jaeger-query as a separate component, listening on different ports to all-in-one to avoid port binding collisions.
$ SPAN_STORAGE_TYPE=memory go run -tags ui ./cmd/query/main.go --query.enable-tracing --query.grpc-server.host-port :17685 --query.http-server.host-port :17686 --admin.http.host-port :17687

# Open localhost:17686 in a browser and refresh a few times to emit traces to jaeger all-in-one.

Confirmed that jaeger-query is visible and contains traces:

Screenshot 2023-08-18 at 11 45 26 pm

Checklist

Signed-off-by: albertteoh <see.kwang.teoh@gmail.com>
@albertteoh albertteoh requested a review from a team as a code owner August 18, 2023 13:46
@codecov
Copy link

codecov bot commented Aug 18, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03% 🎉

Comparison is base (4798446) 97.02% compared to head (615dc07) 97.06%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4685      +/-   ##
==========================================
+ Coverage   97.02%   97.06%   +0.03%     
==========================================
  Files         301      301              
  Lines       17878    17880       +2     
==========================================
+ Hits        17347    17355       +8     
+ Misses        425      421       -4     
+ Partials      106      104       -2     
Flag Coverage Δ
unittests 97.06% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
cmd/query/app/flags.go 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: albertteoh <see.kwang.teoh@gmail.com>
Comment on lines -111 to +115
server, err := app.NewServer(svc.Logger, queryService, metricsQueryService, queryOpts, tm, jtracer)
server, err := app.NewServer(svc.Logger, queryService, metricsQueryService, queryOpts, tm, jt)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to jt to avoid clashing names with the jtracer package.

@@ -88,6 +88,8 @@ func initOTEL(ctx context.Context, svc string) (*sdktrace.TracerProvider, error)
))
})

otel.SetTracerProvider(tracerProvider)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved here so we just set the global tracer in one place, and removes the otel dependencies from the respective files that use them.

I didn't see, or could think of, a use case where we wouldn't want to set the global tracer when instantiating a jtracer.

Let me know if that's not the case.

@yurishkuro yurishkuro merged commit 2119f5f into jaegertracing:main Aug 18, 2023
31 checks passed
@albertteoh albertteoh deleted the add-enable-tracing-opt-in-1 branch August 18, 2023 18:47
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.

[Bug]: jaeger-query connection refused on 4317
2 participants