diff --git a/SampleApp/src/Controller/AwsSdkInstrumentationController.php b/SampleApp/src/Controller/AwsSdkInstrumentationController.php index e7d44a6..8b8b0b7 100644 --- a/SampleApp/src/Controller/AwsSdkInstrumentationController.php +++ b/SampleApp/src/Controller/AwsSdkInstrumentationController.php @@ -68,7 +68,8 @@ public function outgoingHttpCall(): Response If running this sample app locally, set the endpoint to correspond to the endpoint of your collector instance. */ - $transport = (new GrpcTransportFactory())->create('http://otel:4317' . OtlpUtil::method(Signals::TRACE)); + $endpoint = $this->getEndpoint(); + $transport = (new GrpcTransportFactory())->create($endpoint . OtlpUtil::method(Signals::TRACE)); $exporter = new SpanExporter($transport); // Initialize Span Processor, X-Ray ID generator, Tracer Provider, and Propagator @@ -145,7 +146,8 @@ public function awsSdkCall(): Response If running this sample app locally, set the endpoint to correspond to the endpoint of your collector instance. */ - $transport = (new GrpcTransportFactory())->create('http://otel:4317' . OtlpUtil::method(Signals::TRACE)); + $endpoint = $this->getEndpoint(); + $transport = (new GrpcTransportFactory())->create($endpoint . OtlpUtil::method(Signals::TRACE)); $exporter = new SpanExporter($transport); // Initialize Span Processor, X-Ray ID generator, Tracer Provider, and Propagator @@ -215,4 +217,12 @@ public function awsSdkCall(): Response ['traceId' => $traceId] ); } + + private function getEndpoint(): string + { + if (Configuration::has(Variables::OTEL_EXPORTER_OTLP_TRACES_ENDPOINT)) { + return Configuration::getString(Variables::OTEL_EXPORTER_OTLP_TRACES_ENDPOINT); + } + return 'http://0.0.0.0:4317'; + } } \ No newline at end of file