Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

fix(*) zipkin span fields #52

Merged
merged 8 commits into from Nov 5, 2019
Merged

fix(*) zipkin span fields #52

merged 8 commits into from Nov 5, 2019

Conversation

kikito
Copy link
Member

@kikito kikito commented Oct 25, 2019

Fixes #49

It is highly recommended to review this PR commit-by-commit, but notice that github's UI does not list them in the appropriate order.

The initial commits (on git log, not on github's UI) deal with the fact that the current specs were not included on the CI environment (only the linter was called) and they were run in a non-standard way (i.e. Kong was run in production mode, not in test mode).

The feat commits detail the new changes:

  • The Opentracing component tag is renamed to lc for zipkin
  • Empty tags are not sent to zipkin
  • The spans have also been restructured:
    • Request span is the parent, proxy span is for kong internal processing, balancer span(s) for balancer tries.
    • The balancer spans are now children of the request span instead of the proxy span, and they always contain the error tag, set to true or false.
    • The Kong phases were previously encoded as individual spans. Now they have been converted into Opentracing logs / Zipkin annotations inside the request span and proxy span.
  • The spans for http traffic have been renamed:
    • GET http://host:port for the request span
    • GET http://host:port (proxy) for the proxy span
    • GET http://host:port (balancer try n) for each balancer try

All these changes are tested on the last commit.

README.md Outdated
- `kong.preread`, `start` / `finish`, `<timestamp>`
- `kong.header_filter`, `start` / `finish`, `<timestamp>`
- `kong.body_filter`, `start` / `finish`, `<timestamp>`
- `kong.try_[n]`, `start` / `finish`, `<timestamp>`

Choose a reason for hiding this comment

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

the try_n annotation is a nice thing for the top-level span, but each load balancer try should be a sub-span with a different span ID, as you don't want to repeat the same span ID in multiple places. each LB try is a different http request, in other words. Also the tag encoding will affect search in a bad way whereas kong.try_1 will not.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the feedback, I have reverted everything involving the try_[n] tags. Each load balancer try is a new span.

README.md Outdated
- `kong.balancer.try`
- `kong.balancer.state`: see [here](https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/balancer.md#get_last_failure) for possible values
- `kong.balancer.code`
- `kong.try_[n].ipv4`

Choose a reason for hiding this comment

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

all of this should become a child span with kind=CLIENT

assuming there is always at least one http "try", each of these subspans should be a CLIENT span and the parent span should not. The encoding done here will make search unusable, but that's not the only reason subspans should be used. This style also breaks dependency graph linking

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 did as requested. Notice that previously the load balancer spans were children of the proxy span, which was of kind=CLIENT. I have made them children of the request span now, which is the only span of kind "not CLIENT" (it is a SERVER span).

@codefromthecrypt
Copy link

I also tried to find an example of where a parent span added a "tryN" annotation.. I thought google did that in one of their cloud SDKs, but either it was deleted, or I can't find it.

Most typically, a simple parent span for logical in-process work, and a separate child span per attempt is all instrumentation do. This allows graph processing, which never looks at logs/annotations, to understand the success/error properties of in ingress->egress flow.

While up to you, I think the cleanest change would be to unfold the LB tries into sub-spans, with normal tag names, especially "error" and "http.status_code" etc. and the rest looks good.

@kikito kikito force-pushed the fix/zipkin-span-fields branch 2 times, most recently from 7dfd9e4 to 7b55528 Compare October 30, 2019 16:09
This makes several changes in the tests in order to run them from
Travis-CI as well as making them more similar to Kong tests for
other plugins.

* The tests for the deprecated API objects have been eliminated
* The `TIMEOUT` variable was increased to avoid certain flakyness in
  some tests
* Kong's `spec.helpers` have been used to start/stop kong
* Kong's db is initialized using `helpers.get_db_utils`
* The initial service, routes and plugins are created via blueprints
* Replace ; by , for delimiting table items
* Add vertical spacing between functions
* Fix some horizontal spacing issues due to removing tabs
Previously, each kong phase had a span. This changes them to logs
(annotations in zipkin) with start and finish timestamps inside the
proxy span and the request span.

Each balancer try still is represented by a span, but these spans
are now children of the request span instead of the proxy span.
Their tags have been slightly modified too: `error` is now always
present, and set to `true` or `false`.

The span names for http traffic have been changed to:

* `GET http://host:port` for the request span
* `GET http://host:port (proxy)` for the proxy span
* `GET http://host:port (balancer try n)` for each balancer try span
This change exercises the changes included in the previous commits:

* Three types of spans: request, proxy & balancer
* Kong phases are now encoded as annotations instead of sub-spans
* Empty tags aren't sent
* The component tag is renamed `lc`
* The request name of http requests is like `GET http://host:port`

Incidentally it creates an extra test for a situation which was not
tested for at all in the past (error mode behavior was only tested
in the context of the traceId tags).
@kikito
Copy link
Member Author

kikito commented Oct 31, 2019

@adriancole did as requested, and also added a more extensive description on the PR. Thanks for the review!

@codefromthecrypt
Copy link

I think overall this is positive. thanks!

@kikito kikito merged commit f67e495 into master Nov 5, 2019
@kikito kikito deleted the fix/zipkin-span-fields branch November 5, 2019 20:41
component = "kong",
["span.kind"] = "server",
["http.method"] = method,
["http.url"] = url,
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I am late for this. We usually don't record http.url, instead we record http.path because url can leak some private information like tokens or api-key. I can open a PR for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi, we haven't released a new official version of the plugin yet, so there's still time for this. If you feel confident, please open a PR. If not, I will give it a try.

local request_span = tracer:start_span("kong.request", {
child_of = wire_context;

local request_span = tracer:start_span(method .. " " .. url, {
Copy link
Contributor

Choose a reason for hiding this comment

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

Another one: calling a span name GET /something/123abc is a high cardinality source. In http servers we use GET /something/{id} but since kong is an api-gateway it is maybe easier to call it just GET.

Copy link
Member Author

Choose a reason for hiding this comment

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

Gotcha, will do. Thanks!

kikito added a commit that referenced this pull request Nov 6, 2019
We name spans for http traffic `GET` instead of `GET http://foo.bar/baz` in order to avoid high cardinality.

See #52 (review)
@kikito
Copy link
Member Author

kikito commented Nov 6, 2019

Hi @jcchavezs both changes are done in #57

@jcchavezs
Copy link
Contributor

jcchavezs commented Nov 6, 2019 via email

kikito added a commit that referenced this pull request Nov 7, 2019
We name spans for http traffic `GET` instead of `GET http://foo.bar/baz` in order to avoid high cardinality.

See #52 (review)
kikito added a commit that referenced this pull request Nov 7, 2019
We name spans for http traffic `GET` instead of `GET http://foo.bar/baz` in order to avoid high cardinality.

See #52 (review)
gszr pushed a commit to Kong/kong that referenced this pull request Oct 27, 2021
We name spans for http traffic `GET` instead of `GET http://foo.bar/baz` in order to avoid high cardinality.

See Kong/kong-plugin-zipkin#52 (review)
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.

Numerous data problems
4 participants