From 281796fae27af4772ab818f914310e812b4719be Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Date: Wed, 23 Jun 2021 09:46:19 +0200 Subject: [PATCH] Add OTLP HTPP exporter support --- CHANGELOG.md | 2 ++ docs/configuration-reference.md | 4 ++++ pkg/tempo/config.go | 14 ++++++++++++- pkg/tempo/config_test.go | 37 +++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db867e0a3db2..1689c3c9087a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ - [FEATURE] Add TLS config options for tempo `remote_write`s. (@mapno) +- [FEATURE] Add support for OTLP HTTP trace exporting. (@mapno) + - [ENHANCEMENT] The Grafana Agent Operator will now default to deploying the matching release version of the Grafana Agent instead of v0.14.0. (@rfratto) diff --git a/docs/configuration-reference.md b/docs/configuration-reference.md index 3a45f5125f51..dadf68de62dd 100644 --- a/docs/configuration-reference.md +++ b/docs/configuration-reference.md @@ -2038,6 +2038,10 @@ remote_write: # Controls whether compression is enabled. [ compression: | default = "gzip" | supported = "none", "gzip"] + + # Controls what protocol to use when exporting traces. + # Only "grpc" is supported in Grafana Cloud. + [ protocol: | default = "grpc" | supported = "grpc", "http" ] # Controls whether or not TLS is required. See https://godoc.org/google.golang.org/grpc#WithInsecure [ insecure: | default = false ] diff --git a/pkg/tempo/config.go b/pkg/tempo/config.go index 76e60576814e..85678de0b06c 100644 --- a/pkg/tempo/config.go +++ b/pkg/tempo/config.go @@ -23,6 +23,7 @@ import ( "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/config/configmodels" "go.opentelemetry.io/collector/exporter/otlpexporter" + "go.opentelemetry.io/collector/exporter/otlphttpexporter" "go.opentelemetry.io/collector/exporter/prometheusexporter" "go.opentelemetry.io/collector/processor/attributesprocessor" "go.opentelemetry.io/collector/processor/batchprocessor" @@ -137,6 +138,8 @@ type InstanceConfig struct { const ( compressionNone = "none" compressionGzip = "gzip" + protocolGRPC = "grpc" + protocolHTTP = "http" ) // DefaultPushConfig holds the default settings for a PushConfig. @@ -174,12 +177,14 @@ func (c *PushConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { // DefaultRemoteWriteConfig holds the default settings for a PushConfig. var DefaultRemoteWriteConfig = RemoteWriteConfig{ Compression: compressionGzip, + Protocol: protocolGRPC, } // RemoteWriteConfig controls the configuration of an exporter type RemoteWriteConfig struct { Endpoint string `yaml:"endpoint,omitempty"` Compression string `yaml:"compression,omitempty"` + Protocol string `yaml:"protocol,omitempty"` Insecure bool `yaml:"insecure,omitempty"` // Deprecated InsecureSkipVerify bool `yaml:"insecure_skip_verify,omitempty"` @@ -341,7 +346,13 @@ func (c *InstanceConfig) exporters() (map[string]interface{}, error) { if err != nil { return nil, err } - exporterName := fmt.Sprintf("otlp/%d", i) + var exporterName string + switch remoteWriteConfig.Protocol { + case protocolGRPC: + exporterName = fmt.Sprintf("otlp/%d", i) + case protocolHTTP: + exporterName = fmt.Sprintf("otlphttp/%d", i) + } exporters[exporterName] = exporter } return exporters, nil @@ -637,6 +648,7 @@ func tracingFactories() (component.Factories, error) { exporters, err := component.MakeExporterFactoryMap( otlpexporter.NewFactory(), + otlphttpexporter.NewFactory(), loadbalancingexporter.NewFactory(), prometheusexporter.NewFactory(), remotewriteexporter.NewFactory(), diff --git a/pkg/tempo/config_test.go b/pkg/tempo/config_test.go index 3851a7645341..a80c79e3fe4f 100644 --- a/pkg/tempo/config_test.go +++ b/pkg/tempo/config_test.go @@ -736,6 +736,43 @@ service: exporters: ["otlp/0"] processors: [] receivers: ["jaeger"] +`, + }, + { + name: "otlp http & grpc exporters", + cfg: ` +receivers: + jaeger: + protocols: + grpc: +remote_write: + - endpoint: example.com:12345 + protocol: http + - endpoint: example.com:12345 + protocol: grpc +`, + expectedConfig: ` +receivers: + jaeger: + protocols: + grpc: +exporters: + otlphttp/0: + endpoint: example.com:12345 + compression: gzip + retry_on_failure: + max_elapsed_time: 60s + otlp/1: + endpoint: example.com:12345 + compression: gzip + retry_on_failure: + max_elapsed_time: 60s +service: + pipelines: + traces: + exporters: ["otlphttp/0", "otlp/1"] + processors: [] + receivers: ["jaeger"] `, }, }