Skip to content

Commit 78807ee

Browse files
committed
config,crds: unify/simplify OpenTelemetry tracing config.
Simplify OpenTelemetry tracing exporter configuration and unify it with metrics. We only accept "otlp-http" and "otlp-grpc" as exporters. All other configuration of the stock otel exporters can be done using their documented environment variables. Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
1 parent f567805 commit 78807ee

File tree

9 files changed

+50
-54
lines changed

9 files changed

+50
-54
lines changed

config/crd/bases/config.nri_balloonspolicies.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,12 @@ spec:
784784
Endpoints are specified as full URLs, or as plain URL schemes which then
785785
imply scheme-specific defaults. The supported schemes and their default
786786
URLs are:
787-
- otlp-http, http: localhost:4318
788-
- otlp-grpc, grpc: localhost:4317
789-
example: otlp-http://localhost:4318
787+
- otlp-http: use OpenTelemetry HTTP[S] tracing exporter/collector
788+
- otlp-grpc: use OpenTelemetry gRPC tracing exported/collector
789+
enum:
790+
- otlp-http
791+
- otlp-grpc
792+
example: otlp-http
790793
type: string
791794
type: object
792795
loadClasses:

config/crd/bases/config.nri_templatepolicies.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,12 @@ spec:
508508
Endpoints are specified as full URLs, or as plain URL schemes which then
509509
imply scheme-specific defaults. The supported schemes and their default
510510
URLs are:
511-
- otlp-http, http: localhost:4318
512-
- otlp-grpc, grpc: localhost:4317
513-
example: otlp-http://localhost:4318
511+
- otlp-http: use OpenTelemetry HTTP[S] tracing exporter/collector
512+
- otlp-grpc: use OpenTelemetry gRPC tracing exported/collector
513+
enum:
514+
- otlp-http
515+
- otlp-grpc
516+
example: otlp-http
514517
type: string
515518
type: object
516519
log:

config/crd/bases/config.nri_topologyawarepolicies.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,12 @@ spec:
535535
Endpoints are specified as full URLs, or as plain URL schemes which then
536536
imply scheme-specific defaults. The supported schemes and their default
537537
URLs are:
538-
- otlp-http, http: localhost:4318
539-
- otlp-grpc, grpc: localhost:4317
540-
example: otlp-http://localhost:4318
538+
- otlp-http: use OpenTelemetry HTTP[S] tracing exporter/collector
539+
- otlp-grpc: use OpenTelemetry gRPC tracing exported/collector
540+
enum:
541+
- otlp-http
542+
- otlp-grpc
543+
example: otlp-http
541544
type: string
542545
type: object
543546
log:

deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,12 @@ spec:
784784
Endpoints are specified as full URLs, or as plain URL schemes which then
785785
imply scheme-specific defaults. The supported schemes and their default
786786
URLs are:
787-
- otlp-http, http: localhost:4318
788-
- otlp-grpc, grpc: localhost:4317
789-
example: otlp-http://localhost:4318
787+
- otlp-http: use OpenTelemetry HTTP[S] tracing exporter/collector
788+
- otlp-grpc: use OpenTelemetry gRPC tracing exported/collector
789+
enum:
790+
- otlp-http
791+
- otlp-grpc
792+
example: otlp-http
790793
type: string
791794
type: object
792795
loadClasses:

deployment/helm/template/crds/config.nri_templatepolicies.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,12 @@ spec:
508508
Endpoints are specified as full URLs, or as plain URL schemes which then
509509
imply scheme-specific defaults. The supported schemes and their default
510510
URLs are:
511-
- otlp-http, http: localhost:4318
512-
- otlp-grpc, grpc: localhost:4317
513-
example: otlp-http://localhost:4318
511+
- otlp-http: use OpenTelemetry HTTP[S] tracing exporter/collector
512+
- otlp-grpc: use OpenTelemetry gRPC tracing exported/collector
513+
enum:
514+
- otlp-http
515+
- otlp-grpc
516+
example: otlp-http
514517
type: string
515518
type: object
516519
log:

