rollbar / Rollbar.NET

Rollbar for .NET
https://docs.rollbar.com/docs/dotnet
MIT License
65 stars 44 forks source link

Telemetry in DotNet Core 3.1 is not initialized #626

Closed vipetrul closed 2 years ago

vipetrul commented 2 years ago

Describe the bug Using Rollbar within DotNet Core 3.1

services.AddHttpContextAccessor();

            var config = new RollbarInfrastructureConfig("api-key-here", "Development");

            var telemetryOptions = new RollbarTelemetryOptions(true, 20)
            {
                TelemetryAutoCollectionTypes = TelemetryType.Log | TelemetryType.Error | TelemetryType.Network
            };
            config.RollbarTelemetryOptions.Reconfigure(telemetryOptions);

            var dataSecurityOptions = new RollbarDataSecurityOptions
            {
                ScrubFields = new string[]
                {
                    nameof(Patient.mrn),
                    nameof(Patient.lastName),
                    nameof(Patient.dateOfBirth),
                }
            };

            config.RollbarLoggerConfig.RollbarDataSecurityOptions.Reconfigure(dataSecurityOptions);

            RollbarInfrastructure.Instance.Init(config);

          <State of RollbarInfrastructure.Instance.TelemetryCollector is in screenshot below>
serviceCollection.AddLogging(logging =>
                logging
                    .ClearProviders()
                    .AddLambdaLogger(new LambdaLoggerOptions()
                    {
                        IncludeCategory = false,
                        IncludeLogLevel = true,
                        IncludeNewline = true,
                        IncludeEventId = true,
                        IncludeException = true,
                        IncludeScopes = false,
                    }));

            serviceCollection.AddRollbarLogger(opt =>
            {
                opt.Filter = (loggerName, loglevel) => loglevel >= LogLevel.Error;
            });

2022-03-25_09h03_36

Later, when invoking WEB API action method, instance of RollbarInfrastructure.Instance.TelemetryCollector within that action method looks like this: 2022-03-25_09h06_37

When error is thrown within the action method, error is correctly captured within Rollbar, but none of Telemetry is captured. Further more, even if I try to manually push telemetry to TelemetryCollector, it is not captured either.

Another interesting point, is that configuration options that are sent to Rollbar completely missing Telemetry configuration:

"notifier": {
    "version": "5.1.2", 
    "name": "Rollbar.NET (Rollbar.Net Notifier SDK)", 
    "configured_options": {
      "RollbarPayloadAdditionOptions": {
        "Person": null, 
        "Server": null
      }, 
      "HttpProxyOptions": {
        "ProxyAddress": null, 
        "ProxyUsername": null, 
        "ProxyPassword": null
      }, 
      "RollbarDeveloperOptions": {
        "WrapReportedExceptionWithRollbarException": true, 
        "LogLevel": "debug", 
        "RethrowExceptionsAfterReporting": false, 
        "Enabled": true, 
        "PayloadPostTimeout": "00:00:30", 
        "Transmit": true
      }, 
      "RollbarDataSecurityOptions": {
        "IpAddressCollectionPolicy": "Collect", 
        "PersonDataCollectionPolicies": "None", 
        "ScrubSafelistFields": [], 
        "ScrubFields": [
          "mrn", 
          "lastName", 
          "dateOfBirth"
        ]
      }, 
      "RollbarDestinationOptions": {
        "Environment": "Development", 
        "EndPoint": "https://api.rollbar.com/api/1/", 
        "AccessToken": "api-key-here"
      }
    }

Rollbar Client - Rollbar.NET Hosting Environment (please complete the following information):

Expected behavior Logging telemetry is captured with the exception.