Skip to content

feat: add OpenTelemetry metrics (requests, duration, errors)#336

Merged
maximn merged 1 commit into
masterfrom
maximn/issue-296
Jul 1, 2026
Merged

feat: add OpenTelemetry metrics (requests, duration, errors)#336
maximn merged 1 commit into
masterfrom
maximn/issue-296

Conversation

@maximn

@maximn maximn commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Summary

Adds optional OpenTelemetry metrics — three instruments (request counter, latency histogram, error counter) published from a Meter named GoogleMapsApi, recorded once per call and zero-cost until a listener subscribes. This is the metrics half of #296; the ILogger half is intentionally left out and documented as a non-goal.

Related issue

Closes #296

Changes

  • New GoogleMapsApi.Diagnostics.GoogleMapsMetrics (public MeterName const; internal Meter + gmaps.client.requests / gmaps.client.request.duration / gmaps.client.request.errors instruments) with a zero-cost Record() helper; no new package dependency.
  • MapsAPIGenericEngine records metrics once per call in the existing finally, surfacing the HTTP status code via a callback — no behavioural change to request flow, exceptions, or tracing.
  • Updated PublicAPI.Unshipped.txt, added hermetic DiagnosticsMetricsTests (MeterListener-based), and documented metrics in README.md + .agents/observability.md (removed the resolved B5 item; recorded the ILogger non-goal).

Test plan

  • dotnet build clean on all three TFMs (PublicAPI lock satisfied); dotnet format clean on the new files.
  • 256 hermetic unit tests pass on net8.0 and net10.0 — including 3 new metrics tests + the existing tracing tests. Live-network IntegrationTests require a GOOGLE_API_KEY and were not run in this environment.

Checklist

  • dotnet format has been run.
  • dotnet test passes locally (with a valid GOOGLE_API_KEY for integration tests).
  • Multi-framework build passes (netstandard2.0, net8.0, net10.0).
  • XML documentation updated if public API surface changed.

Publishes three instruments from a new GoogleMapsMetrics meter
("GoogleMapsApi", same name as the trace source): gmaps.client.requests
(counter), gmaps.client.request.duration (histogram, seconds), and
gmaps.client.request.errors (counter). Recorded once per call in the
engine and zero-cost until a listener subscribes, mirroring the existing
tracing; no new package dependency. The ILogger half of the issue is
intentionally left out and documented as a non-goal.

Closes #296
@github-actions

Copy link
Copy Markdown

🔬 TestGlance

✅ 265 passed across 1 job — 100.0% · ⏱️ 2.1s

Job Result Pass rate Duration Health
build 265/265 · 100.0% 2.1s Report
🟡 build — details

✅ 265 passed
████████████████ 100.0%
⏱️ 2.1s

vs master

Metric master PR Delta
Pass rate 100.0% 100.0% +0.0%
Duration 2.1s 2.1s -1.1%

📄 HTML Report


Updated 2026-06-30T21:46:53.390Z

@maximn maximn merged commit f569a27 into master Jul 1, 2026
7 checks passed
@maximn maximn deleted the maximn/issue-296 branch July 1, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enhancement: optional ILogger logging and OpenTelemetry metrics

1 participant