diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/field/VirtualField.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/field/VirtualField.java index f9139639d207..7c447a1c98fe 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/field/VirtualField.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/field/VirtualField.java @@ -12,8 +12,9 @@ /** * Represents a "virtual" field of type {@code F} that is added to type {@code T} in the runtime. * - *

Field values are weakly referenced and will be garbage collected when their owner instance is - * collected. + *

A virtual field has similar semantics to a weak-keys strong-values map: the value will be + * garbage collected when their owner instance is collected. It is discouraged to use a virtual + * field for keeping values that might reference their key, as it may cause memory leaks. * * @param The type that will contain the new virtual field. * @param The field type that'll be added to {@code T}. @@ -48,14 +49,14 @@ public static VirtualField find(Class type, Class