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

enabling batch span processor metrics for quoteservice #878

Merged
merged 6 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ release.
([#869](https://github.com/open-telemetry/opentelemetry-demo/pull/869))
* [grafana] fix demo dashboard to be compatible with spanmetrics connector
([#874](https://github.com/open-telemetry/opentelemetry-demo/pull/874))
* [quoteservice] enabling batch span processor metrics
([#878](https://github.com/open-telemetry/opentelemetry-demo/pull/878))

## 1.4.0

Expand Down
100 changes: 97 additions & 3 deletions src/grafana/provisioning/dashboards/general/demo-dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,103 @@
],
"title": "Endpoint Rate by Service",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "webstore-metrics"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 25
},
"id": 16,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "webstore-metrics"
},
"editorMode": "builder",
"expr": "otel_trace_span_processor_spans{service_name=\"quoteservice\"}",
"legendFormat": "{{state}}",
"range": true,
"refId": "A"
}
],
"title": "Quote Service batch span processor",
"type": "timeseries"
}
],
"schemaVersion": 37,
"refresh": "",
"revision": 1,
"schemaVersion": 38,
"style": "dark",
"tags": [],
"templating": {
Expand Down Expand Up @@ -691,6 +785,6 @@
"timezone": "",
"title": "Demo Dashboard",
"uid": "W2gX2zHVk",
"version": 1,
"version": 2,
"weekStart": ""
}
}
2 changes: 1 addition & 1 deletion src/quoteservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN chmod +x /usr/local/bin/install-php-extensions \
opcache \
pcntl \
protobuf \
opentelemetry-1.0.0beta3
opentelemetry-beta

WORKDIR /var/www
COPY --from=build /tmp/vendor/ ./vendor/
Expand Down
19 changes: 10 additions & 9 deletions src/quoteservice/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
"require": {
"php": ">= 8.2",
"ext-json": "*",
"ext-pcntl": "*",
"monolog/monolog": "3.3.1",
"open-telemetry/api": "1.0.0beta5",
"open-telemetry/sdk": "1.0.0beta6",
"open-telemetry/exporter-otlp": "1.0.0beta5",
"open-telemetry/api": "1.0.0beta9",
"open-telemetry/sdk": "1.0.0beta9",
"open-telemetry/exporter-otlp": "1.0.0beta8",
"open-telemetry/opentelemetry-auto-slim": "1.0.0beta7",
"guzzlehttp/guzzle": "7.4.5",
"php-di/php-di": "6.4.0",
"php-di/slim-bridge": "3.2.0",
"guzzlehttp/guzzle": "7.5.1",
"php-di/php-di": "7.0.2",
"php-di/slim-bridge": "3.3.0",
"php-http/guzzle7-adapter": "1.0.0",
"react/http": "v1.8.0",
"slim/psr7": "1.5",
"slim/slim": "4.10.0"
"react/http": "v1.9.0",
"slim/psr7": "1.6.1",
"slim/slim": "4.11.0"
},
"autoload": {
"psr-4": {
Expand Down
17 changes: 17 additions & 0 deletions src/quoteservice/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
use DI\ContainerBuilder;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use OpenTelemetry\API\Common\Instrumentation\Globals;
use OpenTelemetry\API\Common\Log\LoggerHolder;
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;
Expand Down Expand Up @@ -58,6 +63,18 @@
exit;
});

/* workaround for non-async batch processors */
if (($tracerProvider = Globals::tracerProvider()) instanceof TracerProviderInterface) {
Loop::addPeriodicTimer(Configuration::getInt(Variables::OTEL_BSP_SCHEDULE_DELAY)/1000, function() use ($tracerProvider) {
$tracerProvider->forceFlush();
});
}
if (($meterProvider = Globals::meterProvider()) instanceof MeterProviderInterface) {
Loop::addPeriodicTimer(Configuration::getInt(Variables::OTEL_METRIC_EXPORT_INTERVAL)/1000, function() use ($meterProvider) {
$meterProvider->forceFlush();
});
}

$server = new HttpServer(function (ServerRequestInterface $request) use ($app) {
$response = $app->handle($request);
echo sprintf('[%s] "%s %s HTTP/%s" %d %d %s',
Expand Down