Package 

Class NetworkPlugin

  • All Implemented Interfaces:
    tech.devlens.ProbePlugin

    
    public final class NetworkPlugin
     implements ProbePlugin
                        

    Probe plugin — captures OkHttp network traffic.

    val network = NetworkPlugin()
    
    Probe.install(
        Probe.Builder(this).plugin(network).build()
    )
    
    val client = OkHttpClient.Builder()
        .addInterceptor(network.interceptor())  // add LAST for accurate capture
        .build()

    Pass sanitizers to mask sensitive data before streaming to the CLI. The in-memory buffer always retains the original (unmasked) data.

    val network = NetworkPlugin(
        sanitizers = listOf(SanitizeRule.BEARER_TOKEN, SanitizeRule.EMAIL)
    )
    val recent: List<HttpTransaction> = network.dump(last = 50)
    • Constructor Detail

      • NetworkPlugin

        NetworkPlugin(Long maxBodySize, Integer bufferSize, List<SanitizeRule> sanitizers)
        Parameters:
        maxBodySize - Max request/response body size to capture.
        bufferSize - In-memory ring buffer size (number of transactions).
        sanitizers - Rules applied to mask sensitive fields before sending to CLI.
      • NetworkPlugin

        NetworkPlugin(Long maxBodySize, Integer bufferSize)
        Parameters:
        maxBodySize - Max request/response body size to capture.
        bufferSize - In-memory ring buffer size (number of transactions).
      • NetworkPlugin

        NetworkPlugin(Long maxBodySize)
        Parameters:
        maxBodySize - Max request/response body size to capture.
      • NetworkPlugin

        NetworkPlugin()
    • Method Detail

      • interceptor

         final Interceptor interceptor()

        Returns an OkHttp Interceptor that captures requests through this plugin.

      • dump

         final List<HttpTransaction> dump(Integer last)

        Returns the last last captured transactions from the in-memory ring buffer. Thread-safe. Works even when not connected to CLI.

        Privacy note: returns unmasked data regardless of sanitizers configuration. Do not pass the result to logging frameworks or crash reporters without your own masking.

      • clearBuffer

         final <ERROR CLASS> clearBuffer()

        Clears the in-memory transaction buffer.