Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions content/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,15 @@ pages:
template: cluster-id
contextProfile: cluster-id

- id: telemetry
path: telemetry
title: Telemetry
category: Shared Configuration
wrappers: [ruby]
parent: overview
template: telemetry
contextProfile: telemetry

# ---------------------------------------------------------------------------
# Compatibility guide. Each wrapper renders only its own plugins.
# ---------------------------------------------------------------------------
Expand Down
284 changes: 284 additions & 0 deletions content/telemetry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
# =============================================================================
# Telemetry (Monitoring) — shared-configuration page registry
# =============================================================================
#
# Telemetry is not a plugin: it oversees every enabled plugin and the wrapper
# itself, and is turned on with a connection property rather than by being listed
# in the plugin parameter. It therefore lives under Shared Configuration.
#
# This registry is split the way the other shared pages are:
#
# shared: Wrapper-agnostic prose — what telemetry is, the difference
# between traces and metrics, the collector, and the
# top-level/nested trace idea. Reused verbatim by every
# wrapper, so it must not name a property, gem, or backend.
# wrappers.<id>: Everything wrapper-specific — the exact property names and
# their types/defaults/units, the backends that wrapper
# supports, the gems and SDK setup code, and the metric names
# (which are spelled in that wrapper's own casing).
#
# The template reads the shared prose directly and the per-wrapper fields through
# `telemetry.wrappers[wrapper_id]`. Parameters follow the same shape as the other
# pages (a shared `concept`/`description` with per-wrapper `spellings`), so the
# page reuses `partials/plugin-parameters.md.j2`.
# =============================================================================

shared:
overview: |
Telemetry is the ability to gather data and insights on the execution of an
application, so you can inspect what happened and decide what to act on. When
telemetry is enabled, the wrapper records data about its own execution — both
at a global level and per plugin — so you can see how the wrapper as a whole,
and each plugin within it, is performing against your expectations.

Telemetry oversees every plugin you have enabled and the wrapper itself; it is
**not a plugin**. You do not list it alongside the other plugins — you turn it
on with a connection property, described below.

tracesIntro: |
A **trace** gives an overview of what happens in one section of an
application's execution. A trace is a hierarchical sequence of spans, each
carrying basic information about that section — how long it took, and whether
it succeeded or failed.

