/** Returns the value of the field with the specified key or null if not available */ public static String get(TraceContext context, String name, Class<? extends PropagationFields> type) { if (context == null) throw new NullPointerException("context == null"); if (name == null) throw new NullPointerException("name == null"); PropagationFields fields = context.findExtra(type); return fields != null ? fields.get(name) : null; }
/** Replaces the value of the field with the specified key, ignoring if not a permitted field */ public static void put(TraceContext context, String name, String value, Class<? extends PropagationFields> type) { if (context == null) throw new NullPointerException("context == null"); if (name == null) throw new NullPointerException("name == null"); if (value == null) throw new NullPointerException("value == null"); PropagationFields fields = context.findExtra(type); if (fields == null) return; fields.put(name, value); } }
@Override protected void consolidate(P existing, P consolidated) { consolidated.putAllIfAbsent(existing); }
@Override public String toString() { return getClass().getSimpleName() + toMap(); }
@Override protected boolean tryToClaim(P existing, long traceId, long spanId) { return existing.tryToClaim(traceId, spanId); }
/** Returns a mapping of any fields in the trace context. */ public static Map<String, String> getAll(TraceContext context) { if (context == null) throw new NullPointerException("context == null"); PropagationFields fields = context.findExtra(Extra.class); return fields != null ? fields.toMap() : Collections.emptyMap(); }
@Override protected P createExtraAndClaim(long traceId, long spanId) { P result = create(); result.tryToClaim(traceId, spanId); return result; }
/** Returns a mapping of any fields in the extraction result. */ public static Map<String, String> getAll(TraceContextOrSamplingFlags extracted) { if (extracted == null) throw new NullPointerException("extracted == null"); TraceContext extractedContext = extracted.context(); if (extractedContext != null) return getAll(extractedContext); PropagationFields fields = TraceContext.findExtra(Extra.class, extracted.extra()); return fields != null ? fields.toMap() : Collections.emptyMap(); }
@Override protected P createExtraAndClaim(P existing, long traceId, long spanId) { P result = create(existing); result.tryToClaim(traceId, spanId); return result; }
/** Returns the value of the field with the specified key or null if not available */ @Nullable public static String get(TraceContext context, String name) { return PropagationFields.get(context, lowercase(name), Extra.class); }
/** Sets the value of the field with the specified key, or drops if not a configured field */ public static void set(TraceContext context, String name, String value) { PropagationFields.put(context, lowercase(name), value, Extra.class); }
@Override protected void consolidate(P existing, P consolidated) { consolidated.putAllIfAbsent(existing); }
@Override public String toString() { return getClass().getSimpleName() + toMap(); }
@Override protected boolean tryToClaim(P existing, long traceId, long spanId) { return existing.tryToClaim(traceId, spanId); }
/** Returns the value of the field with the specified key or null if not available */ public static String get(TraceContext context, String name, Class<? extends PropagationFields> type) { if (context == null) throw new NullPointerException("context == null"); if (name == null) throw new NullPointerException("name == null"); PropagationFields fields = context.findExtra(type); return fields != null ? fields.get(name) : null; }
/** Replaces the value of the field with the specified key, ignoring if not a permitted field */ public static void put(TraceContext context, String name, String value, Class<? extends PropagationFields> type) { if (context == null) throw new NullPointerException("context == null"); if (name == null) throw new NullPointerException("name == null"); if (value == null) throw new NullPointerException("value == null"); PropagationFields fields = context.findExtra(type); if (fields == null) return; fields.put(name, value); } }
/** Returns a mapping of any fields in the trace context. */ public static Map<String, String> getAll(TraceContext context) { if (context == null) throw new NullPointerException("context == null"); PropagationFields fields = context.findExtra(Extra.class); return fields != null ? fields.toMap() : Collections.emptyMap(); }
@Override protected P createExtraAndClaim(long traceId, long spanId) { P result = create(); result.tryToClaim(traceId, spanId); return result; }
/** Returns the value of the field with the specified key or null if not available */ @Nullable public static String get(TraceContext context, String name) { return PropagationFields.get(context, lowercase(name), Extra.class); }
/** Sets the value of the field with the specified key, or drops if not a configured field */ public static void set(TraceContext context, String name, String value) { PropagationFields.put(context, lowercase(name), value, Extra.class); }