Skip to content

Commit

Permalink
OpenTelemetry.Exporter.InfluxDB nullable support (#1314)
Browse files Browse the repository at this point in the history
  • Loading branch information
Havret authored Aug 25, 2023
1 parent fc4dc0d commit 94f1542
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#nullable enable
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Bucket.get -> string
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Bucket.get -> string?
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Bucket.set -> void
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Endpoint.get -> System.Uri
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Endpoint.get -> System.Uri?
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Endpoint.set -> void
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.FlushInterval.get -> int
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.FlushInterval.set -> void
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.InfluxDBMetricsExporterOptions() -> void
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.MetricsSchema.get -> OpenTelemetry.Exporter.InfluxDB.MetricsSchema
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.MetricsSchema.set -> void
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Org.get -> string
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Org.get -> string?
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Org.set -> void
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Token.get -> string
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Token.get -> string?
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Token.set -> void
OpenTelemetry.Exporter.InfluxDB.MetricsSchema
OpenTelemetry.Exporter.InfluxDB.MetricsSchema.None = 0 -> OpenTelemetry.Exporter.InfluxDB.MetricsSchema
OpenTelemetry.Exporter.InfluxDB.MetricsSchema.TelegrafPrometheusV1 = 1 -> OpenTelemetry.Exporter.InfluxDB.MetricsSchema
OpenTelemetry.Exporter.InfluxDB.MetricsSchema.TelegrafPrometheusV2 = 2 -> OpenTelemetry.Exporter.InfluxDB.MetricsSchema
OpenTelemetry.Metrics.InfluxDBExporterExtensions
static OpenTelemetry.Metrics.InfluxDBExporterExtensions.AddInfluxDBMetricsExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action<OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions> configure) -> OpenTelemetry.Metrics.MeterProviderBuilder
static OpenTelemetry.Metrics.InfluxDBExporterExtensions.AddInfluxDBMetricsExporter(this OpenTelemetry.Metrics.MeterProviderBuilder! builder, System.Action<OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions!>! configure) -> OpenTelemetry.Metrics.MeterProviderBuilder!
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#nullable enable
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Bucket.get -> string
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Bucket.get -> string?
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Bucket.set -> void
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Endpoint.get -> System.Uri
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Endpoint.get -> System.Uri?
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Endpoint.set -> void
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.FlushInterval.get -> int
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.FlushInterval.set -> void
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.InfluxDBMetricsExporterOptions() -> void
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.MetricsSchema.get -> OpenTelemetry.Exporter.InfluxDB.MetricsSchema
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.MetricsSchema.set -> void
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Org.get -> string
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Org.get -> string?
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Org.set -> void
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Token.get -> string
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Token.get -> string?
OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions.Token.set -> void
OpenTelemetry.Exporter.InfluxDB.MetricsSchema
OpenTelemetry.Exporter.InfluxDB.MetricsSchema.None = 0 -> OpenTelemetry.Exporter.InfluxDB.MetricsSchema
OpenTelemetry.Exporter.InfluxDB.MetricsSchema.TelegrafPrometheusV1 = 1 -> OpenTelemetry.Exporter.InfluxDB.MetricsSchema
OpenTelemetry.Exporter.InfluxDB.MetricsSchema.TelegrafPrometheusV2 = 2 -> OpenTelemetry.Exporter.InfluxDB.MetricsSchema
OpenTelemetry.Metrics.InfluxDBExporterExtensions
static OpenTelemetry.Metrics.InfluxDBExporterExtensions.AddInfluxDBMetricsExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action<OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions> configure) -> OpenTelemetry.Metrics.MeterProviderBuilder
static OpenTelemetry.Metrics.InfluxDBExporterExtensions.AddInfluxDBMetricsExporter(this OpenTelemetry.Metrics.MeterProviderBuilder! builder, System.Action<OpenTelemetry.Exporter.InfluxDB.InfluxDBMetricsExporterOptions!>! configure) -> OpenTelemetry.Metrics.MeterProviderBuilder!
2 changes: 1 addition & 1 deletion src/OpenTelemetry.Exporter.InfluxDB/IMetricsWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ namespace OpenTelemetry.Exporter.InfluxDB;

internal interface IMetricsWriter
{
void Write(Metric metric, Resource resource, WriteApi writeApi);
void Write(Metric metric, Resource? resource, WriteApi writeApi);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static MeterProviderBuilder AddInfluxDBMetricsExporter(this MeterProvider
var options = new InfluxDBMetricsExporterOptions();
configure.Invoke(options);
var influxDbClientOptions = new InfluxDBClientOptions(options.Endpoint.ToString());
var influxDbClientOptions = new InfluxDBClientOptions(options.Endpoint?.ToString());
if (!string.IsNullOrWhiteSpace(options.Bucket))
{
influxDbClientOptions.Bucket = options.Bucket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ public class InfluxDBMetricsExporterOptions
/// <summary>
/// Gets or sets HTTP/S destination for line protocol.
/// </summary>
public Uri Endpoint { get; set; }
public Uri? Endpoint { get; set; }

/// <summary>
/// Gets or sets name of InfluxDB organization that owns the destination bucket.
/// </summary>
public string Org { get; set; }
public string? Org { get; set; }

/// <summary>
/// Gets or sets the name of InfluxDB bucket to which signals will be written.
/// </summary>
public string Bucket { get; set; }
public string? Bucket { get; set; }

/// <summary>
/// Gets or sets the authentication token for InfluxDB.
/// </summary>
public string Token { get; set; }
public string? Token { get; set; }

/// <summary>
/// Gets or sets the chosen metrics schema to write.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<MinVerTagPrefix>Exporter.InfluxDB-</MinVerTagPrefix>
<EnableAnalysis>true</EnableAnalysis>
<IncludeSharedExceptionExtensionsSource>true</IncludeSharedExceptionExtensionsSource>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry.Exporter.InfluxDB/PointDataExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static PointData Tags(this PointData pointData, ReadOnlyTagCollection tag
return pointData;
}

public static PointData Tags(this PointData pointData, IEnumerable<KeyValuePair<string, object>> tags)
public static PointData Tags(this PointData pointData, IEnumerable<KeyValuePair<string, object>>? tags)
{
if (tags == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace OpenTelemetry.Exporter.InfluxDB;

internal sealed class TelegrafPrometheusWriterV1 : IMetricsWriter
{
public void Write(Metric metric, Resource resource, WriteApi writeApi)
public void Write(Metric metric, Resource? resource, WriteApi writeApi)
{
var measurement = metric.Name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace OpenTelemetry.Exporter.InfluxDB;

internal sealed class TelegrafPrometheusWriterV2 : IMetricsWriter
{
public void Write(Metric metric, Resource resource, WriteApi writeApi)
public void Write(Metric metric, Resource? resource, WriteApi writeApi)
{
var measurement = "prometheus";
var metricName = metric.Name;
Expand Down

0 comments on commit 94f1542

Please sign in to comment.