The wrapper records a span for work it does and nests spans to show how that
work breaks down. Because spans are hierarchical, a span the wrapper records
can either nest inside a trace your application already has open or stand on
its own as a top-level trace — see
[top-level and nested traces](#top-level-and-nested-traces).

metricsIntro: |
**Metrics** are numeric values measured over the execution of an application.
They show how many times something happened (for example, a failover, or a
token fetch) and, for things that happen repeatedly, how often each outcome
occurred. Metrics come in two kinds: a **counter**, which only ever increases,
and a **gauge**, which reports a current value each time metrics are collected.

The metrics the wrapper records are listed in
[list of metrics](#list-of-metrics). Each one is submitted only while the
plugin that owns it is enabled.

collectorIntro: |
The wrapper records telemetry through the [OpenTelemetry](https://opentelemetry.io/)
API only; it does not export anything on its own. Your application installs an
OpenTelemetry SDK — the tracer and meter providers plus the exporters — and the
wrapper's traces and metrics then go wherever that SDK sends them. Until the
SDK is installed, the API quietly discards what the wrapper records, so nothing
is exported and there is no error.

A common target is the [AWS Distro for OpenTelemetry (ADOT) Collector](https://aws-otel.github.io/docs/getting-started/collector),
which receives telemetry over OTLP and forwards traces to
[AWS X-Ray](https://aws.amazon.com/xray/) and metrics to
[Amazon CloudWatch](https://aws.amazon.com/cloudwatch/). To view the data in
the AWS console you need an IAM principal with permissions for
[X-Ray](https://docs.aws.amazon.com/xray/latest/devguide/security-iam.html) and
[CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/auth-and-access-control-cw.html).

:::warning
The collector is a separate application, not part of the wrapper. Without a
collector (or another OTLP backend) the wrapper still records telemetry, but
there is nowhere for it to be sent and visualized.
:::

topLevelIntro: |
Traces are hierarchical, so when the wrapper is called from code that already
has a trace open, there is a choice: should the wrapper's traces nest inside
that open trace, or stand on their own as top-level traces?

A **top-level** trace has no parent and appears directly in the list of
submitted traces. A **nested** trace is linked under a parent — for example,
the individual plugin spans of one wrapper call are nested under that call's
span. By default the wrapper nests its traces under whatever trace is already
open, and records nothing when no trace is open. The properties below let you
change that.

metricsTableIntro: |
The wrapper submits a set of metrics while it runs. They are predefined, and
each gives insight into what a plugin is doing while it is enabled. A metric is
either a **counter** or a **gauge**. Metrics are only submitted by the plugins
that are enabled, so a plugin you do not use contributes nothing.

wrappers:
ruby:
availableSince: "1.1.0"
# Backends this wrapper can export to, for each signal. Ruby exports over OTLP
# only (plus `none`); it has no direct X-Ray trace backend — X-Ray is reached
# through the collector.
tracesBackends: "`otlp`, `none`"
metricsBackends: "`otlp`, `none`"

# The scope name the wrapper registers its tracer and meter under, so you can
# find its telemetry among other instrumentation.
instrumentationScope: "aws-advanced-ruby-driver-wrapper"

gemsBlock: |
The OpenTelemetry gems are optional dependencies of the wrapper, so add the
ones you need to your Gemfile. Traces and metrics are separate: add the
metrics gems only if you export metrics.

```ruby
# Gemfile
gem 'opentelemetry-sdk' # the SDK your application installs
gem 'opentelemetry-exporter-otlp' # exports traces over OTLP
gem 'opentelemetry-metrics-sdk' # metrics SDK (separate from the traces SDK)
gem 'opentelemetry-exporter-otlp-metrics' # exports metrics over OTLP
```

The wrapper itself requires only the OpenTelemetry API (`opentelemetry-api`
for traces and `opentelemetry-metrics-api` for metrics); the SDK gems above
pull those in. If a selected backend's gem is missing when telemetry is
enabled, the wrapper raises on the first connection.

sdkSetup: |
Install the SDK once, before opening connections. It owns the exporters and
their endpoints; the wrapper only feeds spans and metrics into the API.

```ruby
require 'opentelemetry/sdk'
require 'opentelemetry/exporter/otlp' # traces
require 'opentelemetry-metrics-sdk' # metrics
require 'opentelemetry/exporter/otlp_metrics' # metrics

# Traces: an OTLP span exporter pointed at your collector.
OpenTelemetry::SDK.configure do |c|
c.service_name = 'my-app'
c.add_span_processor(
OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
OpenTelemetry::Exporter::OTLP::Exporter.new(
endpoint: ENV.fetch('OTEL_EXPORTER_OTLP_TRACES_ENDPOINT') # e.g. http://localhost:4318/v1/traces
)
)
)
end

# Metrics: register an OTLP metrics reader on the meter provider.
OpenTelemetry.meter_provider.add_metric_reader(
OpenTelemetry::SDK::Metrics::Export::PeriodicMetricReader.new(
exporter: OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new(
endpoint: ENV.fetch('OTEL_EXPORTER_OTLP_METRICS_ENDPOINT') # e.g. http://localhost:4318/v1/metrics
)
)
)
```

enableIntro: |
Telemetry is off until you enable it. Set `enable_telemetry` to `true` and
choose a backend for each signal you want exported; a backend left at `none`
records nothing for that signal. These are ordinary connection properties, so
they go wherever your other wrapper properties go.
enableBlock: |
```yaml
# config/database.yml
production:
adapter: aws_postgresql
host: my-cluster.cluster-xyz.us-east-1.rds.amazonaws.com
database: mydb
username: <username>
password: <password>
enable_telemetry: true
telemetry_traces_backend: otlp
telemetry_metrics_backend: otlp
```

Using the driver directly, the same properties are keyword arguments:

```ruby
conn = AwsAdvancedRubyDriverWrapper::WrapperPgConnection.new(
host: 'my-cluster.cluster-xyz.us-east-1.rds.amazonaws.com',
dbname: 'mydb',
user: '<username>',
password: '<password>',
enable_telemetry: true,
telemetry_traces_backend: 'otlp',
telemetry_metrics_backend: 'otlp'
)
```

# Top-level / nested behaviour, wrapper-specific wording for the two properties
# that control it.
topLevelDetail: |
Two properties control how the wrapper's traces relate to a trace your
application already has open:

- **`telemetry_submit_top_level`** — by default (`false`) the wrapper nests
each wrapper-call trace under the trace already in progress, and records
nothing when no trace is open. Set it to `true` to submit every wrapper
call as a top-level trace of its own instead.
- **`telemetry_failover_additional_top_trace`** — a failover is normally
recorded as a span within the wrapper call that triggered it. Set this to
`true` to *also* submit each failover as a separate top-level trace, so it
can be found on its own. Only a failover that was already being traced is
submitted this way.

# Parameters. Shared `concept`/`description`; per-wrapper `spellings`. Rendered
# by partials/plugin-parameters.md.j2, exactly like the plugin pages.
parameters:
- concept: enableTelemetry
type: boolean
description: "Enables telemetry and observability of the wrapper. While `false`, no telemetry is recorded, whatever the backend properties say."
spellings:
ruby: { name: enable_telemetry, required: "No", default: "false" }
- concept: telemetryTracesBackend
type: string
description: "Where recorded traces are exported. `otlp` exports to your OpenTelemetry SDK (and on to a collector); `none` records traces but exports them nowhere."
spellings:
ruby: { name: telemetry_traces_backend, required: "No", defaultNote: "none", example: "otlp" }
- concept: telemetryMetricsBackend
type: string
description: "Where recorded metrics are exported. `otlp` exports to your OpenTelemetry SDK (and on to a collector); `none` records metrics but exports them nowhere."
spellings:
ruby: { name: telemetry_metrics_backend, required: "No", defaultNote: "none", example: "otlp" }
- concept: telemetrySubmitTopLevel
type: boolean
description: "Submit each wrapper-call trace as a top-level trace rather than nesting it under a trace already in progress. See [top-level and nested traces](#top-level-and-nested-traces)."
spellings:
ruby: { name: telemetry_submit_top_level, required: "No", default: "false" }
- concept: telemetryFailoverAdditionalTopTrace
type: boolean
description: "Also submit the trace of each failover as a top-level trace of its own. Only a failover that was already being traced is submitted this way."
spellings:
ruby: { name: telemetry_failover_additional_top_trace, required: "No", default: "false" }

# Metrics, grouped by the plugin that emits them. `[NODE]`-style per-node
# metrics do not exist in this wrapper, so none are listed. Names are in this
# wrapper's own casing (snake_case).
metricsNote: |
The `iam`, `federated_auth`, and `okta` plugins share one token cache, so
their three `*.token_cache.size` gauges all report the same value.
metricGroups:
- plugin: "Enhanced Failover — `failover`"
page: enhanced-failover
rows:
- { name: writer_failover.triggered.count, type: Counter, description: "Number of times writer failover was triggered." }
- { name: writer_failover.completed.success.count, type: Counter, description: "Number of times writer failover completed and succeeded." }
- { name: writer_failover.completed.failed.count, type: Counter, description: "Number of times writer failover completed and failed." }
- { name: reader_failover.triggered.count, type: Counter, description: "Number of times reader failover was triggered." }
- { name: reader_failover.completed.success.count, type: Counter, description: "Number of times reader failover completed and succeeded." }
- { name: reader_failover.completed.failed.count, type: Counter, description: "Number of times reader failover completed and failed." }
- plugin: "Custom Endpoint — `custom_endpoint`"
page: using-plugins/custom-endpoint
rows:
- { name: custom_endpoint.info_changed.count, type: Counter, description: "Number of times a monitor detected changed custom endpoint information." }
- { name: custom_endpoint.wait_for_info.count, type: Counter, description: "Number of times a connection attempt waited for custom endpoint information to be fetched." }
# The auth plugins (secrets_manager / iam / federated_auth / okta) come last,
# with the three that share a token cache at the very end so the
# shared-token-cache note below (metricsNote) sits directly after them.
- plugin: "AWS Secrets Manager — `secrets_manager`"
page: using-plugins/aws-secrets-manager
rows:
- { name: secrets_manager.fetch_credentials.count, type: Counter, description: "Number of times credentials were fetched from AWS Secrets Manager." }
- plugin: "IAM Authentication — `iam`"
page: using-plugins/iam-authentication
rows:
- { name: iam.fetch_token.count, type: Counter, description: "Number of times a token was fetched from IAM." }
- { name: iam.token_cache.size, type: Gauge, description: "Number of tokens held in the shared token cache." }
- plugin: "Federated Authentication — `federated_auth`"
page: using-plugins/federated-auth
rows:
- { name: federated.fetch_token.count, type: Counter, description: "Number of tokens generated after a SAML assertion exchange." }
- { name: federated.token_cache.size, type: Gauge, description: "Number of tokens held in the shared token cache." }
- plugin: "Okta Authentication — `okta`"
page: using-plugins/okta-auth
rows:
- { name: okta.fetch_token.count, type: Counter, description: "Number of tokens generated after a SAML assertion exchange." }
- { name: okta.token_cache.size, type: Gauge, description: "Number of tokens held in the shared token cache." }
76 changes: 76 additions & 0 deletions content/templates/telemetry.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: {{ page_title }}
---
{% set tw = telemetry.wrappers[wrapper_id] %}
{{ telemetry.shared.overview }}

:::info Available since
Version {{ tw.availableSince }}
:::

## Traces and metrics

The {{ wrapper.wrapperName }} provides telemetry in two forms: **traces** and **metrics**.

### Traces

{{ telemetry.shared.tracesIntro }}

### Metrics

{{ telemetry.shared.metricsIntro }}

## Where the data goes

{{ telemetry.shared.collectorIntro }}

## Enabling telemetry

{{ tw.enableIntro }}

{{ tw.enableBlock }}

### Install the OpenTelemetry gems

{{ tw.gemsBlock }}

### Set up the OpenTelemetry SDK

The {{ wrapper.wrapperName }} records telemetry through the OpenTelemetry API; your
application owns the SDK that exports it. Both traces and metrics are exported over
OTLP (the supported backends are {{ tw.tracesBackends }} for traces and
{{ tw.metricsBackends }} for metrics). The wrapper registers its tracer and meter
under the instrumentation scope `{{ tw.instrumentationScope }}`.

{{ tw.sdkSetup }}

## Configuration parameters

{% set params = tw.parameters %}
{% include "partials/plugin-parameters.md.j2" %}

## Top-level and nested traces

{{ telemetry.shared.topLevelIntro }}

{{ tw.topLevelDetail }}

## List of metrics

{{ telemetry.shared.metricsTableIntro }}

{% for group in tw.metricGroups %}
### {{ group.plugin }}

{% if group.page %}
See [{{ group.plugin.split('—')[0] | trim }}](./{{ group.page }}).

{% endif %}
| Metric name | Type | Description |
|-------------|------|-------------|
{% for row in group.rows -%}
| `{{ row.name }}` | {{ row.type }} | {{ row.description }} |
{% endfor %}

{% endfor %}
{{ tw.metricsNote }}
Loading
Loading