forked from open-policy-agent/opa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tracing: make otel dependency optional for rego+topdown (open-policy-…
…agent#4127) This follows the same approach as the wasm feature: by default, importers of github.com/open-policy-agent/opa/rego github.com/open-policy-agent/opa/topdown will not get a transitive dependency on the otel libraries. In terms of functionality, nothing changes for the server and runtime. Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
- Loading branch information
Showing
17 changed files
with
252 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2021 The OPA Authors. All rights reserved. | ||
// Use of this source code is governed by an Apache2 | ||
// license that can be found in the LICENSE file. | ||
|
||
package tracing | ||
|
||
import ( | ||
"net/http" | ||
|
||
pkg_tracing "github.com/open-policy-agent/opa/tracing" | ||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" | ||
) | ||
|
||
func init() { | ||
pkg_tracing.RegisterHTTPTracing(&factory{}) | ||
} | ||
|
||
type factory struct{} | ||
|
||
func (*factory) NewTransport(tr http.RoundTripper, opts pkg_tracing.Options) http.RoundTripper { | ||
return otelhttp.NewTransport(tr, convertOpts(opts)...) | ||
} | ||
|
||
func (*factory) NewHandler(f http.Handler, label string, opts pkg_tracing.Options) http.Handler { | ||
return otelhttp.NewHandler(f, label, convertOpts(opts)...) | ||
} | ||
|
||
func convertOpts(opts pkg_tracing.Options) []otelhttp.Option { | ||
otelOpts := make([]otelhttp.Option, 0, len(opts)) | ||
for _, opt := range opts { | ||
otelOpts = append(otelOpts, opt.(otelhttp.Option)) | ||
} | ||
return otelOpts | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.