Skip to content

Commit

Permalink
Merge branch 'main' into sem-conv-v1.27.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek authored Sep 18, 2024
2 parents efe509e + 0bcf991 commit 38550be
Show file tree
Hide file tree
Showing 21 changed files with 328 additions and 123 deletions.
2 changes: 1 addition & 1 deletion build/Common.nonprod.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<SupportedNetTargets>net8.0;net6.0</SupportedNetTargets>
<XUnitRunnerVisualStudioPkgVer>[2.8.2,3.0)</XUnitRunnerVisualStudioPkgVer>
<XUnitPkgVer>[2.9.0,3.0)</XUnitPkgVer>
<WiremockNetPkgVer>[1.6.1,2.0)</WiremockNetPkgVer>
<WiremockNetPkgVer>[1.6.3,2.0)</WiremockNetPkgVer>
</PropertyGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true'">
Expand Down
3 changes: 1 addition & 2 deletions build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<NuGetAudit>true</NuGetAudit>
<!-- NuGetAuditMode will be uncommented in the future PR when all issues will be fixed. -->
<!--<NuGetAuditMode>all</NuGetAuditMode>-->
<NuGetAuditMode>all</NuGetAuditMode>
<NuGetAuditLevel>low</NuGetAuditLevel>
</PropertyGroup>

Expand Down
4 changes: 3 additions & 1 deletion examples/wcf/client-core/Examples.Wcf.Client.DotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
<PackageReference Include="System.ServiceModel.Http" Version="4.7.0" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="$(OpenTelemetryCoreLatestVersion)" />
<!-- System.Text.Json is indirect reference. It is needed to upgrade it directly to avoid https://github.com/advisories/GHSA-hh2w-p6rv-4g7w -->
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 9 additions & 2 deletions examples/wcf/shared/Examples.Wcf.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@

<PropertyGroup>
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<TargetFrameworks>net8.0;net462</TargetFrameworks>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="System.ServiceModel.Primitives" Version="4.7.0" />
</ItemGroup>

