uber / zanzibar

A build system & configuration system to generate versioned API gateways.
MIT License
464 stars 68 forks source link

Update tracer option as a tracer provider func #910

Closed ChenX1993 closed 1 year ago

ChenX1993 commented 1 year ago

The problem of previous gateway option to provide a tracer and a tracer closer is that when creating the tracer, the service name, logger, metric scope are not available.

This PR update the option to be a tracer provider function and takes the gateway as input so that the service name, logger and metric scope all are available similar to NotFoundHandler - func(*Gateway) http.HandlerFunc.

With this change, now we can provide the tracer like below:

var AppOptions = &zanzibar.Options{
     ...
    TracerProvider: func(g *zanzibar.Gateway) (opentracing.Tracer, io.Closer, error) {
        // actual logic to instantiate the tracer with the service name, logger, scope available in gateway
    }
}