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

document logs and metrics for quote service #4279

Merged
merged 10 commits into from
Apr 13, 2024
30 changes: 28 additions & 2 deletions content/en/docs/demo/services/quote.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,34 @@ $span->addEvent('Quote processed, response sent back', [

## Metrics

TBD
In this demo, metrics are emitted by the batch trace and logs processors. The
metrics describe the internal state of the processor, such as number of exported
spans/logs, the queue limit, and queue usage.
brettmc marked this conversation as resolved.
Show resolved Hide resolved

You can enable metrics by setting the environment variable
`OTEL_PHP_INTERNAL_METRICS_ENABLED=true`.
brettmc marked this conversation as resolved.
Show resolved Hide resolved

A manual metric is also emitted, which counts the number of quotes generated,
including attributes for the number of items and total cost.

A counter is created from the globally configured Meter Provider, and is
incremented each time a quote is generated:

```php
static $counter;
$counter ??= Globals::meterProvider()
->getMeter('quotes')
->createCounter('quotes', 'quotes', 'number of quotes calculated');
$counter->add(1, ['number_of_items' => $numberOfItems]);
```

Metrics accumulate and are exported periodically based on the value configured
in `OTEL_METRIC_EXPORT_INTERVAL`.

## Logs

TBD
The quote service emits a log message after a quote is calculated. The Monolog
logging package is configured with a
[Logs Bridge](/docs/concepts/signals/logs/#log-appender--bridge) which converts
Monolog logs into the OpenTelemetry format. Logs sent to this logger will be
exported via the globally configured OpenTelemetry logger.