otel-cli icon indicating copy to clipboard operation
otel-cli copied to clipboard

OTEL_EXPORTER_OTLP_ENDPOINT not support endpoints prefixed by the http(s) schema

Open v1v opened this issue 4 years ago • 1 comments

otel-cli doesn't honour the spec of OTEL_EXPORTER_OTLP_ENDPOINT not supporting endpoints prefixed by the http(s) scheme"

IIUC, that's the specification in https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options

The endpoint MUST be a valid URL with scheme (http or https) and host, MAY contain a port, SHOULD contain a path and MUST NOT contain other parts

I don't know whether this is something specifically for this implementation or the OpenTelemetry SDK, please forgive me if this is not the right place to track this.

What's the problem I see?

First of all, I started an OTEL exporter docker container locally (otel/opentelemetry-collector-contrib-dev:latest)

Then I ran the below commands, you can see the stdout

$ otel-cli exec --insecure true --service my-service --endpoint http://localhost:52796 --name "curl google" curl https://google.com
2021/11/10 14:41:04 context deadline exceeded
# trace id: 6b695385c7f24a272d7db2e0c1c25ebd
#  span id: 11bb5ff1199c6969
TRACEPARENT=00-6b695385c7f24a272d7db2e0c1c25ebd-11bb5ff1199c6969-01

$ otel-cli exec --insecure true --service my-service --endpoint localhost:52796 --name "curl google" --tp-print curl https://google.com 
# trace id: 55a8d22db9cde3e3209975b6ff95be6d
#  span id: ea84d6216356c36f
TRACEPARENT=00-55a8d22db9cde3e3209975b6ff95be6d-ea84d6216356c36f-01

I even tried with the latest 1.1.0 version for the opentelemetry dependencies. But with the same result.

diff --git a/go.mod b/go.mod
index 6a2f0a4..e704450 100644
--- a/go.mod
+++ b/go.mod
@@ -8,11 +8,11 @@ require (
 	github.com/pterm/pterm v0.12.30
 	github.com/spf13/cobra v1.1.3
 	github.com/spf13/viper v1.7.0
-	go.opentelemetry.io/otel v1.0.1
-	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.1
-	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.0.1
-	go.opentelemetry.io/otel/sdk v1.0.1
-	go.opentelemetry.io/otel/trace v1.0.1
+	go.opentelemetry.io/otel v1.1.0
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.1.0
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.1.0
+	go.opentelemetry.io/otel/sdk v1.1.0
+	go.opentelemetry.io/otel/trace v1.1.0
 	go.opentelemetry.io/proto/otlp v0.9.0
 	google.golang.org/grpc v1.41.0
 )
diff --git a/go.sum b/go.sum
index 78a34d3..6dbe29b 100644
$ ./otel-cli exec --insecure true --verbose --service my-service --endpoint localhost:52796 --tp-print  --name "curl google" curl https://google.com
# trace id: 7aca7397428bd39ad3e5de1edde04e23
#  span id: 61b1ed8a81521817
TRACEPARENT=00-7aca7397428bd39ad3e5de1edde04e23-61b1ed8a81521817-01
$ ./otel-cli exec --insecure true --verbose --service my-service --endpoint http://localhost:52796 --tp-print  --name "curl google" curl https://google.com
2021/11/10 14:43:08 OpenTelemetry error: Post "http://localhost:52796/v1/traces": net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x00\x00\x06\x04\x00\x00\x00\x00\x00\x00\x05\x00\x00@\x00"
# trace id: 9aa5c361cee147841a31e0ee482d4bd5
#  span id: 88ed6fd2d5ae9227
TRACEPARENT=00-9aa5c361cee147841a31e0ee482d4bd5-88ed6fd2d5ae9227-01

If I use the apm-server I get a similar output:

$ ./otel-cli exec --insecure true --verbose --service my-service --endpoint localhost:8200 --tp-print  --name "curl google" curl https://google.com       
# trace id: a32dd3e7edfdc10873590d0b1f024ae8
#  span id: 8784904498afb15f
TRACEPARENT=00-a32dd3e7edfdc10873590d0b1f024ae8-8784904498afb15f-01
$ ./otel-cli exec --insecure true --verbose --service my-service --endpoint http://localhost:8200 --tp-print  --name "curl google" curl https://google.com
2021/11/10 14:45:00 OpenTelemetry error: failed to send traces to http://localhost:8200/v1/traces: 404 Not Found
# trace id: e86a7945462b1ca24fc5f5256be0f974
#  span id: 55f5768a2ca2a0bc
TRACEPARENT=00-e86a7945462b1ca24fc5f5256be0f974-55f5768a2ca2a0bc-01
$ curl http://0.0.0.0:8200
{
  "build_date": "2021-08-26T07:58:20Z",
  "build_sha": "3c59d845c4aaa8eee86b3c3d83442d649482198c",
  "version": "7.14.1"
}

Please let me know if you need further details. I'll try to run a few more validations in my end to discard any misconfiguration.

Thanks

v1v avatar Nov 10 '21 14:11 v1v

Good catch, I'm gonna spend a little time on otel-cli soon and will dig into this.

I guess it's time to add TLS options to the test suite...

tobert avatar Nov 17 '21 15:11 tobert

I understand this better now after working on #138. If you have a chance please take a look at the README changes in there and lmk if they help clarify. I think the OTel spec went the wrong way here, and for clarity otel-cli is going to have to diverge a bit since there's no deterministic way to tell if an http/https URL is intended for gRPC or actuall http/protobuf. So otel-cli will only allow http for http and adds grpc:// for grpc in addition to sending bare strings to gRPC/OTLP.

tobert avatar Jan 24 '23 16:01 tobert

v0.1.0 is released. HTTP support is all good now. There could still be some issues with HTTPS because it's not tested directly yet. That's my main task for v0.1.1 and definitely required before I will release a 1.0.

https://github.com/equinix-labs/otel-cli/releases/tag/v0.1.0

tobert avatar Feb 02 '23 16:02 tobert