Skip to content

Commit

Permalink
Merge branch 'main' into aspnetcore-statuscode-boxing
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch authored Apr 4, 2023
2 parents cf8e256 + b5ee98f commit 0fe5fdf
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.2

Released 2023-Mar-31

## 1.5.0-alpha.1

Released 2023-Mar-07
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.2

Released 2023-Mar-31

## 1.5.0-alpha.1

Released 2023-Mar-07
Expand Down
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

## 1.5.0-alpha.2

Released 2023-Mar-31

## 1.5.0-alpha.1

Released 2023-Mar-07
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.2

Released 2023-Mar-31

* Fixed issue where the `MetricSnapshot` of a histogram did not capture the min
and max values.
([#4306](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4306))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public override void WriteDouble(double d)
WriteI64(BitConverter.DoubleToInt64Bits(d));
}

#if NETSTANDARD2_1_OR_GREATER
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
public override void WriteBinary(ReadOnlySpan<byte> bytes)
{
WriteI32(bytes.Length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public override void WriteDouble(double d)
Transport.Write(PreAllocatedBuffer, 0, 8);
}

#if NETSTANDARD2_1_OR_GREATER
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
public override void WriteBinary(ReadOnlySpan<byte> bytes)
{
Int32ToVarInt((uint)bytes.Length, ref PreAllocatedVarInt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected virtual void Dispose(bool disposing)

public virtual void WriteString(string s)
{
#if NETSTANDARD2_1_OR_GREATER
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
if (s.Length <= 128)
{
Span<byte> buffer = stackalloc byte[256];
Expand All @@ -165,7 +165,7 @@ public virtual void WriteString(string s)
}
}

#if NETSTANDARD2_1_OR_GREATER
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
public abstract void WriteBinary(ReadOnlySpan<byte> bytes);
#endif

Expand Down
7 changes: 7 additions & 0 deletions src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

## 1.5.0-alpha.2

Released 2023-Mar-31

* Enabled performance optimizations for .NET 6.0+ runtimes.
([#4349](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4349))

## 1.5.0-alpha.1

Released 2023-Mar-07
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.2

Released 2023-Mar-31

## 1.5.0-alpha.1

Released 2023-Mar-07
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.2

Released 2023-Mar-31

* Add support for exporting histograms aggregated using the
[Base2 Exponential Bucket Histogram Aggregation](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#base2-exponential-bucket-histogram-aggregation).
([#4337](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4337))
Expand Down
11 changes: 10 additions & 1 deletion src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,16 @@ and environment variables.
The `OtlpExporterOptions` type setters take precedence over the environment variables.

This can be achieved by providing an `Action<OtlpExporterOptions>` delegate to the
`AddOtlpExporter()` method.
`AddOtlpExporter()` method or using `AddOptions<OtlpExporterOptions>()`.

If additional services from the dependency injection are required, they can be
configured like this:

```csharp
services.AddOptions<OtlpExporterOptions>().Configure<Service>((opts, svc) => {
// ...
});
```

TODO: Show metrics specific configuration (i.e MetricReaderOptions).

Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.2

Released 2023-Mar-31

## 1.5.0-alpha.1

Released 2023-Mar-07
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.2

Released 2023-Mar-31

## 1.5.0-alpha.1

Released 2023-Mar-07
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.2

Released 2023-Mar-31

## 1.5.0-alpha.1

Released 2023-Mar-07
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.2

Released 2023-Mar-31

## 1.5.0-alpha.1

Released 2023-Mar-07
Expand Down
35 changes: 35 additions & 0 deletions src/OpenTelemetry.Extensions.Hosting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,41 @@ app.Run();
A fully functional example can be found
[here](https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/examples/AspNetCore).

### Resources

To dynamically add resources at startup from the dependency injection you can
provide an `IResourceDetector`.
To make use of it add it to the dependency injection and they you can use the
`ISerivceProvider` add it to OpenTelemetry:

```csharp
public class MyResourceDetector : IResourceDetector
{
private readonly IWebHostEnvironment webHostEnvironment;

public MyResourceDetector(IWebHostEnvironment webHostEnvironment)
{
this.webHostEnvironment = webHostEnvironment;
}

public Resource Detect()
{
return ResourceBuilder.CreateEmpty()
.AddService(serviceName: this.webHostEnvironment.ApplicationName)
.AddAttributes(new Dictionary<string, object> { ["host.environment"] = this.webHostEnvironment.EnvironmentName })
.Build();
}
}

services.AddSingleton<MyResourceDetector>();

services.AddOpenTelemetry()
.ConfigureResource(builder =>
builder.AddDetector(sp => sp.GetRequiredService<MyResourceDetector>()))
.WithTracing(builder => builder.AddConsoleExporter())
.WithMetrics(builder => builder.AddConsoleExporter());
```

## Migrating from pre-release versions of OpenTelemetry.Extensions.Hosting

Pre-release versions (all versions prior to 1.4.0) of
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Extensions.Propagators/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.2

Released 2023-Mar-31

## 1.5.0-alpha.1

Released 2023-Mar-07
Expand Down
10 changes: 10 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## Unreleased

## 1.5.0-alpha.2

Released 2023-Mar-31

* Enabling `SetErrorStatusOnException` on TracerProvider will now set the
`Status` property on Activity to `ActivityStatusCode.Error` in case of an error.
This will be done in addition to current behavior of setting `otel.status_code`
tag on activity.
([#4336](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4336))

* Add support for configuring the
[Base2 Exponential Bucket Histogram Aggregation](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#base2-exponential-bucket-histogram-aggregation)
using the `AddView` API. This aggregation is supported by OTLP but not yet by
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry/Trace/ExceptionProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ public override void OnEnd(Activity activity)

if (snapshot != pointers)
{
// TODO: Remove this when SetStatus is deprecated
activity.SetStatus(Status.Error);

// For processors/exporters checking `Status` property.
activity.SetStatus(ActivityStatusCode.Error);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void SetErrorStatusOnExceptionEnabled()
}

Assert.Equal(StatusCode.Error, activity.GetStatus().StatusCode);
Assert.Equal(ActivityStatusCode.Error, activity.Status);
}

[Fact]
Expand Down Expand Up @@ -84,6 +85,7 @@ public void SetErrorStatusOnExceptionDisabled()
}

Assert.Equal(StatusCode.Unset, activity.GetStatus().StatusCode);
Assert.Equal(ActivityStatusCode.Unset, activity.Status);
}

[Fact]
Expand Down

0 comments on commit 0fe5fdf

Please sign in to comment.