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

update quoteservice for php Release Candidate #1114

Merged
merged 7 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ release.

## Unreleased

* update PHP quoteservice to use RC1
([#1114](https://github.com/open-telemetry/opentelemetry-demo/pull/1114))

## 1.5.0

* update trace-based tests to test stream events
Expand Down
35 changes: 18 additions & 17 deletions src/quoteservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@
# SPDX-License-Identifier: Apache-2.0


FROM composer:2.5 AS build
FROM php:8.2-cli as base

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions \
&& install-php-extensions \
opcache \
pcntl \
protobuf \
opentelemetry

WORKDIR /var/www
CMD php public/index.php
USER www-data
EXPOSE ${QUOTE_SERVICE_PORT}

FROM composer:2.6 AS vendor

WORKDIR /tmp/
COPY ./src/quoteservice/composer.json .
Expand All @@ -15,21 +30,7 @@ RUN composer install \
--no-dev \
--prefer-dist

FROM php:8.2-cli

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions \
&& install-php-extensions \
opcache \
pcntl \
protobuf \
opentelemetry-beta

WORKDIR /var/www
COPY --from=build /tmp/vendor/ ./vendor/
FROM base as final
COPY --from=vendor /tmp/vendor/ ./vendor/
COPY ./src/quoteservice/ /var/www

CMD php public/index.php

USER www-data
EXPOSE ${QUOTE_SERVICE_PORT}
18 changes: 18 additions & 0 deletions src/quoteservice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,21 @@ In order to get traffic into the service you have to deploy
the whole opentelemetry-demo.

Please follow the root README to do so.

## Development

To build and run the quote service locally:

```sh
docker build src/quoteservice --target base -t quoteservice
cd src/quoteservice
docker run --rm -it -v $(pwd):/var/www -e QUOTE_SERVICE_PORT=8999 -p "8999:8999" quoteservice
```

Then, send some curl requests:

```sh
curl --location 'http://localhost:8999/getquote' \
--header 'Content-Type: application/json' \
--data '{"numberOfItems":3}'
```
2 changes: 1 addition & 1 deletion src/quoteservice/app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@



use OpenTelemetry\API\Common\Instrumentation\Globals;
use OpenTelemetry\API\Globals;
use OpenTelemetry\API\Trace\Span;
use OpenTelemetry\API\Trace\SpanKind;
use Psr\Http\Message\ResponseInterface as Response;
Expand Down
19 changes: 10 additions & 9 deletions src/quoteservice/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
"php": ">= 8.2",
"ext-json": "*",
"ext-pcntl": "*",
"monolog/monolog": "3.3.1",
"open-telemetry/api": "1.0.0beta10",
"open-telemetry/sdk": "1.0.0beta14",
"open-telemetry/exporter-otlp": "1.0.0beta12",
"open-telemetry/opentelemetry-auto-slim": "1.0.0beta9",
"guzzlehttp/guzzle": "7.5.1",
"php-di/php-di": "7.0.3",
"php-di/slim-bridge": "3.3.0",
"monolog/monolog": "3.4.0",
"open-telemetry/api": "1.0.0RC1",
"open-telemetry/sdk": "1.0.0RC1",
"open-telemetry/exporter-otlp": "1.0.0RC1",
"open-telemetry/opentelemetry-auto-slim": "1.0.0beta10",
"open-telemetry/detector-container": "0.0.3",
"guzzlehttp/guzzle": "7.8.0",
"php-di/php-di": "7.0.5",
"php-di/slim-bridge": "3.4.0",
"php-http/guzzle7-adapter": "1.0.0",
"react/http": "v1.9.0",
"slim/psr7": "1.6.1",
"slim/slim": "4.11.0"
"slim/slim": "4.12.0"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 1 addition & 9 deletions src/quoteservice/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,19 @@

use DI\Bridge\Slim\Bridge;
use DI\ContainerBuilder;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use OpenTelemetry\API\Common\Instrumentation\Globals;
use OpenTelemetry\API\Common\Log\LoggerHolder;
use OpenTelemetry\API\Globals;
use OpenTelemetry\SDK\Common\Configuration\Configuration;
use OpenTelemetry\SDK\Common\Configuration\Variables;
use OpenTelemetry\SDK\Metrics\MeterProviderInterface;
use OpenTelemetry\SDK\Trace\TracerProviderInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LogLevel;
use React\EventLoop\Loop;
use React\Http\HttpServer;
use React\Socket\SocketServer;
use Slim\Factory\AppFactory;

require __DIR__ . '/../vendor/autoload.php';

LoggerHolder::set(
new Logger('otel-php', [new StreamHandler('php://stdout', LogLevel::DEBUG)])
);

// Instantiate PHP-DI ContainerBuilder
$containerBuilder = new ContainerBuilder();

Expand Down
Loading