Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AzureMonitorDistro] New Public API for Azure Monitor Distro #35250

Merged
merged 2 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

### Features Added

* Added new public APIs `Services.AddOpenTelemetry().WithAzureMonitor()` and `Services.AddOpenTelemetry().WithAzureMonitor(Action<AzureMonitorOptions> configureAzureMonitor)`.

### Breaking Changes

* Removed public APIs `Services.AddAzureMonitor()`, `Services.AddAzureMonitor(AzureMonitorOptions options)` and `Services.AddAzureMonitor(Action<AzureMonitorOptions> configureAzureMonitor)`.

### Bugs Fixed

### Other Changes
Expand All @@ -14,7 +18,7 @@

### Other Changes

- Upgraded dependent `Azure.Core` to `1.30.0` due to an [issue in `ArrayBackedPropertyBag`](https://github.com/Azure/azure-sdk-for-net/pull/34800) in `Azure.Core` version `1.29.0`.
* Upgraded dependent `Azure.Core` to `1.30.0` due to an [issue in `ArrayBackedPropertyBag`](https://github.com/Azure/azure-sdk-for-net/pull/34800) in `Azure.Core` version `1.29.0`.

## 1.0.0-beta.1 (2023-03-07)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ To enable Azure Monitor Distro, add `AddAzureMonitor()` to your `Program.cs` fil
var builder = WebApplication.CreateBuilder(args);

// The following line enables Azure Monitor Distro.
builder.Services.AddAzureMonitor();
builder.Services.AddOpenTelemetry().WithAzureMonitor();

// This code adds other services for your application.
builder.Services.AddMvc();
Expand All @@ -55,7 +55,7 @@ To enable Azure Monitor Distro with a hard-coded connection string, add `AddAzur
var builder = WebApplication.CreateBuilder(args);

// The following line enables Azure Monitor Distro with hard-coded connection string.
builder.Services.AddAzureMonitor(o => o.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000");
builder.Services.AddOpenTelemetry().WithAzureMonitor(o => o.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000");

// This code adds other services for your application.
builder.Services.AddMvc();
Expand All @@ -71,7 +71,7 @@ Azure Active Directory (AAD) authentication is an optional feature that can be u

```C#
// Call AddAzureMonitor and set Credential to authenticate through Active Directory.
rajkumar-rangaraj marked this conversation as resolved.
Show resolved Hide resolved
builder.Services.AddAzureMonitor(o =>
builder.Services.AddOpenTelemetry().WithAzureMonitor(o =>
{
o.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000";
o.Credential = new DefaultAzureCredential();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
namespace Azure.Monitor.OpenTelemetry.AspNetCore
{
public static partial class AzureMonitorExtensions
{
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAzureMonitor(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAzureMonitor(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Azure.Monitor.OpenTelemetry.AspNetCore.AzureMonitorOptions options) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAzureMonitor(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action<Azure.Monitor.OpenTelemetry.AspNetCore.AzureMonitorOptions> configureAzureMonitor) { throw null; }
}
public partial class AzureMonitorOptions
public partial class AzureMonitorOptions : Azure.Core.ClientOptions
{
public AzureMonitorOptions() { }
public string ConnectionString { get { throw null; } set { } }
public Azure.Core.TokenCredential Credential { get { throw null; } set { } }
public bool DisableOfflineStorage { get { throw null; } set { } }
public bool EnableLogs { get { throw null; } set { } }
public bool EnableMetrics { get { throw null; } set { } }
public bool EnableTraces { get { throw null; } set { } }
public string StorageDirectory { get { throw null; } set { } }
}
public static partial class OpenTelemetryBuilderExtensions
{
public static OpenTelemetry.OpenTelemetryBuilder WithAzureMonitor(this OpenTelemetry.OpenTelemetryBuilder builder) { throw null; }
public static OpenTelemetry.OpenTelemetryBuilder WithAzureMonitor(this OpenTelemetry.OpenTelemetryBuilder builder, System.Action<Azure.Monitor.OpenTelemetry.AspNetCore.AzureMonitorOptions> configureAzureMonitor) { throw null; }
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
#nullable disable

using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Monitor.OpenTelemetry.Exporter;

namespace Azure.Monitor.OpenTelemetry.AspNetCore
{
/// <summary>
/// Options that allow users to configure the Azure Monitor.
/// </summary>
public class AzureMonitorOptions
public class AzureMonitorOptions : ClientOptions
{
/// <summary>
/// The Connection String provides users with a single configuration setting to identify the Azure Monitor resource and endpoint.
Expand All @@ -37,43 +36,11 @@ public class AzureMonitorOptions
/// </summary>
public bool DisableOfflineStorage { get; set; }

/// <summary>
/// Gets or sets a value indicating whether Logs should be enabled.
/// </summary>
public bool EnableLogs { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether Metrics should be enabled.
/// </summary>
public bool EnableMetrics { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether Traces should be enabled.
/// </summary>
public bool EnableTraces { get; set; } = true;

/// <summary>
/// Override the default directory for offline storage.
/// </summary>
public string StorageDirectory { get; set; }

// Used for testing purpose
internal HttpPipelineTransport Transport;

internal void Clone(AzureMonitorOptions options)
{
if (options != null)
{
ConnectionString = options.ConnectionString;
DisableOfflineStorage = options.DisableOfflineStorage;
EnableLogs = options.EnableLogs;
EnableMetrics = options.EnableMetrics;
EnableTraces = options.EnableTraces;
StorageDirectory = options.StorageDirectory;
Transport = options.Transport;
}
}

internal void SetValueToExporterOptions(AzureMonitorExporterOptions exporterOptions)
{
exporterOptions.ConnectionString = ConnectionString;
Expand Down
Loading