deployment/helm/topology-aware/crds/config.nri_topologyawarepolicies.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,12 @@ spec:
535535
Endpoints are specified as full URLs, or as plain URL schemes which then
536536
imply scheme-specific defaults. The supported schemes and their default
537537
URLs are:
538-
- otlp-http, http: localhost:4318
539-
- otlp-grpc, grpc: localhost:4317
540-
example: otlp-http://localhost:4318
538+
- otlp-http: use OpenTelemetry HTTP[S] tracing exporter/collector
539+
- otlp-grpc: use OpenTelemetry gRPC tracing exported/collector
540+
enum:
541+
- otlp-http
542+
- otlp-grpc
543+
example: otlp-http
541544
type: string
542545
type: object
543546
log:

docs/resource-policy/policy/balloons.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ Balloons policy parameters:
340340
- `samplingRatePerMillion`: the number of samples to collect per million spans.
341341
Example: `100000`
342342
- `tracingCollector`: defines the external endpoint for tracing data collection.
343-
Example: `otlp-http://localhost:4318`.
343+
Example: `otlp-http`.
344344
- `agent`: controls communicating with the Kubernetes node agent and
345345
the API server.
346346
- `nodeResourceTopology`: if `true`, expose balloons as node

pkg/apis/config/v1alpha1/instrumentation/config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ type Config struct {
3030
// Endpoints are specified as full URLs, or as plain URL schemes which then
3131
// imply scheme-specific defaults. The supported schemes and their default
3232
// URLs are:
33-
// - otlp-http, http: localhost:4318
34-
// - otlp-grpc, grpc: localhost:4317
33+
// - otlp-http: use OpenTelemetry HTTP[S] tracing exporter/collector
34+
// - otlp-grpc: use OpenTelemetry gRPC tracing exported/collector
3535
// +optional
36-
// +kubebuilder:example="otlp-http://localhost:4318"
36+
// +kubebuilder:validation:Enum=otlp-http;otlp-grpc
37+
// +kubebuilder:example="otlp-http"
3738
TracingCollector string `json:"tracingCollector,omitempty"`
3839
// MetricsExporter defines which exporter is used to export metrics.
3940
// The supported exporters are:

pkg/instrumentation/tracing/exporter.go

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ package tracing
1717
import (
1818
"context"
1919
"fmt"
20-
"net/url"
2120
"sync"
2221

2322
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
2423
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
2524
sdktrace "go.opentelemetry.io/otel/sdk/trace"
2625
)
2726

27+
const (
28+
httpExporter = "otlp-http"
29+
grpcExporter = "otlp-grpc"
30+
)
31+
2832
var (
2933
_ sdktrace.SpanExporter = (*spanExporter)(nil)
3034
)
@@ -71,44 +75,17 @@ func (e *spanExporter) setEndpoint(endpoint string) error {
7175
defer e.Unlock()
7276

7377
var (
74-
u *url.URL
7578
exp sdktrace.SpanExporter
7679
err error
7780
)
7881

79-
// Notes:
80-
// We allow collector endpoint URLs to be given as a plain scheme-prefix,
81-
// IOW, without a host, port, and path. If only a prefix is given, the
82-
// exporters use defaults defined by the OTLP library. These are:
83-
// - otlp-http, http: localhost:4318
84-
// - otlp-grpc, grpc: localhost:4317
85-
//
86-
8782
switch endpoint {
88-
case "otlp-http", "http", "otlp-grpc", "grpc":
89-
u = &url.URL{Scheme: endpoint}
90-
default:
91-
u, err = url.Parse(endpoint)
92-
if err != nil {
93-
return fmt.Errorf("invalid tracing endpoint %q: %w", endpoint, err)
94-
}
95-
}
96-
97-
switch u.Scheme {
98-
case "otlp-http", "http":
99-
opts := []otlptracehttp.Option{otlptracehttp.WithInsecure()}
100-
if u.Host != "" {
101-
opts = append(opts, otlptracehttp.WithEndpoint(u.Host))
102-
}
103-
exp, err = otlptracehttp.New(context.Background(), opts...)
83+
case httpExporter:
84+
exp, err = otlptracehttp.New(context.Background())
10485
e.exporter = exp
10586
return err
106-
case "otlp-grpc", "grpc":
107-
opts := []otlptracegrpc.Option{otlptracegrpc.WithInsecure()}
108-
if u.Host != "" {
109-
opts = append(opts, otlptracegrpc.WithEndpoint(u.Host))
110-
}
111-
exp, err = otlptracegrpc.New(context.Background(), opts...)
87+
case grpcExporter:
88+
exp, err = otlptracegrpc.New(context.Background())
11289
e.exporter = exp
11390
return err
11491
}

0 commit comments

Comments
 (0)