Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Add support to the server.Queryer to query against a service's name. #27

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

AmandaCameron
Copy link

No description provided.

@AmandaCameron
Copy link
Author

It's worth noting that this may have some unexpected results. Namely, if A-svc calls B-svc, and you're expecting a search for B-svc to show that call from A-svc, this will not be the case. This can probably be done with a better Postgres query, however calls to B-svc will show up if you search A-svc.

I'm not familiar with zipkin at all, so I'm not sure if this is proper behaviour, just something I felt I should note for completeness.

@dominikh
Copy link
Member

I think it should return all traces that involve the service, not just traces that originate from the service.

@AmandaCameron
Copy link
Author

I'll be honest, I'm not entirely sure how that could be done, my SQL-fu isn't that good.

@AmandaCameron
Copy link
Author

@dominikh did some stabbing around with my live setup, the latest commit appears to be doing the job.

Only issue is now there's an issue with the generated protos being out of date for the latest grpc, but I don't see a way to generate the files locally, and I've got my own custom arcane voodoo for generation myself.

@@ -378,6 +385,7 @@ WHERE
(? = '' OR operation_name = ?) AND
DURATION(time) >= ? AND
DURATION(time) <= ? AND
EXISTS ( SELECT 1 FROM spans AS sub_spans WHERE sub_spans.trace_id = spans.trace_id AND sub_spans.service_name IN (` + strings.Join(serviceConds, ", ") + `)) AND
Copy link
Member

Choose a reason for hiding this comment

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

What happens if no ServiceNames were provided and serviceConds is empty? Is an empty IN valid and does it match?

Copy link
Author

Choose a reason for hiding this comment

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

The zipkin ui does not appear to allow searching with no service name, so I feel this is a moot point for now.

Copy link
Member

Choose a reason for hiding this comment

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

The API allows it; and even if the contract didn't, we do not want to generate invalid SQL on a possible code path. We should either support it, or detect and reject it.

The PostgreSQL documentation documents IN as expression IN (value [, ...]), which would suggest that an empty IN is not valid.

@@ -137,6 +137,8 @@ type Query struct {
OrTags []QueryTag
// How many traces to return. Zero means no limit.
Num int
// ServiceName to filter by.
Copy link

Choose a reason for hiding this comment

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

Nitpick, but did you mean to write "// ServiceNames to filter by." here? Since the variable is called ServiceNames. Or was the removal of "s" intentional?

@AmandaCameron
Copy link
Author

Commit 2d4a394 addresses the comments by @shurcooL and @dominikh -- let me know if there's anything else.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants