Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@

<ItemGroup Condition="$(MSBuildProjectName.StartsWith('Azure.Monitor.OpenTelemetry'))">
<!-- OpenTelemetry dependency approved for Azure.Monitor.OpenTelemetry.Exporter package only -->
<PackageReference Update="OpenTelemetry" Version="1.7.0" />
<PackageReference Update="OpenTelemetry.Exporter.InMemory" Version="1.7.0" />
<PackageReference Update="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
<PackageReference Update="OpenTelemetry" Version="1.8.0" />
<PackageReference Update="OpenTelemetry.Exporter.InMemory" Version="1.8.0" />
<PackageReference Update="OpenTelemetry.Extensions.Hosting" Version="1.8.0" />
<PackageReference Update="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" />
<PackageReference Update="OpenTelemetry.Instrumentation.Http" Version="1.7.0" />
<PackageReference Update="OpenTelemetry.PersistentStorage.FileSystem" Version="1.0.0" />
Expand Down Expand Up @@ -334,7 +334,7 @@
<PackageReference Update="NSubstitute" Version="3.1.0" />
<PackageReference Update="NUnit" Version="3.13.2" />
<PackageReference Update="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Update="OpenTelemetry" Version="1.7.0" />
<PackageReference Update="OpenTelemetry" Version="1.8.0" />
<PackageReference Update="OpenTelemetry.Instrumentation.SqlClient" Version="1.6.0-beta.3" />
<PackageReference Update="Polly" Version="7.1.0" />
<PackageReference Update="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
Expand Down
15 changes: 13 additions & 2 deletions sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@

### Other Changes

