Home > Blockchain >  Problem with export open telemetry data to newRelic
Problem with export open telemetry data to newRelic

Time:11-30

I have an issue with exporting and sending the open telemetry data to the newRelic's GRPC endpoint. This is my snippet code that tries to connect to the newRelic endpoint:

var headers = map[string]string{
    "api-key": "my newRelc API key",
}

var clientOpts = []otlptracegrpc.Option{
    otlptracegrpc.WithEndpoint("https://otlp.nr-data.net:4317"),
    otlptracegrpc.WithInsecure(),
    otlptracegrpc.WithReconnectionPeriod(2 * time.Second),
    otlptracegrpc.WithDialOption(grpc.WithBlock()),
    otlptracegrpc.WithTimeout(30 * time.Second),
    otlptracegrpc.WithHeaders(headers),
    otlptracegrpc.WithCompressor("gzip"),
}

otlpExporter, err := otlptrace.New(ctx, otlptracegrpc.NewClient(clientOpts...))
if err != nil {
    return nil, fmt.Errorf("creating OTLP trace exporter: %w", err)
}

resource, _ := g.Config.resource(ctx)
tracerProvider := trace.NewTracerProvider(
    trace.WithSampler(trace.AlwaysSample()),
    trace.WithBatcher(otlpExporter),
    trace.WithResource(resource),
)

otel.SetTracerProvider(tracerProvider)

it stuck in step otlptrace.New.

I'm new in OpenTelemetry, I read the open telemetry documentation and I can print Otel data in the console but when I want to export it to newrelic it does not work. I read newRelic Otel documentation too and they had an exporter SDK but it discontinued and they provide this new GRPC endpoint but it does not have well documentation and example. Do you have any idea?

CodePudding user response:

I found the problem, The issue was about TLS. I replaced this line:

otlptracegrpc.WithInsecure(),

with this line:

otlptracegrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, "")),
  • Related