Skip to content

Commit

Permalink
updated readme, set http client timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
morus12 committed Sep 26, 2023
1 parent b16140a commit 7e25759
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Added

- Add the new `go.opentelemetry.io/contrib/instrgen` package to provide auto-generated source code instrumentation. (#3068, #3108)
- Add `WithSamplingStrategyFetcher` which sets custom fetcher implementation. (#4045)

### Fixed

- Fixed panic when default HTTP round-tripper is not `*http.Transport` (#4045)

## [1.18.0/0.43.0/0.12.0] - 2023-08-28

Expand All @@ -19,7 +24,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Add `NewMiddleware` function in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp`. (#2964)
- The `go.opentelemetry.io/contrib/exporters/autoexport` package to provide configuration of trace exporters with useful defaults and environment variable support. (#2753, #4100, #4130, #4132, #4134)
- `WithRouteTag` in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` adds HTTP route attribute to metrics. (#615)
- Add `WithSamplingStrategyFetcher` which sets custom fetcher implementation. Fixed panic when default HTTP round-tripper is not `*http.Transport` (#4045)

- Add `WithSpanOptions` option in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`. (#3768)
- Add testing support for Go 1.21. (#4233)

Expand Down
16 changes: 4 additions & 12 deletions samplers/jaegerremote/sampler_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,20 +273,12 @@ type httpSamplingStrategyFetcher struct {
}

func newHTTPSamplingStrategyFetcher(serverURL string) *httpSamplingStrategyFetcher {
fetcher := &httpSamplingStrategyFetcher{
return &httpSamplingStrategyFetcher{
serverURL: serverURL,
httpClient: http.Client{
Timeout: defaultRemoteSamplingTimeout,
},
}

if customTransport, ok := http.DefaultTransport.(*http.Transport); ok {
customTransport = customTransport.Clone()
customTransport.ResponseHeaderTimeout = defaultRemoteSamplingTimeout

fetcher.httpClient = http.Client{
Transport: customTransport.Clone(),
}
}

return fetcher
}

func (f *httpSamplingStrategyFetcher) Fetch(serviceName string) ([]byte, error) {
Expand Down
5 changes: 1 addition & 4 deletions samplers/jaegerremote/sampler_remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,7 @@ func TestSamplingStrategyParserImpl_Error(t *testing.T) {

func TestDefaultSamplingStrategyFetcher_Timeout(t *testing.T) {
fetcher := newHTTPSamplingStrategyFetcher("")

customTransport, ok := fetcher.httpClient.Transport.(*http.Transport)
require.True(t, ok)
assert.Equal(t, defaultRemoteSamplingTimeout, customTransport.ResponseHeaderTimeout)
assert.Equal(t, defaultRemoteSamplingTimeout, fetcher.httpClient.Timeout)
}

func TestDefaultSamplingStrategyFetcher_NoPanic(t *testing.T) {
Expand Down

0 comments on commit 7e25759

Please sign in to comment.