Example #1
0
        public static DirectLogSubmissionManager Create(
            DirectLogSubmissionManager?previous,
            ImmutableDirectLogSubmissionSettings settings,
            string serviceName,
            string env,
            string serviceVersion)
        {
            var formatter = new LogFormatter(settings, serviceName, env, serviceVersion);

            if (previous is not null)
            {
                // Only the formatter uses settings that are configurable in code.
                // If that ever changes, need to update the log-shipping integrations that
                // currently cache the sink/settings instances
                return(new DirectLogSubmissionManager(previous.Settings, previous.Sink, formatter));
            }

            if (!settings.IsEnabled)
            {
                return(new DirectLogSubmissionManager(settings, new NullDatadogSink(), formatter));
            }

            var apiFactory = LogsTransportStrategy.Get(settings);
            var logsApi    = new LogsApi(settings.ApiKey, apiFactory);

            return(new DirectLogSubmissionManager(settings, new DatadogSink(logsApi, formatter, settings.BatchingOptions), formatter));
        }
Example #2
0
        public static IApiRequestFactory Get(ImmutableDirectLogSubmissionSettings settings)
        {
#if NETCOREAPP
            Log.Information("Using {FactoryType} for log submission transport.", nameof(HttpClientRequestFactory));
            return(new HttpClientRequestFactory(LogsApiHeaderNames.DefaultHeaders));
#else
            Log.Information("Using {FactoryType} for log submission transport.", nameof(ApiWebRequestFactory));
            return(new ApiWebRequestFactory(LogsApiHeaderNames.DefaultHeaders));
#endif
        }
Example #3
0
        public static IApiRequestFactory Get(ImmutableDirectLogSubmissionSettings settings)
        {
            // Still quite a long time, but we could be sending a lot of data
            var timeout = TimeSpan.FromSeconds(15);

#if NETCOREAPP
            Log.Information("Using {FactoryType} for log submission transport.", nameof(HttpClientRequestFactory));
            return(new HttpClientRequestFactory(settings.IntakeUrl, LogsApiHeaderNames.DefaultHeaders, timeout: timeout));
#else
            Log.Information("Using {FactoryType} for log submission transport.", nameof(ApiWebRequestFactory));
            return(new ApiWebRequestFactory(settings.IntakeUrl, LogsApiHeaderNames.DefaultHeaders, timeout: timeout));
#endif
        }
Example #4
0
 private DirectLogSubmissionManager(ImmutableDirectLogSubmissionSettings settings, IDatadogSink sink, LogFormatter formatter)
 {
     Settings  = settings;
     Sink      = sink;
     Formatter = formatter;
 }