コード例 #1
0
        public OmsOutput(OmsOutputConfiguration configuration, IHealthReporter healthReporter)
        {
            Requires.NotNull(configuration, nameof(configuration));
            Requires.NotNull(healthReporter, nameof(healthReporter));

            this.healthReporter = healthReporter;
            this.connectionData = CreateConnectionData(configuration);
        }
コード例 #2
0
        public OmsOutput(OmsOutputConfiguration configuration, IHealthReporter healthReporter)
        {
            Requires.NotNull(configuration, nameof(configuration));
            Requires.NotNull(healthReporter, nameof(healthReporter));

            this.healthReporter = healthReporter;
            Initialize(configuration);
        }
コード例 #3
0
        protected virtual OmsConnectionData CreateConnectionData(OmsOutputConfiguration configuration)
        {
            Debug.Assert(configuration != null);

            string workspaceId = configuration.WorkspaceId;

            if (string.IsNullOrWhiteSpace(workspaceId))
            {
                this.healthReporter.ReportProblem($"{nameof(OmsOutput)}: 'workspaceId' configuration parameter is not set");
                return(null);
            }
            string omsWorkspaceKeyBase64 = configuration.WorkspaceKey;

            if (string.IsNullOrWhiteSpace(omsWorkspaceKeyBase64))
            {
                this.healthReporter.ReportProblem($"{nameof(OmsOutput)}: 'workspaceKey' configuration parameter is not set");
                return(null);
            }

            var hasher       = new HMACSHA256(Convert.FromBase64String(omsWorkspaceKeyBase64));
            var retryHandler = new HttpExponentialRetryMessageHandler();
            var httpClient   = new HttpClient(retryHandler);

            if (!string.IsNullOrWhiteSpace(configuration.ServiceDomain))
            {
                httpClient.BaseAddress = new Uri($"https://{workspaceId}.{configuration.ServiceDomain}", UriKind.Absolute);
            }
            else
            {
                httpClient.BaseAddress = new Uri($"https://{workspaceId}.ods.opinsights.azure.com", UriKind.Absolute);
            }

            string logTypeName = configuration.LogTypeName;

            if (string.IsNullOrWhiteSpace(logTypeName))
            {
                logTypeName = "Event";
            }

            return(new OmsConnectionData
            {
                HttpClient = httpClient,
                Hasher = hasher,
                WorkspaceId = workspaceId,
                LogTypeName = logTypeName
            });
        }
コード例 #4
0
        public OmsOutput(IConfiguration configuration, IHealthReporter healthReporter)
        {
            Requires.NotNull(configuration, nameof(configuration));
            Requires.NotNull(healthReporter, nameof(healthReporter));

            this.healthReporter = healthReporter;
            var omsOutputConfiguration = new OmsOutputConfiguration();

            try
            {
                configuration.Bind(omsOutputConfiguration);
            }
            catch
            {
                healthReporter.ReportProblem($"Invalid {nameof(OmsOutput)} configuration encountered: '{configuration.ToString()}'",
                                             EventFlowContextIdentifiers.Configuration);
                throw;
            }

            this.connectionData = CreateConnectionData(omsOutputConfiguration);
        }
コード例 #5
0
 private void Initialize(OmsOutputConfiguration configuration)
 {
     this.connectionData = CreateConnectionData(configuration);
     SerializerSettings  = EventFlowJsonUtilities.GetDefaultSerializerSettings();
 }