Skip to content

Conversation

@Miqueasher
Copy link
Contributor

@Miqueasher Miqueasher commented Oct 16, 2025

This PR adds custom metrics to the existing sample app to verify public documentation is correct and functionality continues to work as changes happen in the future (Regression testing). Specifically for OpenTelemetry metrics using the CloudWatch Agent.

The changes made in this PR are:

  • 2 New imports to views.py (sample app's frontend service for the 'main' instance)
  • Global meter, and histogram/counter added to views.py from OTEL SDK Metrics page
  • Update to environment variables in main.tf
  • Update to jobs & env sections in python-ec2-default-test
  • Update from aws region us-west-2 to us-east-1
  • Update to Cloudwatch agent config to include otlp ports
  • Update to variables.tf to include custom metrics enabled
  • For loop expansion for easier Debugging logs (used in testing & for future)
  • New Validator file to call updated predefined template file
  • Update to PredefinedExpectedTemplate to include new mustache file
  • New mustache file for validation of custom metrics
  • Update to files CloudWatchService.java and CWMetricValidator.java

IMPORTANT
Updates to views.py effect 'python-sample-app.zip which exists in S3 bucket. Proper Zip protocol must be followed for it properly deploy and run. If not it will fail.

Rollback procedure:
A git revert to the most recent SHA (4ca5d60) will be easy to revert back to if necessary.

Passing test runs:
Test 1
Test 2
Test 3
Test 4
Test 5
Test 6
Test 7
Test 8
Test 9
Test 10
Test 11
Test 12

References:
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AppSignals-CustomMetrics.html#AppSignals-CustomMetrics-OpenTelemetry
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-OpenTelemetry-metrics.html
https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#exporter-selection
https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#otel_exporter_otlp_metrics_endpoint
https://opentelemetry.io/docs/specs/otel/metrics/sdk/

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

thpierce
thpierce previously approved these changes Oct 22, 2025
@Miqueasher Miqueasher merged commit fb173f2 into aws-observability:main Oct 23, 2025
10 checks passed
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.

3 participants