public void ShouldParseVcapCredentials()
        {
            var credentials = MetricsCredentialParser.ParseVcapServices(VcapCredentialsJson);

            credentials.AccessKey.Should().Be("abcd123");
            credentials.EndPoint.Should().Be("https://api.pcf.io/metrics");
        }
示例#2
0
 /// <summary>
 ///     Creates a new set of PCF Metrics Forwarder settings from built-in environment variables.
 /// </summary>
 /// <returns>A new settings instance.</returns>
 public static PcfMetricForwarderSettings FromEnvironment(int maximumBatchSize      = DefaultBatchSize,
                                                          TimeSpan?maxBatchInterval = null, TimeSpan?pcfHttpTimeout    = null, bool debugLogging  = false,
                                                          bool errorLogging         = true, ITimeProvider timeProvider = null, bool applySuffixes = true)
 {
     if (PcfEnvironment.IsRunningPcf)
     {
         return(new PcfMetricForwarderSettings(new PcfIdentity(
                                                   PcfEnvironment.Instance.Value.VCAP_APPLICATION.ApplicationId,
                                                   PcfEnvironment.Instance.Value.CF_INSTANCE_GUID,
                                                   PcfEnvironment.Instance.Value.CF_INSTANCE_INDEX ?? 0),
                                               MetricsCredentialParser.ParseVcapServices(), maximumBatchSize, maxBatchInterval, pcfHttpTimeout,
                                               debugLogging, errorLogging, timeProvider, applySuffixes));
     }
     else
     {
         return(new PcfMetricForwarderSettings(new PcfIdentity(
                                                   null,
                                                   null,
                                                   0),
                                               new MetricsForwarderCredentials(null, null), maximumBatchSize, maxBatchInterval, pcfHttpTimeout,
                                               debugLogging, errorLogging, timeProvider, applySuffixes));
     }
 }