* Update OpenTelemetry dependencies
([#43197](https://github.com/Azure/azure-sdk-for-net/pull/43197))
- OpenTelemetry 1.8.0
- OpenTelemetry.Extensions.Hosting 1.8.0

* Removed the necessity for custom resource attributes configuration in
OpenTelemetry logging setup, as the OpenTelemetry .NET SDK's enhancements to
the builder.ConfigureResource method now uniformly set resource attributes
across logs, metrics, and traces.
([#43197](https://github.com/Azure/azure-sdk-for-net/pull/43197))

## 1.2.0-beta.2 (2024-03-12)

### Features Added
Expand All @@ -25,7 +36,7 @@
documentation.
([#42307](https://github.com/Azure/azure-sdk-for-net/pull/42307))

- Enabled support for log collection from Azure SDKs via `Microsoft.Extensions.Logging`. See [Logging with the Azure SDK for .NET](https://learn.microsoft.com/dotnet/azure/sdk/logging)
* Enabled support for log collection from Azure SDKs via `Microsoft.Extensions.Logging`. See [Logging with the Azure SDK for .NET](https://learn.microsoft.com/dotnet/azure/sdk/logging)
for the details.
([#42374](https://github.com/Azure/azure-sdk-for-net/pull/42374))

Expand Down Expand Up @@ -64,7 +75,7 @@
property can be set to `false` to disable live metrics.
([#41872](https://github.com/Azure/azure-sdk-for-net/pull/41872))

- Added an experimental feature for logs emitted within an active tracing
* Added an experimental feature for logs emitted within an active tracing
context to follow the Activity's sampling decision. The feature can be enabled
by setting `OTEL_DOTNET_AZURE_MONITOR_EXPERIMENTAL_ENABLE_LOG_SAMPLING`
environment variable to `true`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ public static class OpenTelemetryBuilderExtensions
/// <item>SQL Client.</item>
/// </list>
/// </remarks>
#pragma warning disable CS0618 // Type or member is obsolete
// Note: OpenTelemetryBuilder is obsolete because users should target
// IOpenTelemetryBuilder for extensions but this method is valid and
// expected to be called to obtain a root builder.
public static OpenTelemetryBuilder UseAzureMonitor(this OpenTelemetryBuilder builder)
#pragma warning restore CS0618 // Type or member is obsolete
{
builder.Services.TryAddSingleton<IConfigureOptions<AzureMonitorOptions>,
DefaultAzureMonitorOptions>();
Expand All @@ -76,7 +81,12 @@ public static OpenTelemetryBuilder UseAzureMonitor(this OpenTelemetryBuilder bui
/// <item>SQL Client.</item>
/// </list>
/// </remarks>
#pragma warning disable CS0618 // Type or member is obsolete
// Note: OpenTelemetryBuilder is obsolete because users should target
// IOpenTelemetryBuilder for extensions but this method is valid and
// expected to be called to obtain a root builder.
public static OpenTelemetryBuilder UseAzureMonitor(this OpenTelemetryBuilder builder, Action<AzureMonitorOptions> configureAzureMonitor)
#pragma warning restore CS0618 // Type or member is obsolete
{
if (builder.Services == null)
{
Expand Down Expand Up @@ -126,10 +136,6 @@ public static OpenTelemetryBuilder UseAzureMonitor(this OpenTelemetryBuilder bui
{
logging.AddOpenTelemetry(builderOptions =>
{
var resourceBuilder = ResourceBuilder.CreateDefault();
configureResource(resourceBuilder);
builderOptions.SetResourceBuilder(resourceBuilder);

Comment thread
rajkumar-rangaraj marked this conversation as resolved.
builderOptions.IncludeFormattedMessage = true;
});
});
Expand Down Expand Up @@ -205,30 +211,16 @@ public static OpenTelemetryBuilder UseAzureMonitor(this OpenTelemetryBuilder bui

private static TracerProviderBuilder AddVendorInstrumentationIfPackageNotReferenced(this TracerProviderBuilder tracerProviderBuilder)
{
var vendorInstrumentationActions = new Dictionary<string, Action>
try
{
{ SqlClientInstrumentationPackageName, () => tracerProviderBuilder.AddSqlClientInstrumentation() },
};

foreach (var packageActionPair in vendorInstrumentationActions)
var instrumentationAssembly = Assembly.Load(SqlClientInstrumentationPackageName);
AzureMonitorAspNetCoreEventSource.Log.FoundInstrumentationPackageReference(SqlClientInstrumentationPackageName);
}
catch
{
Assembly? instrumentationAssembly = null;

try
{
instrumentationAssembly = Assembly.Load(packageActionPair.Key);
AzureMonitorAspNetCoreEventSource.Log.FoundInstrumentationPackageReference(packageActionPair.Key);
}
catch
{
AzureMonitorAspNetCoreEventSource.Log.NoInstrumentationPackageReference(packageActionPair.Key);
}

if (instrumentationAssembly == null)
{
packageActionPair.Value.Invoke();
AzureMonitorAspNetCoreEventSource.Log.VendorInstrumentationAdded(packageActionPair.Key);
}
AzureMonitorAspNetCoreEventSource.Log.NoInstrumentationPackageReference(SqlClientInstrumentationPackageName);
tracerProviderBuilder.AddSqlClientInstrumentation();
AzureMonitorAspNetCoreEventSource.Log.VendorInstrumentationAdded(SqlClientInstrumentationPackageName);
}

return tracerProviderBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

### Other Changes

* Update OpenTelemetry dependencies
([#43197](https://github.com/Azure/azure-sdk-for-net/pull/43197))
- OpenTelemetry 1.8.0

## 1.3.0-beta.1 (2024-02-08)

### Bugs Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Azure.Monitor.OpenTelemetry.LiveMetrics
{
internal sealed class LiveMetricsActivityProcessor : BaseProcessor<Activity>
{
private bool _disposed;
private LiveMetricsResource? _resource;
private readonly Manager _manager;

Expand Down Expand Up @@ -75,27 +74,6 @@ public override void OnEnd(Activity activity)
}
}

protected override void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
try
{
_manager.Dispose();
}
catch (System.Exception)
{
}
}

_disposed = true;
}

base.Dispose(disposing);
}

private void AddExceptionDocument(string exceptionType, string exceptionMessage)
{
var exceptionDocumentIngress = DocumentHelper.CreateException(exceptionType, exceptionMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,34 @@ public static TracerProviderBuilder AddLiveMetrics(
// configuration delegate into options pipeline.
services.Configure(finalOptionsName, configure);
}
});

return builder.AddProcessor(sp =>
{
// SETUP OPTIONS
LiveMetricsExporterOptions exporterOptions;

if (name == null)
// Register Manager as a singleton
services.AddSingleton<Manager>(sp =>
Comment thread
rajkumar-rangaraj marked this conversation as resolved.
{
exporterOptions = sp.GetRequiredService<IOptionsFactory<LiveMetricsExporterOptions>>().Create(finalOptionsName);
LiveMetricsExporterOptions exporterOptions;

// Configuration delegate is executed inline on the fresh instance.
configure?.Invoke(exporterOptions);
}
else
{
// When using named options we can properly utilize Options
// API to create or reuse an instance.
exporterOptions = sp.GetRequiredService<IOptionsMonitor<LiveMetricsExporterOptions>>().Get(finalOptionsName);
}
if (name == null)
{
exporterOptions = sp.GetRequiredService<IOptionsFactory<LiveMetricsExporterOptions>>().Create(finalOptionsName);

// Configuration delegate is executed inline on the fresh instance.
configure?.Invoke(exporterOptions);
}
else
{
// When using named options we can properly utilize Options
// API to create or reuse an instance.
exporterOptions = sp.GetRequiredService<IOptionsMonitor<LiveMetricsExporterOptions>>().Get(finalOptionsName);
}

// INITIALIZE INTERNALS
return new Manager(exporterOptions, new DefaultPlatform());
});
});

// INITIALIZE INTERNALS
var manager = new Manager(exporterOptions, new DefaultPlatform());
return builder.AddProcessor(sp =>
{
var manager = sp.GetRequiredService<Manager>();
Comment thread
rajkumar-rangaraj marked this conversation as resolved.
return new LiveMetricsActivityProcessor(manager);
});
}
Expand Down