Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

modify packet to allow self defined pattern #63

Merged
merged 4 commits into from

3 participants

@torkale

allow custom made statsd pattern of deployment increment

@justincampbell

@torkale Could you please rebase from master? It has fixes for the build failures.

@torkale

@justincampbell Unfortunately I see build failures on master too

@smith
Collaborator

We can probably merge this (without worrying about build failures), but I'd like to see:

  • Removing the .ruby_version. There's no reason this should be in the repo I think.
  • Add a not to the readme.
@torkale

done

@smith smith merged commit 3ee45c0 into gofullstack:master
@torkale
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 27, 2013
  1. @torkale
Commits on Feb 18, 2014
  1. @torkale

    gitignore .ruby-version

    torkale authored
  2. @torkale

    add README note for pattern

    torkale authored
  3. @torkale

    Update README.md

    torkale authored
This page is out of date. Refresh to see the latest.
View
1  .gitignore
@@ -16,3 +16,4 @@ test/tmp
test/version_tmp
tmp
.DS_Store
+.ruby-version
View
12 README.md
@@ -81,4 +81,16 @@ set :notifier_statsd_options, {
}
```
+You can define the pattern that will be used to define the key.
+In the example the key will be 'test.deployment.example'
+
+```rb
+set :application, 'example'
+set :stage, 'test'
+
+set :notifier_statsd_options, {
+ :pattern => "#{stage}.deployment.#{application}"
+}
+```
+
The `nc` ([Netcat](http://netcat.sourceforge.net/)) command is used to send messages to statsd and must be installed on the remote hosts. This is installed by default on most Unix machines.
View
16 lib/capistrano/notifier/statsd.rb
@@ -38,11 +38,17 @@ def options
end
def packet
- if stage
- "#{application}.#{stage}.deploy:#{with}"
- else
- "#{application}.deploy:#{with}"
- end
+ "#{pattern}:#{with}"
+ end
+
+ def pattern
+ options.fetch(:pattern){
+ if stage
+ "#{application}.#{stage}.deploy"
+ else
+ "#{application}.deploy"
+ end
+ }
end
def port
View
17 spec/capistrano/notifier/statsd_spec.rb
@@ -78,4 +78,21 @@
end
end
end
+
+ context "with a pattern" do
+ before :each do
+ configuration.load do
+ set :application, 'example'
+ set :stage, 'test'
+ set :notifier_statsd_options, {
+ :pattern => "#{stage}.deployment.#{application}"
+ }
+ end
+ end
+
+ it "creates a packet" do
+ subject.send(:packet).should == "test.deployment.example:1|c"
+ end
+
+ end
end
Something went wrong with that request. Please try again.