我在將開放遙測資料匯出和發送到 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 端點,但它沒有很好的檔案和示例。你有什么主意嗎?
uj5u.com熱心網友回復:
我發現了問題,問題出在 TLS 上。我替換了這一行:
otlptracegrpc.WithInsecure(),
用這一行:
otlptracegrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, "")),
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/369740.html
