| 1 | // Copyright The OpenTelemetry Authors |
| 2 | // SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| 4 | package xconfighttp // import "go.opentelemetry.io/collector/config/confighttp/xconfighttp" |
| 5 | |
| 6 | import ( |
| 7 | "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" |
| 8 | |
| 9 | "go.opentelemetry.io/collector/config/confighttp" |
| 10 | "go.opentelemetry.io/collector/config/confighttp/internal" |
| 11 | ) |
| 12 | |
| 13 | // WithOtelHTTPOptions allows providing (or overriding) options passed |
| 14 | // to the otelhttp.NewHandler() function. |
| 15 | // |
| 16 | // This is located in the experimental sub-package because the otelhttp library |
| 17 | // has not reached v1.x yet and exposing its types in confighttp public API |
| 18 | // could lead to breaking changes in the future. |
| 19 | // See https://github.com/open-telemetry/opentelemetry-collector/pull/11769 |
| 20 | func WithOtelHTTPOptions(httpopts ...otelhttp.Option) confighttp.ToServerOption { |
| 21 | return internal.ToServerOptionFunc(func(opts *internal.ToServerOptions) { |
| 22 | opts.OtelhttpOpts = append(opts.OtelhttpOpts, httpopts...) |
| 23 | }) |
| 24 | } |