Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[open-telemetry/transport-grpc] Endpoint has to contain scheme, host and path #1157

Open
mrnavrc opened this issue Dec 7, 2023 · 5 comments
Labels
bug Something isn't working stale This issue didn't have recent activity

Comments

@mrnavrc
Copy link

mrnavrc commented Dec 7, 2023

If I use the gRPC protocol in conjunction with Jaeger (direct export without collector), according to the documentation it should be enough to use the address without path (https://opentelemetry.io/docs/instrumentation/php/exporters/).
However, without path it will not pass the validation in grpcTransportFactory:
if (substr_count($parts['path'], '/') !== 2) { throw new InvalidArgumentException(sprintf('Endpoint path is not a valid GRPC method "%s"', $method)); }
On the other hand, when I add path to the address, it fails on the fact that it doesn't know the service name. However the service for Jaeger should be created automatically.

My env settings:
OTEL_PHP_AUTOLOAD_ENABLED=true OTEL_TRACES_EXPORTER=otlp OTEL_METRICS_EXPORTER=none OTEL_LOGS_EXPORTER=none OTEL_EXPORTER_OTLP_PROTOCOL=grpc OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="http://jaeger:14250" OTEL_PROPAGATORS=baggage,tracecontext

@mrnavrc mrnavrc added the bug Something isn't working label Dec 7, 2023
@mrnavrc mrnavrc changed the title gRCP protocol: Endpoint has to contain scheme, host and path [open-telemetry/transport-grpc] Endpoint has to contain scheme, host and path Dec 7, 2023
@brettmc
Copy link
Collaborator

brettmc commented Dec 7, 2023

You are using OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, which per spec is used unchanged, so you'll need to append a path of /opentelemetry.proto.collector.trace.v1.TraceService/Export. Alternatively, try switching to the OTEL_EXPORTER_OTLP_ENDPOINT var with your current value.

What path did you add to the address when it complained about service name? I'm using the collector rather than straight to jaeger, but it looks happy with this value: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://collector:4317/opentelemetry.proto.collector.trace.v1.TraceService/Export

@mrnavrc
Copy link
Author

mrnavrc commented Dec 8, 2023

Thank you, the path you mentioned works. It wasn't exactly clear to me from the documentation how to set up the path.
I am closing this issue as it is not a bug.

@mrnavrc mrnavrc closed this as completed Dec 8, 2023
@mrnavrc
Copy link
Author

mrnavrc commented Dec 8, 2023

@brettmc However, I'm still confused about this, I'm now testing the implementation directly with the collector:

env:

OTEL_PHP_AUTOLOAD_ENABLED=true
OTEL_TRACES_EXPORTER=otlp
OTEL_EXPORTER_OTLP_PROTOCOL=grpc
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel-collector:4317/opentelemetry.proto.collector.trace.v1.TraceService/Export
OTEL_PROPAGATORS=baggage,tracecontext

OTEL config:

receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317

processors:

exporters:
prometheus:
endpoint: 0.0.0.0:55680
namespace: default
zipkin:
endpoint: http://zipkin:9411/api/v2/spans
service:
pipelines:
traces:
receivers: [otlp]
processors: []
exporters: [zipkin]
metrics:
receivers: [otlp]
processors: []
exporters: [prometheus]

container

otel-collector:
image: otel/opentelemetry-collector-contrib
volumes:

  • ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml
    ports:
  • "55680:55680" # Prometheus
  • "4317:4317" # GRPC

At this setting, it will return to me:

unknown service opentelemetry.proto.collector.trace.v1.TraceService

If, on the other hand, I use a generic endpoint as you suggested, I get:

Error during opentelemetry initialization: Endpoint has to contain scheme, host and path
#0 /app/vendor/open-telemetry/exporter-otlp/SpanExporterFactory.php(56):
OpenTelemetry\Contrib\Grpc\GrpcTransportFactory->create('otel-collector:...', 'application/x-p...', Array, > 'none')

@mrnavrc mrnavrc reopened this Dec 8, 2023
@brettmc
Copy link
Collaborator

brettmc commented Dec 9, 2023

If, on the other hand, I use a generic endpoint as you suggested

To use the generic endpoint, you must put it in the OTEL_EXPORTER_OTLP_ENDPOINT variable, then a factory will take care of appending the path for each signal. Is that what you're doing?

unknown service opentelemetry.proto.collector.trace.v1.TraceService

This is an interesting error. AFAICT, it means that a successful grpc connection was made (ie, to otel-collector:4317), but the endpoint is not known to the service. I've seen that before with people trying to send signals to a backend that doesn't understand or has not implemented it (eg trying to send logs or metrics to jaeger), but the collector understands all of the signals...
Is anything interesting logged by the collector?

Copy link

stale bot commented Mar 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale This issue didn't have recent activity label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale This issue didn't have recent activity
Projects
None yet
Development

No branches or pull requests

2 participants