/// <summary> /// Factory (create instance). /// The factory is here for backward compatibility, newer component should use IoC (Dependency Injection) /// </summary> /// <param name="activationFactory">The activation factory.</param> /// <param name="simpleConfig">The simple configuration.</param> /// <param name="tagContext">The tag context.</param> /// <returns></returns> private static IMetricsReporterBuilder Create( ITelemetryActivationFactory activationFactory, ISimpleConfig simpleConfig, ITelemetryTagContext tagContext) { return(new MetricsReporterBuilder(activationFactory, simpleConfig, tagContext)); }
public MetricsReporter( ITelemetryActivation activation, ITelemetryTagContext tagContext, string measurementName, IImmutableDictionary <string, string> tags, MetricsCollector influxClient) { _activation = activation; _tagContext = tagContext; _measurementName = measurementName; _tags = tags ?? ImmutableDictionary <string, string> .Empty; _influxClient = influxClient; }
private MetricsReporterBuilder( ITelemetryActivation config, ITelemetryTagContext tagContext, string measurementName, IImmutableDictionary <string, string> tags, CollectorConfiguration influxConfiguration) { _activation = config; _tagContext = tagContext; _measurementName = measurementName; _tags = tags; _influxConfiguration = influxConfiguration; }
/// <summary> /// Initializes a new instance of the <see cref="MetricsReporterBuilder"/> class. /// </summary> /// <param name="activationFactory">The activation factory.</param> /// <param name="simpleConfig">The simple configuration.</param> /// <param name="tagContext">The tag context.</param> public MetricsReporterBuilder( ITelemetryActivationFactory activationFactory, ISimpleConfig simpleConfig, ITelemetryTagContext tagContext) { // TODO: move it into Influx provider (InfluxMetricFactory) string url = simpleConfig["influx-url"]; string db = simpleConfig["influx-database"]; string version = simpleConfig["influx-report-version"]; _activation = activationFactory.Create(); _influxConfiguration = new CollectorConfiguration() .Tag.With("version", version) .Tag.With("host", Environment.MachineName) .Tag.With("user", Environment.UserName) .Batch.AtInterval(TimeSpan.FromSeconds(5)) .WriteTo.InfluxDB(url, database: db); _tagContext = tagContext; }