package com.timgroup.statsd;

/**
 * A service check model, which is used to format a service check message
 * sent to the datadog agent
 */
public class ServiceCheck {

    private String name, hostname, message;

    private int status, checkRunId, timestamp;

    private String[] tags;

    /**
     */
    public ServiceCheck() {
    }

    /**
     * @param name
     * @param status
     */
    public ServiceCheck(String name, int status) {
        this(name, status, null, null);
    }

    public ServiceCheck(String name, int status, String message, String[] tags) {
        this.name = name;
        this.status = status;
        this.message = message;
        this.tags = tags;
    }

    /**
     * @return
     */
    public String getName() {
        return name;
    }

    /**
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return
     */
    public int getStatus() {
        return status;
    }

    /**
     * @param status
     */
    public void setStatus(int status) {
        this.status = status;
    }

    /**
     * @return
     */
    public String getMessage() {
        return message;
    }

    /**
     * @return
     */
    public String getEscapedMessage() {
        return message.replace("\n", "\\n").replace("m:", "m\\:");
    }

    /**
     *
     * @param message
     */
    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * @return
     */
    public String getHostname() {
        return hostname;
    }

    /**
     * @param hostname
     */
    public void setHostname(String hostname) {
        this.hostname = hostname;
    }

    /**
     * @return
     */
    public int getTimestamp() {
        return timestamp;
    }

    /**
     * @param timestamp
     */
    public void setTimestamp(int timestamp) {
        this.timestamp = timestamp;
    }

    /**
     * @return
     */
    public String[] getTags() {
        return tags;
    }

    /**
     * @param tags
     */
    public void setTags(String... tags) {
        this.tags = tags;
    }

    /**
     * @return
     */
    public String toStatsDString() {
        StringBuilder sb = new StringBuilder();
        sb.append(String.format("_sc|%s|%d", name, status));
        if (timestamp > 0) {
            sb.append(String.format("|d:%d", timestamp));
        }
        if (hostname != null) {
            sb.append(String.format("|h:%s", hostname));
        }
        if (tags != null && tags.length > 0) {
            sb.append(String.format("|#%s", tags[0]));
            for(int i=1;i<tags.length;i++) {
                sb.append(',').append(tags[i]);
            }
        }
        if (message != null) {
            sb.append(String.format("|m:%s", this.getEscapedMessage()));
        }
        return sb.toString();
    }

    public String test() {
        return "Test";
    }
}

@@ -474,16 +474,22 @@
 s, null,
+ null,
  null);%0A
@@ -569,32 +569,187 @@
 tring%5B%5D tags) %7B%0A
+        this(name, status, message, null, tags);%0A    %7D%0A%0A    public ServiceCheck(String name, int status, String message, String hostname, String%5B%5D tags) %7B%0A
         this.nam
@@ -816,24 +816,58 @@
  = message;%0A
+        this.hostname = hostname;%0A
         this

Add SC constructor with hostname