在将开放的遥测数据导出并发送到newRelic的GRPC端点时,我遇到了问题。这是我的代码片段,试图连接到newRelic端点:
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)
它停留在步骤otlptrace.New.中
我是OpenTelemetry的新手,我阅读了开放的遥测文档,我可以在控制台中打印Otel数据,但是当我想要将它导出到newrelic时,它就不工作了。我也读过newRelic Otel文档,他们有一个导出SDK,但是它停止了,他们提供了这个新的GRPC端点,但是它没有很好的文档和示例。你有什么想法吗?
发布于 2021-11-29 16:55:51
我发现了问题,问题是关于TLS的。我替换了这一行:
otlptracegrpc.WithInsecure(),
用这一行:
otlptracegrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, "")),
https://stackoverflow.com/questions/70110038
复制相似问题