Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

[Bug]: config.Configuration.InitGlobalTracer panics if http.DefaultTransport is not a *http.Transport #616

Open
colega opened this issue Dec 18, 2023 · 0 comments
Labels

Comments

@colega
Copy link

colega commented Dec 18, 2023

What happened?

I called config.Configuration.InitGlobalTracer(...) after replacing the http.DefaultTransport with a custom implementation, and it panicked.

The code assumes that http.DefaultTransport is a *http.Transport, and panics otherwise:

customTransport := http.DefaultTransport.(*http.Transport).Clone()

Steps to reproduce

  1. Replace http.DefaultTransport value in your app.
  2. Call config.Configuration.InitGlobalTracer()

Example: https://go.dev/play/p/TH-uFyyMuLD

package main

import (
	"fmt"
	"net/http"

	"github.com/uber/jaeger-client-go/config"
)

func main() {
	http.DefaultTransport = &customTransport{&http.Transport{}}
	closer, err := config.Configuration{}.InitGlobalTracer("hello-world")
	if err != nil {
		panic(fmt.Errorf("failed: %w", err))
	}
	defer closer.Close()

	fmt.Println("Hello, 世界")
}

type customTransport struct {
	next http.RoundTripper
}

func (ct *customTransport) RoundTrip(req *http.Request) (*http.Response, error) {
	return ct.next.RoundTrip(req)
}

Expected behavior

It shouldn't panic.

Relevant log output

No response

Screenshot

No response

Additional context

No response

Jaeger backend version

No response

SDK

No response

Pipeline

No response

Stogage backend

No response

Operating system

No response

Deployment model

No response

Deployment configs

No response

@colega colega added the bug label Dec 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant