GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Don't copy transient views no reader needs · DataDog/dd-trace-java@76b5f3d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • dd-trace-core/src/main/java/datadog/trace/core/propagation
    • ContextInterpreter.java
    • InferredProxyPropagator.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎dd-trace-core/src/main/java/datadog/trace/core/propagation/ContextInterpreter.java‎

Copy file name to clipboardExpand all lines: dd-trace-core/src/main/java/datadog/trace/core/propagation/ContextInterpreter.java
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,34 @@ public boolean accept(HeaderSchema header, String key, String value) {
206206
return acceptUnclassified(key, value);
207207
}
208208

209+
/**
210+
* {@link #acceptTransient} for a style that doesn't parse views itself: a parse-only header that
211+
* isn't the style's own (another style's id header) is skipped, without copying the view, unless
212+
* the configuration names it (a request header tag, a baggage mapping, the client IP header),
213+
* since the shared handling reads nothing else of it. Anything else is copied and accepted.
214+
*/
215+
@Override
216+
public boolean acceptTransient(HeaderSchema header, String key, CharSequence value) {
217+
if (header != null
218+
&& !LOG_EXTRACT_HEADER_NAMES
219+
&& header.isParseOnly()
220+
&& classify(header) == NOT_OWN_HEADER
221+
&& !isConfiguredFor(key)) {
222+
return true;
223+
}
224+
return accept(header, key, value == null ? null : value.toString());
225+
}
226+
227+
/**
228+
* Whether the configuration names {@code key}: a request header tag, mapped baggage, client IP.
229+
*/
230+
private boolean isConfiguredFor(String key) {
231+
String lowerCaseKey = toLowerCase(key);
232+
return headerTags.containsKey(lowerCaseKey)
233+
|| baggageMapping.containsKey(lowerCaseKey)
234+
|| (customIpHeaderName != null && customIpHeaderName.equalsIgnoreCase(key));
235+
}
236+
209237
/**
210238
* How this style handles {@code header}: one of its own classifications (non-negative, for {@link
211239
* #acceptClassified}), {@link #NOT_OWN_HEADER} for a header it doesn't read itself, or {@link
Collapse file

‎dd-trace-core/src/main/java/datadog/trace/core/propagation/InferredProxyPropagator.java‎

Copy file name to clipboardExpand all lines: dd-trace-core/src/main/java/datadog/trace/core/propagation/InferredProxyPropagator.java
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import datadog.context.propagation.CarrierKeys;
77
import datadog.context.propagation.CarrierSetter;
88
import datadog.context.propagation.CarrierVisitor;
9+
import datadog.context.propagation.IndexedCarrier;
910
import datadog.context.propagation.Propagator;
1011
import datadog.trace.api.gateway.InferredProxySpan;
1112
import java.util.HashMap;
@@ -35,7 +36,17 @@ public <C> Context extract(Context context, C carrier, CarrierVisitor<C> visitor
3536
return context;
3637
}
3738
InferredProxyContextExtractor extractor = new InferredProxyContextExtractor();
38-
visitor.forEachKeyValue(carrier, extractor);
39+
if (carrier instanceof IndexedCarrier) {
40+
// a known header never has the proxy prefix, so only keys without a constant are read
41+
IndexedCarrier indexed = (IndexedCarrier) carrier;
42+
for (int i = 0, n = indexed.size(); i < n; i++) {
43+
if (indexed.header(i) == null) {
44+
extractor.accept(indexed.key(i), indexed.value(i));
45+
}
46+
}
47+
} else {
48+
visitor.forEachKeyValue(carrier, extractor);
49+
}
3950
InferredProxySpan inferredProxySpan = extractor.inferredProxySpan();
4051
if (inferredProxySpan != null) {
4152
context = context.with(inferredProxySpan);

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.