Skip to content

Commit

Permalink
Use consistent pattern for namespace of extension methods (#1576)
Browse files Browse the repository at this point in the history
* Change PrometheusRouteBuilderExtensions namespace to Microsoft.AspNetCore.Builder

* Change ConsoleExporterLoggingExtensions namespace to OpenTelemetry.Logs

* Change namespace in example app

* Change namespace of extension methods for InMemoryExporter

* Change ResourceBuilderExtensions namespace to OpenTelemetry.Resources

* Add comment for extension methods not contained in namespace of type they are extending

* Update comment

* Update changelog

Co-authored-by: Cijo Thomas <[email protected]>
  • Loading branch information
alanwest and cijothomas authored Nov 18, 2020
1 parent 5995fd9 commit b710c31
Show file tree
Hide file tree
Showing 25 changed files with 80 additions and 52 deletions.
2 changes: 1 addition & 1 deletion docs/logs/getting-started/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
// limitations under the License.
// </copyright>

using OpenTelemetry.Trace;
#if NETCOREAPP2_1
using Microsoft.Extensions.DependencyInjection;
#endif
using Microsoft.Extensions.Logging;
using OpenTelemetry.Logs;

public class Program
{
Expand Down
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Api/ActivityContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

using System.Diagnostics;

// The ActivityContext class is in the System.Diagnostics namespace.
// These extension methods on ActivityContext are intentionally not placed in the
// same namespace as Activity to prevent name collisions in the future.
// The OpenTelemetry namespace is used because ActivityContext applies to all types
// of telemetry data - i.e. traces, metrics, and logs.
namespace OpenTelemetry
{
/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Api/Trace/ActivityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
using System.Runtime.CompilerServices;
using OpenTelemetry.Internal;

// The Activity class is in the System.Diagnostics namespace.
// These extension methods on Activity are intentionally not placed in the
// same namespace as Activity to prevent name collisions in the future.
// The OpenTelemetry.Trace namespace is used because Activity is analogous
// to Span in OpenTelemetry.
namespace OpenTelemetry.Trace
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ OpenTelemetry.Exporter.ConsoleExporterOutputTargets.Console = 1 -> OpenTelemetry
OpenTelemetry.Exporter.ConsoleExporterOutputTargets.Debug = 2 -> OpenTelemetry.Exporter.ConsoleExporterOutputTargets
OpenTelemetry.Trace.ConsoleExporterHelperExtensions
override OpenTelemetry.Exporter.ConsoleExporter<T>.Export(in OpenTelemetry.Batch<T> batch) -> OpenTelemetry.ExportResult
static OpenTelemetry.Trace.ConsoleExporterHelperExtensions.AddConsoleExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Exporter.ConsoleExporterOptions> configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.ConsoleExporterHelperExtensions.AddConsoleExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Exporter.ConsoleExporterOptions> configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OpenTelemetry.Exporter.ConsoleExporterOutputTargets
OpenTelemetry.Exporter.ConsoleExporterOutputTargets.Console = 1 -> OpenTelemetry.Exporter.ConsoleExporterOutputTargets
OpenTelemetry.Exporter.ConsoleExporterOutputTargets.Debug = 2 -> OpenTelemetry.Exporter.ConsoleExporterOutputTargets
OpenTelemetry.Trace.ConsoleExporterHelperExtensions
OpenTelemetry.Trace.ConsoleExporterLoggingExtensions
OpenTelemetry.Logs.ConsoleExporterLoggingExtensions
override OpenTelemetry.Exporter.ConsoleExporter<T>.Export(in OpenTelemetry.Batch<T> batch) -> OpenTelemetry.ExportResult
static OpenTelemetry.Trace.ConsoleExporterHelperExtensions.AddConsoleExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Exporter.ConsoleExporterOptions> configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.ConsoleExporterLoggingExtensions.AddConsoleExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions, System.Action<OpenTelemetry.Exporter.ConsoleExporterOptions> configure = null) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions
static OpenTelemetry.Logs.ConsoleExporterLoggingExtensions.AddConsoleExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions, System.Action<OpenTelemetry.Exporter.ConsoleExporterOptions> configure = null) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OpenTelemetry.Exporter.ConsoleExporterOutputTargets
OpenTelemetry.Exporter.ConsoleExporterOutputTargets.Console = 1 -> OpenTelemetry.Exporter.ConsoleExporterOutputTargets
OpenTelemetry.Exporter.ConsoleExporterOutputTargets.Debug = 2 -> OpenTelemetry.Exporter.ConsoleExporterOutputTargets
OpenTelemetry.Trace.ConsoleExporterHelperExtensions
OpenTelemetry.Trace.ConsoleExporterLoggingExtensions
OpenTelemetry.Logs.ConsoleExporterLoggingExtensions
override OpenTelemetry.Exporter.ConsoleExporter<T>.Export(in OpenTelemetry.Batch<T> batch) -> OpenTelemetry.ExportResult
static OpenTelemetry.Trace.ConsoleExporterHelperExtensions.AddConsoleExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Exporter.ConsoleExporterOptions> configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.ConsoleExporterLoggingExtensions.AddConsoleExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions, System.Action<OpenTelemetry.Exporter.ConsoleExporterOptions> configure = null) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions
static OpenTelemetry.Logs.ConsoleExporterLoggingExtensions.AddConsoleExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions, System.Action<OpenTelemetry.Exporter.ConsoleExporterOptions> configure = null) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.Console/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* `AddConsoleExporter` extension method for logs moved from
`OpenTelemetry.Trace` namespace to `OpenTelemetry.Logs` namespace.
([#1576](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1576))

## 1.0.0-rc1.1

Released 2020-Nov-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
#if NET461 || NETSTANDARD2_0
using System;
using OpenTelemetry.Exporter;
using OpenTelemetry.Logs;

namespace OpenTelemetry.Trace
namespace OpenTelemetry.Logs
{
public static class ConsoleExporterLoggingExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OpenTelemetry.Exporter.InMemoryExporter<T>
OpenTelemetry.Exporter.InMemoryExporter<T>.InMemoryExporter(System.Collections.Generic.ICollection<T> exportedItems) -> void
OpenTelemetry.InMemoryExporterHelperExtensions
OpenTelemetry.Trace.InMemoryExporterHelperExtensions
override OpenTelemetry.Exporter.InMemoryExporter<T>.Export(in OpenTelemetry.Batch<T> batch) -> OpenTelemetry.ExportResult
static OpenTelemetry.InMemoryExporterHelperExtensions.AddInMemoryExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Collections.Generic.ICollection<System.Diagnostics.Activity> exportedItems) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.InMemoryExporterHelperExtensions.AddInMemoryExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Collections.Generic.ICollection<System.Diagnostics.Activity> exportedItems) -> OpenTelemetry.Trace.TracerProviderBuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OpenTelemetry.Exporter.InMemoryExporter<T>
OpenTelemetry.Exporter.InMemoryExporter<T>.InMemoryExporter(System.Collections.Generic.ICollection<T> exportedItems) -> void
OpenTelemetry.InMemoryExporterHelperExtensions
OpenTelemetry.Trace.InMemoryExporterHelperExtensions
override OpenTelemetry.Exporter.InMemoryExporter<T>.Export(in OpenTelemetry.Batch<T> batch) -> OpenTelemetry.ExportResult
static OpenTelemetry.InMemoryExporterHelperExtensions.AddInMemoryExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Collections.Generic.ICollection<System.Diagnostics.Activity> exportedItems) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.InMemoryExporterHelperExtensions.AddInMemoryExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Collections.Generic.ICollection<System.Diagnostics.Activity> exportedItems) -> OpenTelemetry.Trace.TracerProviderBuilder
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Microsoft.Extensions.Logging.InMemoryExporterLoggingExtensions
OpenTelemetry.Logs.InMemoryExporterLoggingExtensions
OpenTelemetry.Exporter.InMemoryExporter<T>
OpenTelemetry.Exporter.InMemoryExporter<T>.InMemoryExporter(System.Collections.Generic.ICollection<T> exportedItems) -> void
OpenTelemetry.InMemoryExporterHelperExtensions
OpenTelemetry.Trace.InMemoryExporterHelperExtensions
override OpenTelemetry.Exporter.InMemoryExporter<T>.Export(in OpenTelemetry.Batch<T> batch) -> OpenTelemetry.ExportResult
static Microsoft.Extensions.Logging.InMemoryExporterLoggingExtensions.AddInMemoryExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions, System.Collections.Generic.ICollection<OpenTelemetry.Logs.LogRecord> exportedItems) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions
static OpenTelemetry.InMemoryExporterHelperExtensions.AddInMemoryExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Collections.Generic.ICollection<System.Diagnostics.Activity> exportedItems) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Logs.InMemoryExporterLoggingExtensions.AddInMemoryExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions, System.Collections.Generic.ICollection<OpenTelemetry.Logs.LogRecord> exportedItems) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions
static OpenTelemetry.Trace.InMemoryExporterHelperExtensions.AddInMemoryExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Collections.Generic.ICollection<System.Diagnostics.Activity> exportedItems) -> OpenTelemetry.Trace.TracerProviderBuilder
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Microsoft.Extensions.Logging.InMemoryExporterLoggingExtensions
OpenTelemetry.Logs.InMemoryExporterLoggingExtensions
OpenTelemetry.Exporter.InMemoryExporter<T>
OpenTelemetry.Exporter.InMemoryExporter<T>.InMemoryExporter(System.Collections.Generic.ICollection<T> exportedItems) -> void
OpenTelemetry.InMemoryExporterHelperExtensions
OpenTelemetry.Trace.InMemoryExporterHelperExtensions
override OpenTelemetry.Exporter.InMemoryExporter<T>.Export(in OpenTelemetry.Batch<T> batch) -> OpenTelemetry.ExportResult
static Microsoft.Extensions.Logging.InMemoryExporterLoggingExtensions.AddInMemoryExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions, System.Collections.Generic.ICollection<OpenTelemetry.Logs.LogRecord> exportedItems) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions
static OpenTelemetry.InMemoryExporterHelperExtensions.AddInMemoryExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Collections.Generic.ICollection<System.Diagnostics.Activity> exportedItems) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Logs.InMemoryExporterLoggingExtensions.AddInMemoryExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions, System.Collections.Generic.ICollection<OpenTelemetry.Logs.LogRecord> exportedItems) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions
static OpenTelemetry.Trace.InMemoryExporterHelperExtensions.AddInMemoryExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Collections.Generic.ICollection<System.Diagnostics.Activity> exportedItems) -> OpenTelemetry.Trace.TracerProviderBuilder
7 changes: 7 additions & 0 deletions src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

