Example #1
0
        public Telemetry(
            string assemblyVersion,
            TimeSpan flushInterval,
            IStatsSender statsSender,
            string[] globalTags)
        {
            _optionalStatsSender = statsSender;

            string transport;
            switch (statsSender.TransportType)
            {
                case StatsSenderTransportType.UDP: transport = "udp"; break;
                case StatsSenderTransportType.UDS: transport = "uds"; break;
                default: transport = statsSender.TransportType.ToString(); break;
            }

            var optionalTags = new List<string> { "client:csharp", $"client_version:{assemblyVersion}", $"client_transport:{transport}" };
            optionalTags.AddRange(globalTags);
            _optionalTags = optionalTags.ToArray();

            _optionalTimer = new Timer(
                _ => Flush(),
                null,
                flushInterval,
                flushInterval);
        }
        private Telemetry CreateTelemetry(
            StatsdConfig config,
            string[] globalTags,
            IStatsSender statsSender)
        {
            var telemetryFlush = config.Advanced.TelemetryFlushInterval;

            if (telemetryFlush.HasValue)
            {
                var assembly = typeof(StatsdBuilder).GetTypeInfo().Assembly;
                var version  = assembly.GetName().Version.ToString();

                return(_factory.CreateTelemetry(version, telemetryFlush.Value, statsSender, globalTags));
            }

            // Telemetry is not enabled
            return(new Telemetry());
        }
Example #3
0
 public Telemetry CreateTelemetry(string assemblyVersion, TimeSpan flushInterval, IStatsSender statsSender, string[] globalTags)
 {
     return(new Telemetry(assemblyVersion, flushInterval, statsSender, globalTags));
 }