Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.
This repository was 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

@colega

Description

@colega

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions