Giter Site home page Giter Site logo

mongodb.applicationinsights's People

Contributors

blushingpenguin avatar milkshakeuk avatar richardszalay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mongodb.applicationinsights's Issues

Experiencing timeouts with Atlas Serverless cluster

Hi

We've been using this library for years with our classic Atlas cluster, but since switching to an Atlas Serverless cluster, we've started seeing intermittent timeout exceptions:

MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server.
---> System.TimeoutException: The operation has timed out.
at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadAsync(Stream stream, Byte[] buffer, Int32 offset, Int32 count, TimeSpan timeout, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytesAsync(Stream stream, Byte[] buffer, Int32 offset, Int32 count, TimeSpan timeout, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync(CancellationToken cancellationToken)

The application is an Azure App Service, and the pattern of failures is that all requests succeed until there's a period of idling, after which the next one will timeout.

At first, I didn't consider the possibility that it had anything to do with this library, so I reached out to the MongoDB Atlas team and wondered if they are aware of any issues related to slow cold starts or similar. But they suggested that I try and see if I can reproduce it when creating a MongoClient directly without using this library, so for the last couple of days, I've been switching back and forth and I can indeed confirm that the timeouts only occur when this library is used.

Do you have any clue why this would happen?

Azure Application Map Support for multiple Slot

Hi! Does it have support for the Azure Application Map for different slots?
When I use on an App Service that has Production Slot and Development Slot the request log can not differentiate between both. It seems like I', always using the Production Slot.

In the picture, the PRD communicates with MongoDB but the truth is that DEV does.
question

Thanks!

Insert command tracing disabling.

Is it possible to disable insert command output?
As I see AppInsights service gets all data which is inserted in Mongo, which is an unwanted behavior.

image

Too many open connections after using MongoDB.ApplicationInsights

Hello there,

Last week we released a new version of one of our services with this library to get more info about the usage of MongoDB. This apps runs in our kubernetes cluster and our MongoDB is a mongodb as a service. We didn't see any problems at first, everything apparently was working as intended. After a while I notice that this service was OOMKilled a lot of times during the week after the release (in simple terms, the container was rebooted because it used more memory than we allowed it to have). So we put the threshold bigger, and today, for our surprise we got notified by MongoDB that our connection limit reached 80% of the limit, than after some minutes close to 100%. Only thing we did in this deploy was to add this library to help us with the Application Insights metrics.

So here are some charts that I got from the MongoDB. You can see that from 12 of setember there was a peak of commands with is followed with peak of connections:
mongodb-operations
mongodb-connections

The pikes and the valleys is because as the connections go up, memory consumption goes up, than the pod is killed and restarted, than goes again. Each chart is from one server in our replica set. After we removed the use of library:
mongodb-operations-connections

So, this is the expected number of connections, we don't have a huge MongoDb use yet, these ones are shared instances since it's cheaper and it's ok for us.

I checked the library implementation and didn't find any reason for this, so maybe the way we are configuring it is wrong. This is what we have configured:

.AddSingleton<IMongoClientFactory>(
    sp => new MongoClientFactory(
         sp.GetService<TelemetryClient>(),
         new MongoApplicationInsightsSettings()
))

We use repository pattern and all references are used as AddScoped. If needed I can post all. We use this IMongoClientFactory in our MongoDatabaseProvider (we need the SslProtocols.Tls12 to connect to mongo):

namespace Some.NameSpace
{
    using System;
    using System.Security.Authentication;
    using Configuration;
    using global::MongoDB.Driver;

    // this class is added as scoped
    public class MongoDatabaseProvider : IDataBaseProvider<IMongoDatabase>
    {
        public MongoDatabaseProvider(IMongoDbSettings settings, IMongoClientFactory mongoClientFactory)
        {
            this.Settings = settings ?? throw new ArgumentNullException(nameof(settings));
            if (!settings.UseSsl)
            {
                this.Client = new MongoClient(settings.ConnectionString);
            }
            else
            {
                var mongodbSettings = MongoClientSettings.FromUrl(
                    new MongoUrl(settings.ConnectionString)
                );

                mongodbSettings.SslSettings = new SslSettings { EnabledSslProtocols = SslProtocols.Tls12 };
                // this factory already tests if there is application insights configuration
                this.Client = mongoClientFactory?.GetClient(mongodbSettings) ?? new MongoClient(mongodbSettings);
            }
        }

        private IMongoClient Client { get; }
        private IMongoDbSettings Settings { get; }
        public IMongoDatabase GetDatabase()
        {
            return this.Client.GetDatabase(this.Settings.Database);
        }
    }
}

Can someone have a look if we did something wrong? Maybe we cant register the factory as singleton?

End to End Transaction - Incorrect nesting

Hi,

Thank you for this nuget package it has helped us capture MongoDb calls in our application insights.

I have come across an issue where the nesting of end to end transaction event list is not nested correctly in the timeline, possibly related to parentId on the events.

See image below.

image

Package vulnerability due to transitive packages

Aquascaner has reported some issues due to this library ( MongoDB.ApplicationInsights ) dependency on NETStandard.Library 1.6.1

┌────────────────────────────────┬───────────────┬──────────┬───────────────────┬───────────────┬───────────────────────────────────────────────────────────┐
│            Library             │ Vulnerability │ Severity │ Installed Version │ Fixed Version │                           Title                           │
├────────────────────────────────┼───────────────┼──────────┼───────────────────┼───────────────┼───────────────────────────────────────────────────────────┤
│ System.Net.Http                │ CVE-2018-8292 │ HIGH     │ 4.3.0             │ 4.3.4         │ .NET Core: information disclosure due to authentication   │
│                                │               │          │                   │               │ information exposed in a redirect...                      │
│                                │               │          │                   │               │ https://avd.aquasec.com/nvd/cve-2018-8292                 │
├────────────────────────────────┼───────────────┤          │                   ├───────────────┼───────────────────────────────────────────────────────────┤
│ System.Text.RegularExpressions │ CVE-2019-0820 │          │                   │ 4.3.1         │ dotnet: timeouts for regular expressions are not enforced │
│                                │               │          │                   │               │ https://avd.aquasec.com/nvd/cve-2019-0820                 │
└────────────────────────────────┴───────────────┴──────────┴───────────────────┴───────────────┴───────────────────────────────────────────────────────────┘

I am not sure how to solve this issue, because all versions of netstartard depends on a vulnerable version of the packages.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.