* `AddInMemoryExporter` extension method for traces moved from
`OpenTelemetry` namespace to `OpenTelemetry.Trace` namespace.
([#1576](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1576))
* `AddInMemoryExporter` extension method for logs moved from
`Microsoft.Extensions.Logging` namespace to `OpenTelemetry.Logs` namespace.
([#1576](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1576))

## 1.0.0-rc1.1

Released 2020-Nov-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
using System.Collections.Generic;
using System.Diagnostics;
using OpenTelemetry.Exporter;
using OpenTelemetry.Trace;

namespace OpenTelemetry
namespace OpenTelemetry.Trace
{
public static class InMemoryExporterHelperExtensions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
#if NET461 || NETSTANDARD2_0
using System;
using System.Collections.Generic;
using OpenTelemetry;
using OpenTelemetry.Exporter;
using OpenTelemetry.Logs;

namespace Microsoft.Extensions.Logging
namespace OpenTelemetry.Logs
{
public static class InMemoryExporterLoggingExtensions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ OpenTelemetry.Exporter.Prometheus.PrometheusExporterOptions
OpenTelemetry.Exporter.Prometheus.PrometheusExporterOptions.PrometheusExporterOptions() -> void
OpenTelemetry.Exporter.Prometheus.PrometheusExporterOptions.Url.get -> string
OpenTelemetry.Exporter.Prometheus.PrometheusExporterOptions.Url.set -> void
OpenTelemetry.Exporter.Prometheus.PrometheusRouteBuilderExtensions
Microsoft.AspNetCore.Builder.PrometheusRouteBuilderExtensions
override OpenTelemetry.Exporter.Prometheus.PrometheusExporter.ExportAsync(System.Collections.Generic.IEnumerable<OpenTelemetry.Metrics.Export.Metric> metrics, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<OpenTelemetry.Metrics.Export.MetricExporter.ExportResult>
static OpenTelemetry.Exporter.Prometheus.PrometheusExporterExtensions.GetMetricsCollection(this OpenTelemetry.Exporter.Prometheus.PrometheusExporter exporter) -> string
static OpenTelemetry.Exporter.Prometheus.PrometheusExporterExtensions.WriteMetricsCollection(this OpenTelemetry.Exporter.Prometheus.PrometheusExporter exporter, System.IO.StreamWriter writer) -> void
static OpenTelemetry.Exporter.Prometheus.PrometheusRouteBuilderExtensions.UsePrometheus(this Microsoft.AspNetCore.Builder.IApplicationBuilder app) -> Microsoft.AspNetCore.Builder.IApplicationBuilder
virtual OpenTelemetry.Exporter.Prometheus.PrometheusExporterMetricsHttpServer.Dispose(bool disposing) -> void
static Microsoft.AspNetCore.Builder.PrometheusRouteBuilderExtensions.UsePrometheus(this Microsoft.AspNetCore.Builder.IApplicationBuilder app) -> Microsoft.AspNetCore.Builder.IApplicationBuilder
virtual OpenTelemetry.Exporter.Prometheus.PrometheusExporterMetricsHttpServer.Dispose(bool disposing) -> void
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Exporter.Prometheus/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

* `UsePrometheus` extension method for adding middleware to an ASP.NET Core
application moved from `OpenTelemetry.Exporter.Prometheus` namespace to
`Microsoft.AspNetCore.Builder` namespace.
([#1576](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1576))

## 1.0.0-rc1.1

Released 2020-Nov-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

#if NETSTANDARD2_0

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using OpenTelemetry.Exporter.Prometheus;

namespace OpenTelemetry.Exporter.Prometheus
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Provides extension methods for <see cref="IApplicationBuilder"/> to add Prometheus Scraper Endpoint.
Expand Down
10 changes: 5 additions & 5 deletions src/OpenTelemetry/.publicApi/net452/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ OpenTelemetry.Resources.Resource.Merge(OpenTelemetry.Resources.Resource other) -
OpenTelemetry.Resources.ResourceBuilder
OpenTelemetry.Resources.ResourceBuilder.Build() -> OpenTelemetry.Resources.Resource
OpenTelemetry.Resources.ResourceBuilder.Clear() -> OpenTelemetry.Resources.ResourceBuilder
OpenTelemetry.ResourceBuilderExtensions
OpenTelemetry.Resources.ResourceBuilderExtensions
OpenTelemetry.Sdk
OpenTelemetry.SimpleExportProcessor<T>
OpenTelemetry.SimpleExportProcessor<T>.SimpleExportProcessor(OpenTelemetry.BaseExporter<T> exporter) -> void
Expand Down Expand Up @@ -226,11 +226,11 @@ override sealed OpenTelemetry.BaseExportProcessor<T>.OnEnd(T data) -> void
override sealed OpenTelemetry.BaseExportProcessor<T>.OnStart(T data) -> void
readonly OpenTelemetry.BaseExportProcessor<T>.exporter -> OpenTelemetry.BaseExporter<T>
static OpenTelemetry.ProviderExtensions.GetResource(this OpenTelemetry.BaseProvider baseProvider) -> OpenTelemetry.Resources.Resource
static OpenTelemetry.ResourceBuilderExtensions.AddEnvironmentVariableDetector(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Resources.ResourceBuilderExtensions.AddEnvironmentVariableDetector(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Resources.Resource.Empty.get -> OpenTelemetry.Resources.Resource
static OpenTelemetry.ResourceBuilderExtensions.AddAttributes(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>> attributes) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.ResourceBuilderExtensions.AddService(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder, string serviceName, string serviceNamespace = null, string serviceVersion = null, bool autoGenerateServiceInstanceId = true, string serviceInstanceId = null) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.ResourceBuilderExtensions.AddTelemetrySdk(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Resources.ResourceBuilderExtensions.AddAttributes(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>> attributes) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Resources.ResourceBuilderExtensions.AddService(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder, string serviceName, string serviceNamespace = null, string serviceVersion = null, bool autoGenerateServiceInstanceId = true, string serviceInstanceId = null) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Resources.ResourceBuilderExtensions.AddTelemetrySdk(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Resources.ResourceBuilder.CreateDefault() -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Resources.ResourceBuilder.CreateEmpty() -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Sdk.CreateMeterProviderBuilder() -> OpenTelemetry.Metrics.MeterProviderBuilder
Expand Down
Loading

0 comments on commit b710c31

Please sign in to comment.