Open uralsemih opened 2 years ago
Node should automatically lower case header (https://nodejs.org/dist/latest-v16.x/docs/api/http.html#messageheaders) thats why we use lower case. The kafka instrumentation should instead lower case incoming headers i think
To be honest, it is hard to define for me which is a better approach but when I checked b3-propagation seems they're expecting uppercase rather than lowercase.
HTTP header keys are case insensitive (RFC 2616 4.2 Message Headers), that's why Node.js is converting all incoming HTTP header keys to lower case.
For B3 propagation in other transports, I find that there is a note about the preference of case sentitivity in their document:
https://github.com/openzipkin/b3-propagation#multiple-headers Note: Http headers are case-insensitive, but sometimes this encoding is used for other transports. When encoding in case-sensitive transports, prefer lowercase keys or the single header encoding which is explicitly lowercase.
If I read that correctly, lowercase keys are still the preferred way.
Seems like this is inconsistent across techs. Java doesn't use lowercase keys..
I think the OTel spec should clarify here to avoid interoperability issues like this.
There is also a difference between "prefer lowercase keys" and "ignore non-lowercase keys". It could be interpreted to prefer the lowercase version if there is a collision.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This issue was closed because it has been stale for 14 days with no activity.
Encountered a similar issue, do we have any updates later?
Can confirm this causes split traces. Could this get a never stale tag?
Hi everyone, I don't know if this could be helpful for someone, but I fixed it like this: Basically, I created a wrapper around B3Propagator and then I simply lowercased the carrier's keys.
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { Context, TextMapGetter } from '@opentelemetry/api';
export class LowerCaseB3Propagator extends B3Propagator {
public extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {
return super.extract(context, this.toLowerCase(carrier), getter);
}
private toLowerCase(carrier: any): any {
if (carrier === undefined || carrier === null) return carrier;
return Object.keys(carrier).reduce((result: any, field: string) => {
const value = carrier[field];
if (value !== undefined) {
result[field.toLowerCase()] = value;
}
return result;
}, {});
}
}
What happened?
Hello,
I have a Java service(producer) and Nodejs service(consumer) where they are connecting to Kafka. Java service sends a JSON object to Kafka and Node.js service consumes it and saves it to the database.
I am using b3-propagators multi and when I made a comparison to traces between services I am aware that the Kafka one has a different one where it breaks the traces.If you check the consumer message and java the traces are same which is 2721916b8dbb8e1d58d6d269a10b056d where Kafka one 2273c5c3fe7cd6edc27f3c3c8366ab7e..
Seems the root cause of this issue is case sensitivity where b3 propagator searching for headers with lowercase which is not according to spec.
Can someone have a look at this, please?
opentelemetry/propagator-b3
opentelemetry/opentelemetry-java
OpenTelemetry Setup Code
package.json
Relevant log output