github.com/pinpoint-apm/pinpoint-go-agent@v1.4.1-0.20240110120318-a50c2eb18c8c/doc/troubleshooting.md (about)

     1  # Troubleshooting
     2  
     3  ## Disable the Agent
     4  If the agent causes disruptions or problems to a production application, you can disable the agent.
     5  
     6  ### Config option
     7  You can disable the agent by setting config option '**Enable**' to false.
     8  Restart your application with command flag '--pinpoint-enable=false' or environment variable 'PINPOINT_GO_ENABLE=false'.
     9  For more information, Refer the [Configuration](config.md#Enable) document.
    10  
    11  ### Shutdown function
    12  You can stop the agent by calling Agent.Shutdown() function, and there’s no need to restart your application.
    13  After Agent.Shutdown() is called, the agent will never collect tracing data again.
    14  If you want to restart a agent, you can just create a new agent using the NewAgent() function,
    15  there’s no need to restart your application as well.
    16  
    17  As in the example below, you can write code to start and stop the agent whenever you want without.
    18  ``` go
    19  func newAgent(w http.ResponseWriter, r *http.Request) {
    20      opts := []pinpoint.ConfigOption{
    21          pinpoint.WithConfigFile(os.Getenv("HOME") + "/tmp/pinpoint-config.yaml"),
    22      }
    23      c, _ := pinpoint.NewConfig(opts...)
    24      _, err := pinpoint.NewAgent(c)
    25      if err == nil {
    26          io.WriteString(w, "New Pinpoint Go Agent - success")
    27      } else {
    28          io.WriteString(w, "New Pinpoint Go Agent - fail")
    29      } 	
    30  }
    31  
    32  func shutdown(w http.ResponseWriter, r *http.Request) {
    33      pinpoint.GetAgent().Shutdown()
    34      io.WriteString(w, "Shutdown Pinpoint Go Agent")
    35  }
    36  
    37  func main() {
    38      ...
    39      
    40      http.HandleFunc("/newagent", newAgent)
    41      http.HandleFunc("/shutdown", shutdown)
    42      http.HandleFunc("/handler", pphttp.WrapHandlerFunc(handler))
    43      http.ListenAndServe(":8000", r)
    44  }
    45  ```
    46  
    47  ## Logging
    48  
    49  Pinpoint Go Agent outputs logs related to agent operation (config, gRPC, goroutine, ...) to **stderr**.
    50  This logs are helpful to the debugging process.
    51  
    52  You can use config option **LogLevel** to increase the granularity of the agent’s logging.
    53  For more information, Refer the [Configuration](config.md#LogLevel) document.