Skip to content

Commit

Permalink
add concurrent_http.go
Browse files Browse the repository at this point in the history
  • Loading branch information
tandysun committed Nov 7, 2023
1 parent f2e1f58 commit cf1a0fe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
5 changes: 1 addition & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import (
"strings"
"time"

"github.com/opentracing/opentracing-go"

"github.com/uber/jaeger-client-go"
"github.com/uber/jaeger-client-go/internal/baggage/remote"
throttler "github.com/uber/jaeger-client-go/internal/throttler/remote"
"github.com/uber/jaeger-client-go/rpcmetrics"
Expand Down Expand Up @@ -406,7 +403,7 @@ func (rc *ReporterConfig) newTransport() (jaeger.Transport, error) {
if rc.User != "" && rc.Password != "" {
httpOptions = append(httpOptions, transport.HTTPBasicAuth(rc.User, rc.Password))
}
return transport.NewHTTPTransport(rc.CollectorEndpoint, httpOptions...), nil
return transport.NewConcurrentHttpTransport(transport.NewHTTPTransport(rc.CollectorEndpoint, httpOptions...)), nil
default:
return jaeger.NewUDPTransport(rc.LocalAgentHostPort, 0)
}
Expand Down
29 changes: 29 additions & 0 deletions transport/concurrent_http.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package transport

import (
j "github.com/uber/jaeger-client-go/thrift-gen/jaeger"
)

type ConcurrentHttpTransport struct {
*HTTPTransport
pool chan int
}

func NewConcurrentHttpTransport(httpTransport *HTTPTransport) *ConcurrentHttpTransport {
ctp := &ConcurrentHttpTransport{
HTTPTransport: httpTransport,
}
ctp.pool = make(chan int, 100)
for i := 0; i < 100; i++ {
ctp.pool <- 0
}
return ctp
}

func (c *ConcurrentHttpTransport) send(spans []*j.Span) error {
<-c.pool
defer func() {
c.pool <- 0
}()
return c.HTTPTransport.send(spans)
}

0 comments on commit cf1a0fe

Please sign in to comment.