Skip to content

Commit

Permalink
allow custom transports for otlp tracing default
Browse files Browse the repository at this point in the history
  • Loading branch information
Alagunto committed Oct 6, 2024
1 parent 59fba63 commit 7585b46
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions near.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7585b46

Please sign in to comment.