public static IHealthChecksBuilder AddDatadogPublisher(this IHealthChecksBuilder builder, Action <DatadogConfiguration> configAction)
        {
            builder.Services.AddSingleton <IHealthCheckPublisher>(
                provider =>
            {
                var config = new DatadogConfiguration();
                configAction.Invoke(config);

                var context = new ValidationContext(config);

                Validator.ValidateObject(config, context, true);

                return(new DatadogPublisher(config, new DatadogHttpClient(config)));
            });

            return(builder);
        }
예제 #2
0
 public DatadogPublisher(DatadogConfiguration configuration, DatadogHttpClient client)
 {
     _configuration = configuration;
     _client        = client;
 }
 public DatadogHttpClient(DatadogConfiguration config)
 {
     _client = new HttpClient();
     _url    = $"{config.Url}/v1/series?api_key={config.ApiKey}&application_key={config.ApplicationKey}";
 }