public MetricSnapshotGraphitePlainTextProtocolWriter( TextWriter textWriter, IGraphitePointTextWriter metricNameFormatter = null) { _textWriter = textWriter ?? throw new ArgumentNullException(nameof(textWriter)); _points = new GraphitePoints(); _metricNameFormatter = metricNameFormatter ?? new DefaultGraphitePointTextWriter(); }
public GraphitePoint( string context, string measurement, IReadOnlyDictionary <string, object> fields, MetricTags tags, IGraphitePointTextWriter pointTextWriter, DateTime?utcTimestamp = null) { _pointTextWriter = pointTextWriter ?? throw new ArgumentNullException(nameof(pointTextWriter)); if (string.IsNullOrEmpty(measurement)) { throw new ArgumentException("A measurement must be specified", nameof(measurement)); } if (fields == null || fields.Count == 0) { throw new ArgumentException("At least one field must be specified", nameof(fields)); } if (fields.Any(f => string.IsNullOrEmpty(f.Key))) { throw new ArgumentException("Fields must have non-empty names", nameof(fields)); } if (utcTimestamp != null && utcTimestamp.Value.Kind != DateTimeKind.Utc) { throw new ArgumentException("Timestamps must be specified as UTC", nameof(utcTimestamp)); } Context = context; Measurement = measurement; Fields = fields; Tags = tags; UtcTimestamp = utcTimestamp ?? DateTime.UtcNow; }