<ItemGroup>
<!-- System.Security.Cryptography.Xml is indirect reference. It is needed to upgrade it directly to avoid https://github.com/advisories/GHSA-rxg9-xrhp-64gj -->
<PackageReference Include="System.Security.Cryptography.Xml" Version="4.7.1" />
<!-- System.Drawing.Common is indirect reference. It is needed to upgrade it directly to avoid https://github.com/advisories/GHSA-rxg9-xrhp-64gj -->
<PackageReference Include="System.Drawing.Common" Version="4.7.3" />
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Exporter.InfluxDB/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
* Updated OpenTelemetry core component version(s) to `1.9.0`.
([#1888](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1888))

* Updated `InfluxDB.Client` to `4.18.0` to mitigate [CVE-2024-45302](https://github.com/advisories/GHSA-4rr6-2v9v-wcpc)
and [CVE-2024-30105](https://github.com/advisories/GHSA-hh2w-p6rv-4g7w)
in transitive dependencies.
([#2073](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2073))

## 1.0.0-alpha.3

Released 2023-Oct-13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="InfluxDB.Client" Version="4.12.0" />
<PackageReference Include="InfluxDB.Client" Version="4.18.0" />
<PackageReference Include="OpenTelemetry" Version="$(OpenTelemetryCoreLatestVersion)" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ static Confluent.Kafka.OpenTelemetryConsumeResultExtensions.TryExtractPropagatio
static Confluent.Kafka.OpenTelemetryProducerBuilderExtensions.AsInstrumentedProducerBuilder<TKey, TValue>(this Confluent.Kafka.ProducerBuilder<TKey, TValue>! producerBuilder) -> Confluent.Kafka.InstrumentedProducerBuilder<TKey, TValue>!
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddKafkaConsumerInstrumentation<TKey, TValue>(this OpenTelemetry.Metrics.MeterProviderBuilder! builder) -> OpenTelemetry.Metrics.MeterProviderBuilder!
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddKafkaConsumerInstrumentation<TKey, TValue>(this OpenTelemetry.Metrics.MeterProviderBuilder! builder, Confluent.Kafka.InstrumentedConsumerBuilder<TKey, TValue>! consumerBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder!
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddKafkaConsumerInstrumentation<TKey, TValue>(this OpenTelemetry.Metrics.MeterProviderBuilder! builder, string? name) -> OpenTelemetry.Metrics.MeterProviderBuilder!
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddKafkaConsumerInstrumentation<TKey, TValue>(this OpenTelemetry.Metrics.MeterProviderBuilder! builder, string? name, Confluent.Kafka.InstrumentedConsumerBuilder<TKey, TValue>? consumerBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder!
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddKafkaProducerInstrumentation<TKey, TValue>(this OpenTelemetry.Metrics.MeterProviderBuilder! builder) -> OpenTelemetry.Metrics.MeterProviderBuilder!
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddKafkaProducerInstrumentation<TKey, TValue>(this OpenTelemetry.Metrics.MeterProviderBuilder! builder, Confluent.Kafka.InstrumentedProducerBuilder<TKey, TValue>! producerBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder!
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddKafkaProducerInstrumentation<TKey, TValue>(this OpenTelemetry.Metrics.MeterProviderBuilder! builder, string? name) -> OpenTelemetry.Metrics.MeterProviderBuilder!
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddKafkaProducerInstrumentation<TKey, TValue>(this OpenTelemetry.Metrics.MeterProviderBuilder! builder, string? name, Confluent.Kafka.InstrumentedProducerBuilder<TKey, TValue>? producerBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddKafkaConsumerInstrumentation<TKey, TValue>(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddKafkaConsumerInstrumentation<TKey, TValue>(this OpenTelemetry.Trace.TracerProviderBuilder! builder, Confluent.Kafka.InstrumentedConsumerBuilder<TKey, TValue>! consumerBuilder) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddKafkaConsumerInstrumentation<TKey, TValue>(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string? name) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddKafkaConsumerInstrumentation<TKey, TValue>(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string? name, Confluent.Kafka.InstrumentedConsumerBuilder<TKey, TValue>? consumerBuilder) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddKafkaProducerInstrumentation<TKey, TValue>(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddKafkaProducerInstrumentation<TKey, TValue>(this OpenTelemetry.Trace.TracerProviderBuilder! builder, Confluent.Kafka.InstrumentedProducerBuilder<TKey, TValue>! producerBuilder) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddKafkaProducerInstrumentation<TKey, TValue>(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string? name) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddKafkaProducerInstrumentation<TKey, TValue>(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string? name, Confluent.Kafka.InstrumentedProducerBuilder<TKey, TValue>? producerBuilder) -> OpenTelemetry.Trace.TracerProviderBuilder!
virtual Confluent.Kafka.OpenTelemetryConsumeAndProcessMessageHandler<TKey, TValue>.Invoke(Confluent.Kafka.ConsumeResult<TKey, TValue>! consumeResult, System.Diagnostics.Activity? activity, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

## Unreleased

## 0.1.0-alpha.2

Released 2024-Sep-18

- Add named instrumentation support
([#2074](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2074))

## 0.1.0-alpha.1

Released 2024-Sep-16

* Initial release
- Initial release
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System.Diagnostics;
using OpenTelemetry.Instrumentation.ConfluentKafka;

namespace Confluent.Kafka;
Expand All @@ -13,6 +12,8 @@ namespace Confluent.Kafka;
/// <typeparam name="TValue">Type of value.</typeparam>
public sealed class InstrumentedConsumerBuilder<TKey, TValue> : ConsumerBuilder<TKey, TValue>
{
private readonly ConfluentKafkaConsumerInstrumentationOptions<TKey, TValue> options = new();

/// <summary>
/// Initializes a new instance of the <see cref="InstrumentedConsumerBuilder{TKey, TValue}"/> class.
/// </summary>
Expand All @@ -22,19 +23,27 @@ public InstrumentedConsumerBuilder(IEnumerable<KeyValuePair<string, string>> con
{
}

internal ConfluentKafkaConsumerInstrumentationOptions<TKey, TValue>? Options { get; set; }
internal bool EnableMetrics
{
get => this.options.Metrics;
set => this.options.Metrics = value;
}

internal bool EnableTraces
{
get => this.options.Traces;
set => this.options.Traces = value;
}

/// <summary>
/// Build a new IConsumer instance.
/// </summary>
/// <returns>an <see cref="IProducer{TKey,TValue}"/>.</returns>
public override IConsumer<TKey, TValue> Build()
{
Debug.Assert(this.Options != null, "Options should not be null.");

ConsumerConfig config = (ConsumerConfig)this.Config;

var consumer = new InstrumentedConsumer<TKey, TValue>(base.Build(), this.Options!);
var consumer = new InstrumentedConsumer<TKey, TValue>(base.Build(), this.options);
consumer.GroupId = config.GroupId;

return consumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public InstrumentedProducer(

public string Name => this.producer.Name;

internal ConfluentKafkaProducerInstrumentationOptions<TKey, TValue> Options => this.options;

public int AddBrokers(string brokers)
{
return this.producer.AddBrokers(brokers);
Expand Down Expand Up @@ -326,6 +324,11 @@ private static void RecordPublish(TopicPartition topicPartition, TimeSpan durati

private Activity? StartPublishActivity(DateTimeOffset start, string topic, Message<TKey, TValue> message, int? partition = null)
{
if (!this.options.Traces)
{
return null;
}

var spanName = string.Concat(topic, " ", ConfluentKafkaCommon.PublishOperationName);
var activity = ConfluentKafkaCommon.ActivitySource.StartActivity(name: spanName, kind: ActivityKind.Producer, startTime: start);
if (activity == null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System.Diagnostics;
using OpenTelemetry.Instrumentation.ConfluentKafka;

namespace Confluent.Kafka;
Expand All @@ -13,6 +12,8 @@ namespace Confluent.Kafka;
/// <typeparam name="TValue">Type of value.</typeparam>
public sealed class InstrumentedProducerBuilder<TKey, TValue> : ProducerBuilder<TKey, TValue>
{
private readonly ConfluentKafkaProducerInstrumentationOptions<TKey, TValue> options = new();

/// <summary>
/// Initializes a new instance of the <see cref="InstrumentedProducerBuilder{TKey, TValue}"/> class.
/// </summary>
Expand All @@ -22,16 +23,24 @@ public InstrumentedProducerBuilder(IEnumerable<KeyValuePair<string, string>> con
{
}

internal ConfluentKafkaProducerInstrumentationOptions<TKey, TValue>? Options { get; set; }
internal bool EnableMetrics
{
get => this.options.Metrics;
set => this.options.Metrics = value;
}

internal bool EnableTraces
{
get => this.options.Traces;
set => this.options.Traces = value;
}

/// <summary>
/// Build a new IProducer instance.
/// </summary>
/// <returns>an <see cref="IProducer{TKey,TValue}"/>.</returns>
public override IProducer<TKey, TValue> Build()
{
Debug.Assert(this.Options != null, "Options should not be null.");

return new InstrumentedProducer<TKey, TValue>(base.Build(), this.Options!);
return new InstrumentedProducer<TKey, TValue>(base.Build(), this.options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Confluent.Kafka;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OpenTelemetry.Instrumentation.ConfluentKafka;
using OpenTelemetry.Internal;

Expand All @@ -25,6 +24,18 @@ public static MeterProviderBuilder AddKafkaConsumerInstrumentation<TKey, TValue>
this MeterProviderBuilder builder)
=> AddKafkaConsumerInstrumentation<TKey, TValue>(builder, name: null, consumerBuilder: null);

/// <summary>
/// Enables automatic data collection of outgoing requests to Kafka.
/// </summary>
/// <typeparam name="TKey">The type of the key.</typeparam>
/// <typeparam name="TValue">The type of the value.</typeparam>
/// <param name="builder"><see cref="MeterProviderBuilder"/> being configured.</param>
/// <param name="name">The name of the instrumentation.</param>
/// <returns>The instance of <see cref="MeterProviderBuilder"/> to chain the calls.</returns>
public static MeterProviderBuilder AddKafkaConsumerInstrumentation<TKey, TValue>(
this MeterProviderBuilder builder, string? name)
=> AddKafkaConsumerInstrumentation<TKey, TValue>(builder, name: name, consumerBuilder: null);

/// <summary>
/// Enables automatic data collection of outgoing requests to Kafka.
/// </summary>
Expand Down Expand Up @@ -58,34 +69,21 @@ public static MeterProviderBuilder AddKafkaConsumerInstrumentation<TKey, TValue>
{
Guard.ThrowIfNull(builder);

name ??= Options.DefaultName;

builder.ConfigureServices(services =>
{
services.Configure<ConfluentKafkaConsumerInstrumentationOptions<TKey, TValue>>(name, EnableMetrics);
});

return builder
.AddMeter(ConfluentKafkaCommon.InstrumentationName)
.AddInstrumentation(sp =>
{
if (consumerBuilder == null)
if (name == null)
{
consumerBuilder = sp.GetRequiredService<InstrumentedConsumerBuilder<TKey, TValue>>();
var options = sp.GetRequiredService<IOptionsMonitor<ConfluentKafkaConsumerInstrumentationOptions<TKey, TValue>>>();
consumerBuilder.Options = options.Get(name);
consumerBuilder ??= sp.GetRequiredService<InstrumentedConsumerBuilder<TKey, TValue>>();
}

if (consumerBuilder.Options == null)
else
{
consumerBuilder.Options = new ConfluentKafkaConsumerInstrumentationOptions<TKey, TValue>();
EnableMetrics(consumerBuilder.Options);
consumerBuilder ??= sp.GetRequiredKeyedService<InstrumentedConsumerBuilder<TKey, TValue>>(name);
}

consumerBuilder.EnableMetrics = true;
return new ConfluentKafkaConsumerInstrumentation<TKey, TValue>(consumerBuilder);
});
}

private static void EnableMetrics<TKey, TValue>(ConfluentKafkaConsumerInstrumentationOptions<TKey, TValue> options) =>
options.Metrics = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Confluent.Kafka;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OpenTelemetry.Instrumentation.ConfluentKafka;
using OpenTelemetry.Internal;

Expand All @@ -25,6 +24,18 @@ public static MeterProviderBuilder AddKafkaProducerInstrumentation<TKey, TValue>
this MeterProviderBuilder builder)
=> AddKafkaProducerInstrumentation<TKey, TValue>(builder, name: null, producerBuilder: null);

/// <summary>
/// Enables automatic data collection of outgoing requests to Kafka.
/// </summary>
/// <typeparam name="TKey">The type of the key.</typeparam>
/// <typeparam name="TValue">The type of the value.</typeparam>
/// <param name="builder"><see cref="MeterProviderBuilder"/> being configured.</param>
/// <param name="name">The name of the instrumentation.</param>
/// <returns>The instance of <see cref="MeterProviderBuilder"/> to chain the calls.</returns>
public static MeterProviderBuilder AddKafkaProducerInstrumentation<TKey, TValue>(
this MeterProviderBuilder builder, string? name)
=> AddKafkaProducerInstrumentation<TKey, TValue>(builder, name: name, producerBuilder: null);

/// <summary>
/// Enables automatic data collection of outgoing requests to Kafka.
/// </summary>
Expand Down Expand Up @@ -58,34 +69,21 @@ public static MeterProviderBuilder AddKafkaProducerInstrumentation<TKey, TValue>
{
Guard.ThrowIfNull(builder);

name ??= Options.DefaultName;

builder.ConfigureServices(services =>
{
services.Configure<ConfluentKafkaProducerInstrumentationOptions<TKey, TValue>>(name, EnableMetrics);
});

return builder
.AddMeter(ConfluentKafkaCommon.InstrumentationName)
.AddInstrumentation(sp =>
{
if (producerBuilder == null)
if (name == null)
{
producerBuilder = sp.GetRequiredService<InstrumentedProducerBuilder<TKey, TValue>>();
var options = sp.GetRequiredService<IOptionsMonitor<ConfluentKafkaProducerInstrumentationOptions<TKey, TValue>>>();
producerBuilder.Options = options.Get(name);
producerBuilder ??= sp.GetRequiredService<InstrumentedProducerBuilder<TKey, TValue>>();
}

if (producerBuilder.Options == null)
else
{
producerBuilder.Options = new ConfluentKafkaProducerInstrumentationOptions<TKey, TValue>();
EnableMetrics(producerBuilder.Options);
producerBuilder ??= sp.GetRequiredKeyedService<InstrumentedProducerBuilder<TKey, TValue>>(name);
}

producerBuilder.EnableMetrics = true;
return new ConfluentKafkaProducerInstrumentation<TKey, TValue>(producerBuilder);
});
}

private static void EnableMetrics<TKey, TValue>(ConfluentKafkaProducerInstrumentationOptions<TKey, TValue> options) =>
options.Metrics = true;
}
Loading

0 comments on commit 38550be

Please sign in to comment.