newrelic / opentelemetry-exporter-go

New Relic's Golang OpenTelemetry Exporter
Apache License 2.0
29 stars 28 forks source link

Cannot find the metrics from the simple example in New Relic One #58

Closed jason-magnetic-io closed 3 years ago

jason-magnetic-io commented 3 years ago

I am trying to implement OpenTelemetry using the exporter but cannot find the metrics in NR1.

I'm using the simple example https://github.com/newrelic/opentelemetry-exporter-go/blob/master/examples/simple/main.go

I had to modify the code a little as I'm using the EU data centre and the NewExporter itself doesn't read the environment variables the way the NewExportPipeline does.

(I've noticed in the blog posts and in the code examples there is little or no mention of the EU data centre and the need to modify code, etc.)

    metricsURL, ok := os.LookupEnv("NEW_RELIC_METRIC_URL")
    if !ok {
        fmt.Println("Missing NEW_RELIC_METRIC_URL required for New Relic OpenTelemetry Exporter")
        os.Exit(1)
    }
    tracesURL, ok := os.LookupEnv("NEW_RELIC_TRACE_URL")
    if !ok {
        fmt.Println("Missing NEW_RELIC_TRACE_URL required for New Relic OpenTelemetry Exporter")
        os.Exit(1)
    }
    exporter, err := newrelic.NewExporter(
        "Simple OpenTelemetry Service",
        apiKey,
        telemetry.ConfigBasicErrorLogger(os.Stderr),
        telemetry.ConfigBasicDebugLogger(os.Stderr),
        telemetry.ConfigBasicAuditLogger(os.Stderr),
        telemetry.ConfigSpansURLOverride(tracesURL),
        func(cfg *telemetry.Config) {
            cfg.MetricsURLOverride = metricsURL
        },
    )

The logging appears to show the example metrics and trace data being sent to NR1 successfully

2021/02/05 14:25:10.082945 {"api-key":"NRII-...","event":"harvester created","events-url-override":"","harvest-period-seconds":5,"metrics-url-override":"https://metric-api.eu.newrelic.com/metric/v1","spans-url-override":"https://trace-api.eu.newrelic.com/trace/v1","version":"0.2.0"}
2021/02/05 14:25:10.084548 {"body-length":268,"event":"data post","url":"https://metric-api.eu.newrelic.com/metric/v1"}
2021/02/05 14:25:10.084595 {"data":[{"common":{"timestamp":1612531510082,"interval.ms":0},"metrics":[{"name":"ex.com.one","type":"gauge","value":1,"timestamp":1612531510083,"attributes":{"C":"3","ex.com/lemons":10,"description":"A ValueObserver set to 1.0","instrumentation.provider":"opentelemetry","collector.name":"newrelic-opentelemetry-exporter","service.name":"Simple OpenTelemetry Service","A":"1","B":"2"}}]}],"event":"uncompressed request body","url":"https://metric-api.eu.newrelic.com/metric/v1"}
2021/02/05 14:25:10.484315 {"body":{"requestId":"e5420614-0001-b000-0000-0177725e2cc5"},"event":"data post response","status":202}
2021/02/05 14:25:10.484403 {"body-length":337,"event":"data post","url":"https://trace-api.eu.newrelic.com/trace/v1"}
2021/02/05 14:25:10.484512 {"data":[{"common":{},"spans":[{"id":"0e58001e53592a63","trace.id":"302f9b8633b71a0466005c23f6794e3a","timestamp":1612531510083,"attributes":{"name":"Sub operation...","parent.id":"6f42b4ea75989b15","duration.ms":0.002442,"service.name":"Simple OpenTelemetry Service","instrumentation.provider":"opentelemetry","collector.name":"newrelic-opentelemetry-exporter","ex.com/lemons":"five","span.kind":"internal"}},{"id":"6f42b4ea75989b15","trace.id":"302f9b8633b71a0466005c23f6794e3a","timestamp":1612531510083,"attributes":{"name":"operation","duration.ms":0.027327,"service.name":"Simple OpenTelemetry Service","ex.com/another":"yes","span.kind":"internal","instrumentation.provider":"opentelemetry","collector.name":"newrelic-opentelemetry-exporter"}}]}],"event":"uncompressed request body","url":"https://trace-api.eu.newrelic.com/trace/v1"}
2021/02/05 14:25:10.694570 {"body":{"requestId":"17bf1804-0001-b000-0000-0177725e2d95"},"event":"data post response","status":202}

I can see the "Simple OpenTelemetry Service" entity in the NR1 explorer but when I click on the Metrics explorer it tells me that "You're not collecting metric data".

Screenshot 2021-02-05 at 16 02 44
rvanderwal-newrelic commented 3 years ago

Hi @jason-magnetic-io,

Thanks for writing in! First, I’ll forward a note about the lack of documentation for the EU data center to our Product Manager, and perhaps put an easy line into our quick start guide.

Regarding metrics, you’ve stumbled on one of the rougher spots in the UI as we migrate to OpenTelemetry, and as the OpenTelemetry organization changes the specs for how metrics are delivered. For now, you’ll have much better luck if you follow the steps in the “To see metric data” section of the Getting Started guide.

Let us know if you have any other questions or comments!