public GridLayerDefinition() : base() { Image = "grid.png"; Color = new OgmoColor(0, 0, 0); ExportMode = ExportModes.Bitstring; }
public GridLayerDefinition() : base() { Image = "grid.png"; Color = new OgmoColor(0, 0, 0); ExportMode = ExportModes.Bitstring; }
public void FlushMetricExporterTest(ExportModes mode) { BaseExporter <Metric> exporter = null; switch (mode) { case ExportModes.Push: exporter = new PushOnlyMetricExporter(); break; case ExportModes.Pull: exporter = new PullOnlyMetricExporter(); break; case ExportModes.Pull | ExportModes.Push: exporter = new PushPullMetricExporter(); break; } var reader = new BaseExportingMetricReader(exporter); using var meterProvider = Sdk.CreateMeterProviderBuilder() .AddReader(reader) .Build(); switch (mode) { case ExportModes.Push: Assert.True(reader.Collect()); Assert.True(meterProvider.ForceFlush()); break; case ExportModes.Pull: Assert.False(reader.Collect()); Assert.False(meterProvider.ForceFlush()); Assert.True((exporter as IPullMetricExporter).Collect(-1)); break; case ExportModes.Pull | ExportModes.Push: Assert.True(reader.Collect()); Assert.True(meterProvider.ForceFlush()); break; } }
public BaseExportingMetricReader(BaseExporter <Metric> exporter) { Guard.Null(exporter, nameof(exporter)); this.exporter = exporter; var exportorType = exporter.GetType(); var attributes = exportorType.GetCustomAttributes(typeof(AggregationTemporalityAttribute), true); if (attributes.Length > 0) { var attr = (AggregationTemporalityAttribute)attributes[attributes.Length - 1]; this.PreferredAggregationTemporality = attr.Preferred; this.SupportedAggregationTemporality = attr.Supported; } attributes = exportorType.GetCustomAttributes(typeof(ExportModesAttribute), true); if (attributes.Length > 0) { var attr = (ExportModesAttribute)attributes[attributes.Length - 1]; this.supportedExportModes = attr.Supported; } if (exporter is IPullMetricExporter pullExporter) { if (this.supportedExportModes.HasFlag(ExportModes.Push)) { pullExporter.Collect = this.Collect; } else { pullExporter.Collect = (timeoutMilliseconds) => { using (PullMetricScope.Begin()) { return(this.Collect(timeoutMilliseconds)); } }; } } }
/// <summary> /// Initializes a new instance of the <see cref="BaseExportingMetricReader"/> class. /// </summary> /// <param name="exporter">Exporter instance to export Metrics to.</param> public BaseExportingMetricReader(BaseExporter <Metric> exporter) { Guard.ThrowIfNull(exporter); this.exporter = exporter; var exportorType = exporter.GetType(); var attributes = exportorType.GetCustomAttributes(typeof(ExportModesAttribute), true); if (attributes.Length > 0) { var attr = (ExportModesAttribute)attributes[attributes.Length - 1]; this.supportedExportModes = attr.Supported; } if (exporter is IPullMetricExporter pullExporter) { if (this.supportedExportModes.HasFlag(ExportModes.Push)) { pullExporter.Collect = this.Collect; } else { pullExporter.Collect = (timeoutMilliseconds) => { using (PullMetricScope.Begin()) { return(this.Collect(timeoutMilliseconds)); } }; } } this.exportCalledMessage = $"{nameof(BaseExportingMetricReader)} calling {this.Exporter}.{nameof(this.Exporter.Export)} method."; this.exportSucceededMessage = $"{this.Exporter}.{nameof(this.Exporter.Export)} succeeded."; this.exportFailedMessage = $"{this.Exporter}.{nameof(this.Exporter.Export)} failed."; }
public ExportModesAttribute(ExportModes supported) { this.supportedExportModes = supported; }