Closed fasdalf closed 6 months ago
Hey @fasdalf π Fair take, I was waiting for a ticket like this π Sure, OTEL specific variables might be defined via env variables and this FR is approved by default π Let me think of how to implement this w/o extra third-party libraries (I mean env/v6).
Hey @fasdalf π Remember, that you may use the following well-known syntax, e.g.:
otel:
# other options
endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://collector:4318}
In this case, if the OTEL_EXPORTER_OTLP_ENDPOINT
env variable is not set, default http://collector:4318
value for the endpoint
would be used.
otel: # other options endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://collector:4318}
Thank you, @rustatian! I gave it a try and it worked! Is it suitable to add this variables, especially OTEL_SERVICE_NAME, to config examples shipped with the Roadrunner?
Cool π₯³ Yeah, I also forgot that RR supports Bash parameter expansion syntax. It would be cool if you document your configuration experience here: link π
Hey, I've finalized the configuration and noticed one thing that sounds more like an issue.
if I am passing this variable to Roadrunner (e.g. via docker-compose)
OTEL_EXPORTER_OTLP_ENDPOINT: http://collector:4318
It is working with PHP OTEL like a charm. Whenever I enable otel for RR (with GRPC, not sure if http reproducible), it starts to complain
| 2024/02/12 15:01:27 traces export: parse "http://http:%2F%2Fcollector:4318/v1/traces": invalid URL escape "%2F"
notice that double "http://".
If I do not add http://
in URL => PHP version doesn't work as it tries to connect to https (default)
This leads to the situation that the hostname has to be configured without http://
in the configuration, like this:
OTEL_EXPORTER_OTLP_ENDPOINT: collector:4318
and on the PHP side I had to do some dirty trick
$otelHost = 'http://'.getenv('OTEL_EXPORTER_OTLP_ENDPOINT');
putenv("OTEL_EXPORTER_OTLP_ENDPOINT=$otelHost");
Besides that, works like a charm with collector/zipkin and/or datadog π₯³
Plugin
GRPC
I have an idea!
Hello! Opentelemerty plugin reads config from .rr.yaml as other plugins do. Also specification defines environment variables https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/ and https://opentelemetry.io/docs/specs/otel/protocol/exporter/ to read default opentelemetry values from. Roadrunner 2023 already uses library https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc#pkg-overview with support of this variables but over writes them with hardcoded defaults: c.Resource.ServiceNamespaceKey = fmt.Sprintf("RoadRunner-%s", uuid.NewString()) sdktrace.WithResource(newResource(p.cfg.Resource, cfg.RRVersion())),
Could you restore use of this environment variables as defaults if no values are set in .rr.yaml and use hardcoded strings only when both configurations are empty?
Variables tested to be effective with otel v.1.21.1
Here is an example of code using these variables with
InitFromEnvironment()