Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add App Insights Dependency Tracking #51

Open
lukos opened this issue Oct 28, 2016 · 4 comments
Open

Add App Insights Dependency Tracking #51

lukos opened this issue Oct 28, 2016 · 4 comments

Comments

@lukos
Copy link

lukos commented Oct 28, 2016

Currently, Redis does not use Dependency Tracking for Application Insights, and we have seen many issues related to Redis timeouts and network latency that would be much easier to debug and see if dependency tracking was built into this provider.

@markalanevans
Copy link

Do you guys think you will add support for this?

@Leonardo-Ferreira
Copy link

i really don't think thats a good idea... at least not bluntly put as such... my redis logs about 14 million operations per hour (avg of 4 operations per millisecond) and i'm operating from a single 2 core 3gb ram PaaS... that would affect me in 3 ways:

  • the simple fact of detecting whether or not to log would hurt my performance,

  • if yes-log, most likely (like SQL dependency log) the log operation wouldn't yield any new information that you don't already have in exceptions or redis itself

  • the cost of storing such data would be significant (i currently use the basic C2 that goes for about 70 bucks/months)

@andre-castro-garcia
Copy link

I'm currently bypasses this problem using a custom implementation for track events in my Application Insights.

My code seems like this:

    /// <summary>
    /// 
    /// </summary>
    public class RedisFacade : IRedisFacade {
        private readonly IDatabaseAsync _cache;
        private readonly TelemetryClient _telemetry;

        private readonly Stopwatch _watch;

        private const string Redis = "REDIS";
        private readonly string _redisHost;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="multiplexer"></param>
        /// <param name="options"></param>
        /// <param name="telemetry"></param>
        public RedisFacade(IConnectionMultiplexer multiplexer, IOptions<ConnectionsOptions> options,
            TelemetryClient telemetry) {
            _cache = multiplexer.GetDatabase();
            _telemetry = telemetry;
            _watch = new Stopwatch();
            _redisHost = "myredishost:6379";
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="method"></param>
        /// <param name="func"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        private async Task<T> ExecuteWithTracking<T>(string method, Func<Task<T>> func) {
            var start = DateTimeOffset.Now;
            if (_watch.IsRunning)
                _watch.Restart();
            else
                _watch.Start();
            var result = await func().ConfigureAwait(false);
            _watch.Stop();

            var end = _watch.Elapsed;
            _telemetry.TrackDependency(Redis, _redisHost,
                method, string.Empty, start, end, string.Empty, true);
            return result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public async Task<RedisValue> StringGetAsync(RedisKey key) {
            return await ExecuteWithTracking("StringGetAsync", () => _cache.StringGetAsync(key))
                .ConfigureAwait(false);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public async Task<bool> KeyExistsAsync(RedisKey key) {
            return await ExecuteWithTracking("KeyExistsAsync", () => _cache.KeyExistsAsync(key))
                .ConfigureAwait(false);
        }
}

My Application Insights Application Map:

image

@mtamrakar
Copy link

@andre-castro-garcia, is IRedisFacade your own abstraction? If not, how do we inject this abstraction into RedisSessionStateProvider.cs to make sure everything goes through this override.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants