Enhancing workload observability using Amazon CloudWatch Embedded Metric Format
Pulled from these two projects using the Embedded Metric Format Specification as a reference guide.
- Node: https://github.com/awslabs/aws-embedded-metrics-node
- Python: https://github.com/awslabs/aws-embedded-metrics-python
However, unlike these projects, we differ in the following ways. Again, contributions are very much welcome if you want to see more or change this.
- Initial focus on Lambda. No other sinks.
- As such, no default Dimensions or Configuraiton for:
LogGroupName
LogStreamName
ServiceName
ServiceType
Add this line to your application's Gemfile:
gem 'aws-embedded-metrics-customink'
Simple configuration:
Aws::Embedded::Metrics.configure do |c|
c.namespace = 'MyApplication'
end
Using the Logger
sink to write to a log file:
Aws::Embedded::Metrics.configure do |c|
c.sink = Aws::Embedded::Metrics::Sinks::Logger.new(Rails.logger)
end
Usage is in a scope block. All metrics are flushed afterward
Aws::Embedded::Metrics.logger do |metrics|
metrics.put_dimension 'SomeDimension', 'SomeDimensionValue'
metrics.set_property 'EventKey', 'some/s3/path'
metrics.put_metric 'Processor', 232, 'Milliseconds'
metrics.put_metric 'Total', 4008, 'Milliseconds'
end
After checking out the repo, run bin/setup
to install dependencies. Then, run bin/test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/customink/aws-embedded-metrics-customink. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Aws::Embedded::Metrics project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.