From 7585b46c2ac717ce63f8a611f23b71d2da6f062d Mon Sep 17 00:00:00 2001 From: Alagunto from Portal Date: Sun, 6 Oct 2024 23:14:47 +0200 Subject: [PATCH] allow custom transports for otlp tracing default --- near.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/near.go b/near.go index 8af1f0e..f1764b1 100644 --- a/near.go +++ b/near.go @@ -29,6 +29,23 @@ func NewConnection(nodeURL string) *Connection { return NewConnectionWithTimeout(nodeURL, 0) } +func NewConnectionWithOTLPTracingAndTransport(nodeURL string, timeout time.Duration, transport *http.Transport) *Connection { + return &Connection{ + OTLPEnabled: true, + c: jsonrpc.NewClientWithOpts(nodeURL, &jsonrpc.RPCClientOpts{ + HTTPClient: &http.Client{ + Timeout: timeout, + Transport: otelhttp.NewTransport( + transport, + otelhttp.WithSpanNameFormatter(func(operation string, r *http.Request) string { + return "near-api-go.json-rpc-http" + }), + ), + }, + }), + } +} + func NewConnectionWithOTLPTracing(nodeURL string, timeout time.Duration) *Connection { return &Connection{ OTLPEnabled: true,