Class ReferenceCollector


  • public class ReferenceCollector
    extends Object
    LinkedHashMap is used for reference map to guarantee a deterministic order of iteration, so that bytecode generated based on it would also be deterministic.

    This class is only called at compile time by the MuzzleCodeGenerationPlugin ByteBuddy plugin.

    • Constructor Detail

      • ReferenceCollector

        public ReferenceCollector​(Predicate<String> libraryInstrumentationPredicate)
      • ReferenceCollector

        public ReferenceCollector​(Predicate<String> libraryInstrumentationPredicate,
                                  ClassLoader resourceLoader)
    • Method Detail

      • collectReferencesFromResource

        public void collectReferencesFromResource​(String resource)
        If passed resource path points to an SPI file (either Java ServiceLoader or AWS SDK ExecutionInterceptor) reads the file and adds every implementation as a reference, traversing the graph of classes until a non-instrumentation (external) class is encountered.
        Parameters:
        resource - path to the resource file, same as in ClassLoader.getResource(String)
        See Also:
        InstrumentationClassPredicate
      • collectReferencesFromAdvice

        public void collectReferencesFromAdvice​(String adviceClassName)
        Traverse a graph of classes starting from adviceClassName and collect all references to both internal (instrumentation) and external classes.

        The graph of classes is traversed until a non-instrumentation (external) class is encountered.

        Parameters:
        adviceClassName - Starting point for generating references.
        See Also:
        InstrumentationClassPredicate
      • getReferences

        public Map<String,​io.opentelemetry.javaagent.extension.muzzle.ClassRef> getReferences()
      • prune

        public void prune()
      • getSortedHelperClasses

        public List<String> getSortedHelperClasses()
      • getContextStoreClasses

        public Map<String,​String> getContextStoreClasses()