Skip to content

Commit

Permalink
Merge branch 'open-telemetry:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMothra authored Feb 15, 2022
2 parents ba726c5 + 84821ff commit 68d1977
Show file tree
Hide file tree
Showing 11 changed files with 294 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ public override ExportResult Export(in Batch<Activity> batch)
{
foreach (var activity in batch)
{
this.WriteLine($"Activity.Id: {activity.Id}");
if (!string.IsNullOrEmpty(activity.ParentId))
this.WriteLine($"Activity.TraceId: {activity.TraceId}");
this.WriteLine($"Activity.SpanId: {activity.SpanId}");
this.WriteLine($"Activity.TraceFlags: {activity.ActivityTraceFlags}");
if (!string.IsNullOrEmpty(activity.TraceStateString))
{
this.WriteLine($"Activity.ParentId: {activity.ParentId}");
this.WriteLine($"Activity.TraceState: {activity.TraceStateString}");
}

if (activity.ParentSpanId != default)
{
this.WriteLine($"Activity.ParentSpanId: {activity.ParentSpanId}");
}

this.WriteLine($"Activity.ActivitySourceName: {activity.Source.Name}");
Expand All @@ -45,7 +52,7 @@ public override ExportResult Export(in Batch<Activity> batch)
this.WriteLine($"Activity.Duration: {activity.Duration}");
if (activity.TagObjects.Any())
{
this.WriteLine("Activity.TagObjects:");
this.WriteLine("Activity.Tags:");
foreach (var tag in activity.TagObjects)
{
var array = tag.Value as Array;
Expand Down
2 changes: 2 additions & 0 deletions src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ OpenTelemetry.ReadOnlyTagCollection.Enumerator.Enumerator() -> void
OpenTelemetry.ReadOnlyTagCollection.Enumerator.MoveNext() -> bool
OpenTelemetry.ReadOnlyTagCollection.GetEnumerator() -> OpenTelemetry.ReadOnlyTagCollection.Enumerator
OpenTelemetry.ReadOnlyTagCollection.ReadOnlyTagCollection() -> void
OpenTelemetry.Resources.IResourceDetector
OpenTelemetry.Resources.IResourceDetector.Detect() -> OpenTelemetry.Resources.Resource
OpenTelemetry.Trace.BatchExportActivityProcessorOptions
OpenTelemetry.Trace.BatchExportActivityProcessorOptions.BatchExportActivityProcessorOptions() -> void
override OpenTelemetry.BaseExportProcessor<T>.OnForceFlush(int timeoutMilliseconds) -> bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ OpenTelemetry.ReadOnlyTagCollection.Enumerator.Enumerator() -> void
OpenTelemetry.ReadOnlyTagCollection.Enumerator.MoveNext() -> bool
OpenTelemetry.ReadOnlyTagCollection.GetEnumerator() -> OpenTelemetry.ReadOnlyTagCollection.Enumerator
OpenTelemetry.ReadOnlyTagCollection.ReadOnlyTagCollection() -> void
OpenTelemetry.Resources.IResourceDetector
OpenTelemetry.Resources.IResourceDetector.Detect() -> OpenTelemetry.Resources.Resource
OpenTelemetry.Trace.BatchExportActivityProcessorOptions
OpenTelemetry.Trace.BatchExportActivityProcessorOptions.BatchExportActivityProcessorOptions() -> void
override OpenTelemetry.BaseExportProcessor<T>.OnForceFlush(int timeoutMilliseconds) -> bool
Expand Down
3 changes: 3 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Make `IResourceDetector` public to allow custom implementations of resource detectors.
([2897](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2897))

## 1.2.0-rc2

Released 2022-Feb-02
Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry/Resources/IResourceDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace OpenTelemetry.Resources
/// <summary>
/// An interface for Resource detectors.
/// </summary>
internal interface IResourceDetector
public interface IResourceDetector
{
/// <summary>
/// Called to get a resource with attributes from detector.
Expand Down
27 changes: 27 additions & 0 deletions test/OpenTelemetry.Tests.Stress.Logs/DummyProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// <copyright file="DummyProcessor.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using OpenTelemetry;
using OpenTelemetry.Logs;

namespace OpenTelemetry.Tests.Stress;

internal class DummyProcessor : BaseProcessor<LogRecord>
{
public override void OnEnd(LogRecord record)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net462</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests.Stress\Skeleton.cs" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="[6.0.0,)" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\Utils.cs" Link="Includes\Utils.cs" />
</ItemGroup>

</Project>
120 changes: 120 additions & 0 deletions test/OpenTelemetry.Tests.Stress.Logs/Payload.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// <copyright file="Payload.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

namespace OpenTelemetry.Tests.Stress;

internal class Payload
{
public int Field001 = 0;
public float Field002 = 2.718281828f;
public double Field003 = 3.141592653589793d;
public string Field004 = "Hello, World!";
public bool Field005 = true;
public int Field006 = 6;
public int Field007 = 7;
public int Field008 = 8;
public int Field009 = 9;
public int Field010 = 10;
public int Field011 = 11;
public int Field012 = 12;
public int Field013 = 13;
public int Field014 = 14;
public int Field015 = 15;
public int Field016 = 16;
public int Field017 = 17;
public int Field018 = 18;
public int Field019 = 19;
public int Field020 = 20;
public int Field021 = 21;
public int Field022 = 22;
public int Field023 = 23;
public int Field024 = 24;
public int Field025 = 25;
public int Field026 = 26;
public int Field027 = 27;
public int Field028 = 28;
public int Field029 = 29;
public int Field030 = 30;
public int Field031 = 31;
public int Field032 = 32;
public int Field033 = 33;
public int Field034 = 34;
public int Field035 = 35;
public int Field036 = 36;
public int Field037 = 37;
public int Field038 = 38;
public int Field039 = 39;
public int Field040 = 40;
public int Field041 = 41;
public int Field042 = 42;
public int Field043 = 43;
public int Field044 = 44;
public int Field045 = 45;
public int Field046 = 46;
public int Field047 = 47;
public int Field048 = 48;
public int Field049 = 49;
public int Field050 = 50;
public int Field051 = 51;
public int Field052 = 52;
public int Field053 = 53;
public int Field054 = 54;
public int Field055 = 55;
public int Field056 = 56;
public int Field057 = 57;
public int Field058 = 58;
public int Field059 = 59;
public int Field060 = 60;
public int Field061 = 61;
public int Field062 = 62;
public int Field063 = 63;
public int Field064 = 64;
public int Field065 = 65;
public int Field066 = 66;
public int Field067 = 67;
public int Field068 = 68;
public int Field069 = 69;
public int Field070 = 70;
public int Field071 = 71;
public int Field072 = 72;
public int Field073 = 73;
public int Field074 = 74;
public int Field075 = 75;
public int Field076 = 76;
public int Field077 = 77;
public int Field078 = 78;
public int Field079 = 79;
public int Field080 = 80;
public int Field081 = 81;
public int Field082 = 82;
public int Field083 = 83;
public int Field084 = 84;
public int Field085 = 85;
public int Field086 = 86;
public int Field087 = 87;
public int Field088 = 88;
public int Field089 = 89;
public int Field090 = 90;
public int Field091 = 91;
public int Field092 = 92;
public int Field093 = 93;
public int Field094 = 94;
public int Field095 = 95;
public int Field096 = 96;
public int Field097 = 97;
public int Field098 = 98;
public int Field099 = 99;
}
53 changes: 53 additions & 0 deletions test/OpenTelemetry.Tests.Stress.Logs/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// <copyright file="Program.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System.Runtime.CompilerServices;
using Microsoft.Extensions.Logging;
using OpenTelemetry.Logs;

namespace OpenTelemetry.Tests.Stress;

public partial class Program
{
private static ILogger logger;
private static Payload payload = new Payload();

public static void Main()
{
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(options =>
{
options.AddProcessor(new DummyProcessor());
});
});

logger = loggerFactory.CreateLogger<Program>();

Stress(prometheusPort: 9184);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected static void Run()
{
logger.Log(
logLevel: LogLevel.Information,
eventId: 2,
state: payload,
exception: null,
formatter: (state, ex) => string.Empty);
}
}
14 changes: 14 additions & 0 deletions test/OpenTelemetry.Tests.Stress.Logs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# OpenTelemetry Stress Tests for Logs

This is Stress Test specifically for logging, and is
based on the [OpenTelemetry.Tests.Stress](../OpenTelemetry.Tests.Stress/README.md).

* [Running the stress test](#running-the-stress-test)

## Running the stress test

Open a console, run the following command from the current folder:

```sh
dotnet run --framework net6.0 --configuration Release
```
42 changes: 42 additions & 0 deletions test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,48 @@ public void ViewToDropSingleInstrument()
Assert.Equal("counterInteresting", metric.Name);
}

[Fact]
public void ViewToDropSingleInstrumentObservableCounter()
{
using var meter = new Meter(Utils.GetCurrentMethodName());
var exportedItems = new List<Metric>();
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter(meter.Name)
.AddView("observableCounterNotInteresting", new MetricStreamConfiguration() { Aggregation = Aggregation.Drop })
.AddInMemoryExporter(exportedItems)
.Build();

// Expecting one metric stream.
meter.CreateObservableCounter("observableCounterNotInteresting", () => { return 10; }, "ms");
meter.CreateObservableCounter("observableCounterInteresting", () => { return 10; }, "ms");

meterProvider.ForceFlush(MaxTimeToAllowForFlush);
Assert.Single(exportedItems);
var metric = exportedItems[0];
Assert.Equal("observableCounterInteresting", metric.Name);
}

[Fact]
public void ViewToDropSingleInstrumentObservableGauge()
{
using var meter = new Meter(Utils.GetCurrentMethodName());
var exportedItems = new List<Metric>();
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter(meter.Name)
.AddView("observableGaugeNotInteresting", new MetricStreamConfiguration() { Aggregation = Aggregation.Drop })
.AddInMemoryExporter(exportedItems)
.Build();

// Expecting one metric stream.
meter.CreateObservableGauge("observableGaugeNotInteresting", () => { return 10; }, "ms");
meter.CreateObservableGauge("observableGaugeInteresting", () => { return 10; }, "ms");

meterProvider.ForceFlush(MaxTimeToAllowForFlush);
Assert.Single(exportedItems);
var metric = exportedItems[0];
Assert.Equal("observableGaugeInteresting", metric.Name);
}

[Fact]
public void ViewToDropMultipleInstruments()
{
Expand Down

0 comments on commit 68d1977

Please sign in to comment.