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

feat(tracing): Add instana header support in propagation #13915

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

Conversation

SuzyWangIBMer
Copy link
Contributor

@SuzyWangIBMer SuzyWangIBMer commented Nov 23, 2024

Summary

Checklist

  • The Pull Request has tests
  • A changelog file has been created under changelog/unreleased/kong or skip-changelog label added on PR if changelog is unnecessary. README.md
  • There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

Issue reference

Fix #12494

@SuzyWangIBMer SuzyWangIBMer marked this pull request as ready for review November 25, 2024 20:37
@team-eng-enablement team-eng-enablement added the author/community PRs from the open-source community (not Kong Inc) label Nov 25, 2024
@samugi samugi self-requested a review November 26, 2024 18:02
Copy link
Member

@samugi samugi left a comment

Choose a reason for hiding this comment

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

Thank you so much for this great contribution! A couple of notes:

  • For consistency, this should be supported by the Zipkin plugin as well, which requires a small schema update similar to what was done for OpenTelemetry in this PR, and an integration test in spec/03-plugins/34-zipkin/zipkin_spec.lua.
  • The test in spec/01-unit/26-observability/02-propagation_strategies_spec.lua should be updated as well to include this new header format

@samugi
Copy link
Member

samugi commented Dec 17, 2024

In addition to my previous comment, this needs a rebase.


trace_id = from_hex(trace_id_raw) or nil
span_id = from_hex(span_id_raw) or nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated trace_id, span_id, level_id variable name to trace_id_raw, span_id_raw and level_id_raw

Also since we dont use correlation_type and correlationId here, changed

level_id_raw = level_id_raw:match("^([0-1])$") 
              or level_id_raw:match("^([0-1]),correlationType=(.-);correlationId=(.*)")

to

  level_id_raw = level_id_raw:match("^([0-1])$") 
                or level_id_raw:match("^([0-1]).")

@SuzyWangIBMer SuzyWangIBMer force-pushed the feat/instana_headers branch 2 times, most recently from b21ca04 to e26f7ca Compare January 9, 2025 19:45
@SuzyWangIBMer SuzyWangIBMer requested a review from samugi January 9, 2025 20:40
Copy link
Member

@samugi samugi left a comment

Choose a reason for hiding this comment

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

Left a few comments.

Please also address my comments from the previous review:

  • For consistency, this should be supported by the Zipkin plugin as well, which requires a small schema update similar to what was done for OpenTelemetry in this PR, and an integration test in spec/03-plugins/34-zipkin/zipkin_spec.lua

  • The test in spec/01-unit/26-observability/02-propagation_strategies_spec.lua should be updated as well to include this new header format

Comment on lines 45 to 46
local trace_id = from_hex(trace_id_raw) or nil
local span_id = from_hex(span_id_raw) or nil
Copy link
Member

Choose a reason for hiding this comment

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

let's add a nil check:

Suggested change
local trace_id = from_hex(trace_id_raw) or nil
local span_id = from_hex(span_id_raw) or nil
local trace_id = trace_id_raw and from_hex(trace_id_raw) or nil
local span_id = span_id_raw and from_hex(span_id_raw) or nil

Comment on lines 17 to 19
local trace_id_raw = headers["x-instana-t"]
local span_id_raw = headers["x-instana-s"]
local level_id_raw = headers["x-instana-l"]
Copy link
Member

Choose a reason for hiding this comment

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

the value of headers["name"] can be a string or a table, depending on whether the same header was passed more than once in the request, see: https://github.com/openresty/lua-nginx-module?tab=readme-ov-file#ngxreqget_headers

We should handle the scenario where multiple headers are passed, for example by ignoring the header if passed more than once, or grabbing the first value.

Comment on lines 40 to 41
level_id_raw = level_id_raw:match("^([0-1])$")
or level_id_raw:match("^([0-1]).")
Copy link
Member

Choose a reason for hiding this comment

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

could we just:

Suggested change
level_id_raw = level_id_raw:match("^([0-1])$")
or level_id_raw:match("^([0-1]).")
level_id_raw = level_id_raw:sub(1, 1)

level_id_raw = level_id_raw:match("^([0-1])$")
or level_id_raw:match("^([0-1]).")
end
local should_sample = level_id_raw or "1"
Copy link
Member

Choose a reason for hiding this comment

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

this must be type boolean, see here

Suggested change
local should_sample = level_id_raw or "1"
local should_sample = level_id_raw == "1"

@SuzyWangIBMer SuzyWangIBMer force-pushed the feat/instana_headers branch 7 times, most recently from d79c73a to 834a15d Compare January 18, 2025 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author/community PRs from the open-source community (not Kong Inc) cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee core/tracing plugins/opentelemetry schema-change-noteworthy size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OTEL plugin sends incoming W3C tracestate and Instana tracing HTTP headers out as received
3 participants