Closed sriemer closed 5 months ago
Okay, found a workaround for this issue. :tada: :tada: :tada: :smiley:
First working custom LUA code:
-- Modify the root span
local root_span = kong.tracing.active_span()
-- Use NGINX request API directly
h = ngx.req.get_headers()
local span_id_in = h["x-instana-s"]
local tracestate_in = h["tracestate"]
if span_id_in then
root_span:set_attribute("headers.x-instana-s", span_id_in)
root_span:set_attribute("headers.dropping-x-instana-s", "true")
ngx.req.set_header("x-instana-s", "")
else
root_span:set_attribute("headers.no-x-instana-s", "true")
end
if tracestate_in then
root_span:set_attribute("headers.tracestate", tracestate_in)
root_span:set_attribute("headers.dropping-tracestate", "true")
ngx.req.set_header("tracestate", "")
else
root_span:set_attribute("headers.no-tracestate", "true")
end
My demo uses the declarative YAML config and Kong without database. So I have to put the code into kong.yml
.
Unfortunately, the Kong post-function
method access
does not allow reading a LUA file in there, expects an equals sign '=' and an array in a single line. So I have to inject that code into a single line by:
"
;
envsubst
and an ${OTEL_LUA_CODE}
variablekong.yml.in
part:
plugins:
- name: opentelemetry
config:
endpoint: "http://instana-agent:4318/v1/traces"
resource_attributes:
service.name: "kong-otel-demo"
- name: post-function
config:
access: ["${OTEL_LUA_CODE}"]
So the last remaining things that I'm requesting are:
traceparent
) andThanks in advance.
Hi @sriemer thank you for opening this issue.
X-INSTANA-*
headers are currently not supported by Kong; that's why they are ignored and their content remains unchanged in the request. This is true for any header format that is not yet supported.
The good news is that the tracing headers propagation module has just been reworked to allow more configurability of tracing headers propagation and also to make it easier to add support for new headers. The feature has not been released yet and as of today it is only available in development branches/images. Documentation updates are still WIP but will include examples of tracing headers configurations, we will make sure to cover the points you highlighted.
If you'd like to check out what's changed you can have a look in the master branch:
In order to add support for a new header type so that it can be configured to be extracted
, injected
or cleared
with no need for additional custom Lua code it is enough to add dedicated extractor and injector modules. If you would like to open a Pull Request to add Instana headers support I will be happy to review it. Otherwise, I will take note of this requirement for potential consideration in the future.
Thank you
This issue is marked as stale because it has been open for 14 days with no activity.
Dear contributor,
We are automatically closing this issue because it has not seen any activity for three weeks. We're sorry that your issue could not be resolved. If any new information comes up that could help resolving it, please feel free to reopen it.
Your contribution is greatly appreciated!
Please have a look our pledge to the community for more information.
Sincerely, Your Kong Gateway team
@samugi Thanks so much for that great work. :pray: That will help us a lot. I'll discuss this with our product management and check when we can do the Instana support for this.
Is there an existing issue for this?
Kong version (
$ kong version
)Kong 3.5.0
Current Behavior
Receiving Instana + W3C tracing headers like
Sending out tracing headers like
Next Instana tracer in the chain picks up span ID from
X-INSTANA-S
, fallback:tracestate
in
member, only thentraceparent
. So on the Instana UI it appears as if spans are directly sent from client app to server app without Kong.Expected Behavior
Would be nice to be able to add support for Instana headers or at least filtering out Instana headers and the
tracestate
header.Is that possible with custom LUA code?
Does "customize OTel spans as a developer" (https://docs.konghq.com/hub/kong-inc/opentelemetry/#customize-opentelemetry-spans-as-a-developer) work for this?
So expecting to see just header
traceparent
here with the new span ID:Steps To Reproduce
kong-tracing
-> it is private for now.env
docker-compose build && docker-compose up
ip -s a | grep $(docker inspect $(docker ps | grep kong-tracing_kong | cut -d' ' -f1) | grep "Gateway.*[0-9\.]\+" | grep -o "[0-9\.]\+")
tcpdump
viatcpdump -s 0 -i $BRIDGE_INTERFACE -w kong-tracing-demo.pcap
wireshark
OTel plugin config:
Anything else?
OS: Linux x86_64