Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jaegerremote: Add WithSamplingStrategyFetcher option #4045

Merged
merged 16 commits into from Sep 29, 2023
7 changes: 6 additions & 1 deletion CHANGELOG.md
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)
morus12 marked this conversation as resolved.
Show resolved Hide resolved

### Fixed

- Fixed panic when default HTTP round-tripper is not `*http.Transport` (#4045)
morus12 marked this conversation as resolved.
Show resolved Hide resolved

## [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)

morus12 marked this conversation as resolved.
Show resolved Hide resolved
- 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
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
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