Skip to content

Conversation

@lucas-angeli-gimenes
Copy link
Collaborator

@lucas-angeli-gimenes lucas-angeli-gimenes commented Feb 6, 2026

Description

Problem

Histogram metrics for HTTP and database operations were not following OpenTelemetry semantic conventions:

  1. Wrong unit: Duration metrics were being reported in milliseconds (ms) instead of seconds (s) [1]
  2. Missing bucket boundaries: Histograms were created without explicit bucket boundaries [2]

Solution

  • Changed all duration metrics to use seconds as the unit
  • Added ExplicitBucketBoundaries as recommended by the OpenTelemetry specification
  • Created a centralized MetricBoundaries class to avoid duplication

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Performance/Refactor
  • CI/CD/Chore

Checklist

  • Title follows Conventional Commits (e.g., feat: add SQS aspect)
  • Tests added/updated
  • composer test passes locally
  • Documentation updated (README/Docs)
  • No breaking changes (or documented if any)

Copilot AI review requested due to automatic review settings February 6, 2026 13:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes histogram metrics for HTTP and database operations to comply with OpenTelemetry semantic conventions. The changes address two critical issues: incorrect unit usage (milliseconds instead of seconds) and missing explicit bucket boundaries that were causing observability backends like Dynatrace to show only +inf buckets.

Changes:

  • Changed all HTTP and database duration metrics from milliseconds to seconds
  • Added explicit bucket boundaries for histograms following OpenTelemetry specifications
  • Created a centralized MetricBoundaries class with documented HTTP and database duration bucket boundaries
  • Updated all related tests to verify the new unit and bucket boundaries

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Support/MetricBoundaries.php New class defining centralized bucket boundaries for HTTP (14 buckets) and database (9 buckets) duration histograms
src/Middleware/MetricMiddleware.php Updated HTTP server request duration metric to use seconds and explicit bucket boundaries
src/Listener/DbQueryExecutedListener.php Updated database query duration metric to use seconds (converting from ms) and explicit bucket boundaries
src/Aspect/RedisAspect.php Updated Redis operation duration metric to use seconds and explicit bucket boundaries
src/Aspect/MongoAspect.php Updated MongoDB operation duration metric to use seconds and explicit bucket boundaries
src/Aspect/GuzzleClientAspect.php Updated HTTP client request duration metric to use seconds, explicit bucket boundaries, and constant instead of hardcoded string
src/Aspect/Aws/DynamoDbClientAspect.php Updated DynamoDB operation duration metric to use seconds and explicit bucket boundaries
tests/Unit/Middleware/MetricMiddlewareTest.php Updated test expectations to verify seconds unit and 14 bucket boundaries for HTTP metrics
tests/Unit/Listener/DbQueryExecutedListenerTest.php Updated test expectations to verify seconds unit, 9 bucket boundaries, and correct duration conversions (e.g., 25.3ms → 0.0253s)
tests/Unit/Aspect/RedisAspectTest.php Updated test expectations to verify seconds unit and 9 bucket boundaries for Redis metrics
tests/Unit/Aspect/MongoAspectTest.php Updated test expectations to verify seconds unit and 9 bucket boundaries for MongoDB metrics
tests/Unit/Aspect/GuzzleClientAspectTest.php Updated test expectations to verify seconds unit and 14 bucket boundaries for HTTP client metrics
tests/Unit/Aspect/Aws/DynamoDbClientAspectTest.php Updated test expectations to verify seconds unit and 9 bucket boundaries for DynamoDB metrics

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lucas-angeli-gimenes lucas-angeli-gimenes merged commit 83a3dea into main Feb 12, 2026
6 checks passed
@lucas-angeli-gimenes lucas-angeli-gimenes deleted the fix_bucket branch February 12, 2026 11:13
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.

5 participants