forked from openzipkin/brave
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removes expectation a setter can clear a key (openzipkin#506)
I made a mistake documenting Propagation.Setter as being able to clear a key. This is not guaranteed to work, for example you can't clear headers made with URLConnection, only replace or add to them. Instead, this documents that in reusable carriers, you must clear keys on your own. If carriers are single-shot, there's no need to clear anything first.
- Loading branch information
1 parent
c4f98bd
commit 937987e
Showing
10 changed files
with
61 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 26 additions & 26 deletions
52
instrumentation/kafka-clients/src/main/java/brave/kafka/clients/KafkaPropagation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
package brave.kafka.clients; | ||
|
||
import brave.propagation.Propagation.Getter; | ||
import brave.propagation.Propagation.Setter; | ||
import java.nio.charset.Charset; | ||
import org.apache.kafka.common.header.Header; | ||
import org.apache.kafka.common.header.Headers; | ||
|
||
final class KafkaPropagation { | ||
|
||
static final Charset UTF_8 = Charset.forName("UTF-8"); | ||
|
||
static final Setter<Headers, String> HEADER_SETTER = (carrier, key, value) -> { | ||
carrier.remove(key); | ||
if (value != null) carrier.add(key, value.getBytes(UTF_8)); | ||
}; | ||
|
||
static final Getter<Headers, String> HEADER_GETTER = (carrier, key) -> { | ||
Header header = carrier.lastHeader(key); | ||
if (header == null) return null; | ||
return new String(header.value(), UTF_8); | ||
}; | ||
|
||
KafkaPropagation() { | ||
} | ||
} | ||
package brave.kafka.clients; | ||
|
||
import brave.propagation.Propagation.Getter; | ||
import brave.propagation.Propagation.Setter; | ||
import java.nio.charset.Charset; | ||
import org.apache.kafka.common.header.Header; | ||
import org.apache.kafka.common.header.Headers; | ||
|
||
final class KafkaPropagation { | ||
|
||
static final Charset UTF_8 = Charset.forName("UTF-8"); | ||
|
||
static final Setter<Headers, String> HEADER_SETTER = (carrier, key, value) -> { | ||
carrier.remove(key); | ||
carrier.add(key, value.getBytes(UTF_8)); | ||
}; | ||
|
||
static final Getter<Headers, String> HEADER_GETTER = (carrier, key) -> { | ||
Header header = carrier.lastHeader(key); | ||
if (header == null) return null; | ||
return new String(header.value(), UTF_8); | ||
}; | ||
|
||
KafkaPropagation() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters