GraphiteAliases.

Graphite(ICakeContext, GraphiteSettings) Method

Summary

Creates a new GraphiteClient using the specified settings. Send methods are in GraphiteExtensions
Assembly
Cake.Graphite.dll
Namespace
Cake.Graphite
Containing Type
GraphiteAliases

Syntax

public static Graphite Graphite(this ICakeContext context, GraphiteSettings settings)

Examples

 #addin nuget:?package=Cake.Graphite&loaddependencies=true
 // This is needed for the Datapoint struct
 using ahd.Graphite;
 public class BuildData
 {
     public Graphite Graphite { get; }
 
     public BuildData(Graphite graphite)
     {
        Graphite = graphite;
     }
 }
 
 Setup(setupContext  =>
 {
    var graphiteClient = Graphite(new GraphiteSettings{
       Host = "localhost",
       Prefix = "cake.graphite.example" // Include your api key in front if you are using HostedGraphite
    });
 
    return new BuildData(graphiteClient);
 });

 Task("Default")
     .Does<BuildData>(data =>
 {
     // Send a single metric without time
     data.Graphite.Send("single_metric", 1);
     // Send a single metric with a specific time
     data.Graphite.Send("single_metric2", 1, DateTime.UtcNow);

     var now = DateTime.UtcNow;
     var bulkDatapoints = new List<Datapoint>();
     bulkDatapoints.Add(new Datapoint("bulk_metric1", 1, now));
     bulkDatapoints.Add(new Datapoint("bulk_metric2", 1, now));
     bulkDatapoints.Add(new Datapoint("bulk_metric3", 1, now));
     bulkDatapoints.Add(new Datapoint("bulk_metric4", 1, now));
     bulkDatapoints.Add(new Datapoint("bulk_metric5", 1, now));
     bulkDatapoints.Add(new Datapoint("bulk_metric6", 1, now));

     // Bulk sending of metrics
     data.Graphite.Send(bulkDatapoints);
 });

Attributes

Type Description
CakeMethodAliasAttribute
CakeAliasCategoryAttribute

Parameters

Name Type Description
context ICakeContext The context.
settings GraphiteSettings The settings.

Return Value

Type Description
Graphite