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
40 changes: 38 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,44 @@ $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.

### Initializing metrics

To generate metrics, you need to create an instrument such as a counter, gauge,
or histogram. The following example retrieves a meter from the globally
configured Meter Provider and uses it to create a counter:

```php
$counter = Globals::meterProvider()
->getMeter('my-meter')
->createCounter('my-counter');
```

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

### Generate metrics

An instrument provides a method to record a new value against it. This example
shows how to `add` values to the counter:

```php
$counter->add(2);
```
julianocosta89 marked this conversation as resolved.
Show resolved Hide resolved

## 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, and sends them to the globally
configured OpenTelemetry Logger.