newrelic / newrelic-telemetry-sdk-go

Go library for sending telemetry data to New Relic
Apache License 2.0
42 stars 30 forks source link

Add better logging for first-time users #40

Open RichVanderwal opened 3 years ago

RichVanderwal commented 3 years ago

When a customer starts using the New Relic Telemetry SDK for Go, they'll probably want to see the harvest loop running in the debug log. Since this library is used as part of a larger system, the log lines written should identify it as coming from this library for easier and quicker troubleshooting.

  1. Add a logDebug call to the harvest cycle, perhaps in the HarvestNow function, that prints a line and the number of requests it's sending. A good place to do this might be here. https://github.com/newrelic/newrelic-telemetry-sdk-go/blob/master/telemetry/harvester.go#L392 Something like this would do the job:
    h.config.logDebug(map[string]interface{}{
        "message": "OpenTelemetry SDK harvest cycle transmitting " + strconv.Itoa(len(reqs)) + "requests",
    })
  1. Come up with a good string to prefix every line of logging that this library produces to identify it as the New Relic Telemetry SDK for Go.
jodeev commented 3 years ago

Also somewhat related, on the exporter side: https://github.com/newrelic/opentelemetry-exporter-go/issues/39

totomz commented 2 years ago

I'm in the same situation (just started using this library and trying to understand why the metrics are not in newrelic)

Not sure if this has been merged after this issue, but it is possible to log library events:

nrel, err := telemetry.NewHarvester(
    telemetry.ConfigAPIKey(nrKey),
    telemetry.ConfigBasicDebugLogger(os.Stdout),
    telemetry.ConfigBasicErrorLogger(os.Stdout),
)