@Override public TraceContextOrSamplingFlags extract(C carrier) { TraceContextOrSamplingFlags result = delegate.extract(carrier); // always allocate in case fields are added late Extra fields = propagation.factory.extraFactory.create(); for (int i = 0, length = propagation.keys.size(); i < length; i++) { String maybeValue = getter.get(carrier, propagation.keys.get(i)); if (maybeValue == null) continue; fields.put(propagation.factory.keyToField[i], maybeValue); } return result.toBuilder().addExtra(fields).build(); } }
@Override public TraceContext decorate(TraceContext context) { TraceContext result = delegate.decorate(context); return extraFactory.decorate(result); } }
@Override public TraceContextOrSamplingFlags extract(C carrier) { TraceContextOrSamplingFlags result = delegate.extract(carrier); // always allocate in case fields are added late Extra fields = propagation.factory.extraFactory.create(); for (int i = 0, length = propagation.keys.size(); i < length; i++) { String maybeValue = getter.get(carrier, propagation.keys.get(i)); if (maybeValue == null) continue; fields.put(propagation.factory.keyToField[i], maybeValue); } return result.toBuilder().addExtra(fields).build(); } }
Factory(Propagation.Factory delegate, String[] fieldNames, String[] keyNames, int[] keyToField) { this.delegate = delegate; this.keyToField = keyToField; this.fieldNames = fieldNames; this.keyNames = keyNames; this.extraFactory = new ExtraFactory(fieldNames); }
Factory(Propagation.Factory delegate, String[] fieldNames, String[] keyNames, int[] keyToField) { this.delegate = delegate; this.keyToField = keyToField; this.fieldNames = fieldNames; this.keyNames = keyNames; this.extraFactory = new ExtraFactory(fieldNames); }
@Override public TraceContext decorate(TraceContext context) { TraceContext result = delegate.decorate(context); return extraFactory.decorate(result); } }