Hi,
I am trying to implement OpenTelemetry using https://github.com/newrelic/opentelemetry-exporter-go. Since our account is setup in the EU datacenter, I had to override theSpansURLOverride
to use the .eu
subdomain. I don’t know if this has an impact. Without this the API returned 403 Forbidden
.
I have it set up and everything. When I try to add a trace I get the following logs:
{
"data": [
{
"common": {},
"spans": [
{
"id": "73bda0f20665838d",
"trace.id": "48f44bd474f5833d487960a0ea01edcf",
"timestamp": 1608554828768,
"attributes": {
"name": "login",
"duration.ms": 98.3224,
"service.name": "LOCAL auth",
"span.kind": "internal",
"instrumentation.provider": "opentelemetry",
"collector.name": "newrelic-opentelemetry-exporter"
}
}
]
}
],
"event": "uncompressed request body",
"url": "https://trace-api.eu.newrelic.com/trace/v1"
}
And the API responds with:
{
"body": {
"requestId": "ba1694f9-0001-b000-0000-01768556eed4"
},
"event": "data post response",
"status": 202
}
However, I am still not able to see the traces in the Distributed Tracing
tab of the service.
If I use the https://github.com/newrelic/go-agent package directly using the newrelic.WrapHandleFunc
function, I can see the transaction in the Distributed Tracing
tab.
This is the current attempt at implementing:
exporter, err := newrelic.NewExporter(
cfg.AppName,
cfg.NewRelicInsightsKey,
telemetry.ConfigBasicErrorLogger(os.Stderr),
telemetry.ConfigBasicDebugLogger(os.Stderr),
telemetry.ConfigBasicAuditLogger(os.Stderr),
telemetry.ConfigSpansURLOverride("https://trace-api.eu.newrelic.com/trace/v1"),
)
if err != nil {
fmt.Printf("failed to instantiate New Relic OpenTelemetry exporter: %v\n", err)
}
ctx := context.Background()
defer exporter.Shutdown(ctx)
// Create a tracer provider
bsp := sdktrace.NewBatchSpanProcessor(exporter)
tp := sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(bsp))
defer func() { _ = tp.Shutdown(ctx) }()
// Set global options
otel.SetTracerProvider(tp)
And in our controller we do this:
var span trace.Span
tracer := otel.Tracer("SuperTestLogin")
ctx, span := tracer.Start(req.Context(), "login")
defer span.End()
span.AddEvent("Nice operation!", trace.WithAttributes(label.Int("bogons", 100)))
Thanks!
Best Regards,
Jarl