Beispiel #1
0
        public void FromHeaderMutation()
        {
            Assert.Null(CallSettings.FromHeaderMutation(null));
            Action <Metadata> action = metadata => { }; // No-op, but still an action...
            var settings             = CallSettings.FromHeaderMutation(action);

            Assert.Same(action, settings.HeaderMutation);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of <see cref="StackdriverTraceExporter"/> class.
        /// </summary>
        /// <param name="projectId">Project ID to send telemetry to.</param>
        public StackdriverTraceExporter(string projectId)
        {
            this.googleCloudProjectId = new Google.Api.Gax.ResourceNames.ProjectName(projectId);

            // Set header mutation for every outgoing API call to Stackdriver so the BE knows
            // which version of OC client is calling it as well as which version of the exporter
            var callSettings = CallSettings.FromHeaderMutation(StackdriverCallHeaderAppender);

            this.traceServiceSettings = new TraceServiceSettings();
            this.traceServiceSettings.CallSettings = callSettings;
        }
Beispiel #3
0
        public static FirestoreDb Create()
        {
            var firestoreHost     = Environment.GetEnvironmentVariable("FIRESTORE_EMULATOR_HOST") ?? "localhost:8080";
            var matches           = Regex.Match(firestoreHost, "(?<host>.*):(?<port>\\d+)");
            var host              = matches.Groups["host"].Value;
            var port              = int.Parse(matches.Groups["port"].Value);
            var firestoreSettings = new FirestoreSettings
            {
                CallSettings = CallSettings.FromHeaderMutation(x => x.Add("Authorization", "Bearer owner"))
            };

            return(FirestoreDb.Create("na",
                                      FirestoreClient.Create(new Channel(host, port, ChannelCredentials.Insecure), firestoreSettings)));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="StackdriverMetricsExporter"/> class.
        /// </summary>
        /// <param name="projectId">Project ID to send telemetry to.</param>
        /// <param name="monitoredResource">Monitored resource to associate metric telemetry with.</param>
        public StackdriverMetricsExporter(string projectId, MonitoredResource monitoredResource)
        {
            this.monitoredResource = monitoredResource;
            this.projectName       = new ProjectName(projectId);

            // Set header mutation for every outgoing API call to Stackdriver so the BE knows
            // which version of OC client is calling it as well as which version of the exporter
            var metricServiceSettings = new MetricServiceSettings
            {
                CallSettings = CallSettings.FromHeaderMutation(StackdriverCallHeaderAppender),
            };

            this.metricServiceClient = new MetricServiceClientBuilder {
                Settings = metricServiceSettings
            }.Build();
        }
Beispiel #5
0
 public void ToCallOptions_InvalidHeaderMutations(string header, string value) =>
 Assert.Throws <InvalidOperationException>(
     () => CallSettings
     .FromHeaderMutation(metadata => metadata.Add(new Metadata.Entry(header, value)))
     .ToCallOptions(new Mock <IClock>().Object));