Skip to content

Commit

Permalink
Merge branch 'main' into feature/prometheus-scope-info
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcoltheart authored Nov 30, 2023
2 parents 937b7da + f592dcf commit 42da2d2
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 168 deletions.
6 changes: 0 additions & 6 deletions test/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.AspNetCore\OpenTelemetry.Instrumentation.AspNetCore.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(RepoRoot)\src\Shared\DiagnosticSourceInstrumentation\DiagnosticSourceListener.cs" Link="Includes\DiagnosticSourceListener.cs" />
<Compile Include="$(RepoRoot)\src\Shared\DiagnosticSourceInstrumentation\DiagnosticSourceSubscriber.cs" Link="Includes\DiagnosticSourceSubscriber.cs" />
<Compile Include="$(RepoRoot)\src\Shared\DiagnosticSourceInstrumentation\ListenerHandler.cs" Link="Includes\ListenerHandler.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.InMemory\OpenTelemetry.Exporter.InMemory.csproj" />
Expand Down
File renamed without changes.

This file was deleted.

32 changes: 15 additions & 17 deletions test/Benchmarks/Logs/LogBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,21 @@
using OpenTelemetry.Logs;

/*
// * Summary *
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19044.1466 (21H2)
Intel Core i7-4790 CPU 3.60GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
.NET SDK=6.0.101
[Host] : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT
DefaultJob : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT
| Method | Mean | Error | StdDev | Gen 0 | Allocated |
|--------------------------------------- |-----------:|----------:|----------:|-------:|----------:|
| NoListener | 72.365 ns | 0.9425 ns | 0.8817 ns | 0.0153 | 64 B |
| NoListenerWithLoggerMessageGenerator | 4.769 ns | 0.0161 ns | 0.0142 ns | - | - |
| OneProcessor | 168.330 ns | 0.6198 ns | 0.5494 ns | 0.0553 | 232 B |
| OneProcessorWithLoggerMessageGenerator | 142.898 ns | 0.5233 ns | 0.4086 ns | 0.0401 | 168 B |
| TwoProcessors | 173.727 ns | 0.5978 ns | 0.4992 ns | 0.0553 | 232 B |
| ThreeProcessors | 174.295 ns | 0.7697 ns | 0.7200 ns | 0.0553 | 232 B |
BenchmarkDotNet v0.13.10, Windows 11 (10.0.23424.1000)
Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
| Method | Mean | Error | StdDev | Median | Gen0 | Allocated |
|--------------------------------------- |-----------:|----------:|----------:|-----------:|-------:|----------:|
| NoListener | 44.633 ns | 0.8442 ns | 1.9733 ns | 43.683 ns | 0.0102 | 64 B |
| NoListenerWithLoggerMessageGenerator | 1.880 ns | 0.0141 ns | 0.0125 ns | 1.879 ns | - | - |
| OneProcessor | 126.857 ns | 1.1861 ns | 1.0514 ns | 126.730 ns | 0.0165 | 104 B |
| OneProcessorWithLoggerMessageGenerator | 112.677 ns | 1.0021 ns | 0.8884 ns | 112.605 ns | 0.0063 | 40 B |
| TwoProcessors | 129.967 ns | 0.8315 ns | 0.7371 ns | 129.850 ns | 0.0165 | 104 B |
| ThreeProcessors | 130.117 ns | 1.1359 ns | 1.0626 ns | 129.991 ns | 0.0165 | 104 B |
*/

namespace Benchmarks.Logs;
Expand Down
29 changes: 23 additions & 6 deletions test/Benchmarks/Logs/LogScopeBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
using Microsoft.Extensions.Logging;
using OpenTelemetry.Logs;

/*
BenchmarkDotNet v0.13.10, Windows 11 (10.0.23424.1000)
Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
| Method | Mean | Error | StdDev | Allocated |
|------------- |---------:|---------:|---------:|----------:|
| ForEachScope | 74.29 ns | 0.605 ns | 0.536 ns | - |
*/

namespace Benchmarks.Logs;

public class LogScopeBenchmarks
Expand All @@ -27,8 +40,10 @@ public class LogScopeBenchmarks

private readonly Action<LogRecordScope, object> callback = (LogRecordScope scope, object state) =>
{
foreach (KeyValuePair<string, object> scopeItem in scope)
foreach (var scopeItem in scope)
{
_ = scopeItem.Key;
_ = scopeItem.Value;
}
};

Expand All @@ -39,19 +54,21 @@ public LogScopeBenchmarks()
this.scopeProvider.Push(new ReadOnlyCollection<KeyValuePair<string, object>>(
new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("item1", "value1"),
new KeyValuePair<string, object>("item2", "value2"),
new("item1", "value1"),
new("item2", "value2"),
}));

this.scopeProvider.Push(new ReadOnlyCollection<KeyValuePair<string, object>>(
new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("item3", "value3"),
new("item3", "value3"),
}));

this.scopeProvider.Push(new ReadOnlyCollection<KeyValuePair<string, object>>(
new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("item4", "value4"),
new KeyValuePair<string, object>("item5", "value5"),
new("item4", "value4"),
new("item5", "value5"),
}));

#pragma warning disable CS0618 // Type or member is obsolete
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="OpenTelemetrySdkBenchmarksActivity.cs" company="OpenTelemetry Authors">
// <copyright file="ActivityCreationBenchmarks.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -21,27 +21,25 @@
using OpenTelemetry.Trace;

/*
// * Summary *
BenchmarkDotNet v0.13.10, Windows 11 (10.0.23424.1000)
Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
BenchmarkDotNet=v0.13.2, OS=Windows 10 (10.0.19044.2130/21H2/November2021Update)
Intel Core i7-4790 CPU 3.60GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
.NET SDK=7.0.100-preview.7.22377.5
[Host] : .NET 6.0.10 (6.0.1022.47605), X64 RyuJIT AVX2
DefaultJob : .NET 6.0.10 (6.0.1022.47605), X64 RyuJIT AVX2
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|--------------------------------------------------------- |---------:|--------:|--------:|-------:|----------:|
| CreateActivity_NoopProcessor | 457.9 ns | 1.39 ns | 1.23 ns | 0.0992 | 416 B |
| CreateActivity_WithParentContext_NoopProcessor | 104.8 ns | 0.43 ns | 0.36 ns | - | - |
| CreateActivity_WithParentId_NoopProcessor | 221.9 ns | 0.44 ns | 0.39 ns | 0.0343 | 144 B |
| CreateActivity_WithAttributes_NoopProcessor | 541.4 ns | 3.32 ns | 2.94 ns | 0.1488 | 624 B |
| CreateActiviti_WithKind_NoopProcessor | 437.5 ns | 2.05 ns | 1.92 ns | 0.0992 | 416 B |
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|----------------------------------------------- |----------:|---------:|---------:|-------:|----------:|
| CreateActivity_NoopProcessor | 307.12 ns | 5.769 ns | 6.172 ns | 0.0663 | 416 B |
| CreateActivity_WithParentContext_NoopProcessor | 75.18 ns | 0.399 ns | 0.354 ns | - | - |
| CreateActivity_WithParentId_NoopProcessor | 156.52 ns | 1.609 ns | 1.426 ns | 0.0229 | 144 B |
| CreateActivity_WithAttributes_NoopProcessor | 372.34 ns | 6.215 ns | 4.852 ns | 0.0992 | 624 B |
| CreateActivity_WithKind_NoopProcessor | 302.24 ns | 5.859 ns | 8.402 ns | 0.0663 | 416 B |
*/

namespace Benchmarks.Trace;

public class OpenTelemetrySdkBenchmarksActivity
public class ActivityCreationBenchmarks
{
private readonly ActivitySource benchmarkSource = new("Benchmark");
private readonly ActivityContext parentCtx = new(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.None);
Expand Down Expand Up @@ -76,5 +74,5 @@ public void GlobalCleanup()
public void CreateActivity_WithAttributes_NoopProcessor() => ActivityCreationScenarios.CreateActivityWithAttributes(this.benchmarkSource);

[Benchmark]
public void CreateActiviti_WithKind_NoopProcessor() => ActivityCreationScenarios.CreateActivityWithKind(this.benchmarkSource);
public void CreateActivity_WithKind_NoopProcessor() => ActivityCreationScenarios.CreateActivityWithKind(this.benchmarkSource);
}
21 changes: 9 additions & 12 deletions test/Benchmarks/Trace/SamplerBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,18 @@
using OpenTelemetry.Trace;

/*
// * Summary *
BenchmarkDotNet v0.13.10, Windows 11 (10.0.23424.1000)
Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19044.1889 (21H2)
Intel Core i7-4790 CPU 3.60GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
.NET SDK=7.0.100-preview.7.22377.5
[Host] : .NET 6.0.8 (6.0.822.36306), X64 RyuJIT
DefaultJob : .NET 6.0.8 (6.0.822.36306), X64 RyuJIT
| Method | Mean | Error | StdDev | Gen 0 | Allocated |
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|------------------------------ |---------:|--------:|--------:|-------:|----------:|
| SamplerNotModifyingTraceState | 398.6 ns | 7.48 ns | 7.68 ns | 0.0782 | 328 B |
| SamplerModifyingTraceState | 411.8 ns | 2.38 ns | 2.11 ns | 0.0782 | 328 B |
| SamplerAppendingTraceState | 428.5 ns | 2.54 ns | 2.25 ns | 0.0916 | 384 B |
| SamplerNotModifyingTraceState | 293.3 ns | 3.55 ns | 3.15 ns | 0.0520 | 328 B |
| SamplerModifyingTraceState | 289.4 ns | 5.64 ns | 6.27 ns | 0.0520 | 328 B |
| SamplerAppendingTraceState | 312.7 ns | 6.07 ns | 8.10 ns | 0.0610 | 384 B |
*/

namespace Benchmarks.Trace;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="OpenTelemetrySdkBenchmarks.cs" company="OpenTelemetry Authors">
// <copyright file="SpanCreationBenchmarks.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,9 +19,31 @@
using OpenTelemetry;
using OpenTelemetry.Trace;

/*
BenchmarkDotNet v0.13.10, Windows 11 (10.0.23424.1000)
Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated |
|--------------------------------- |-----------:|----------:|-----------:|------:|--------:|-------:|----------:|
| CreateSpan_Sampled | 357.256 ns | 2.1430 ns | 1.7895 ns | 61.41 | 0.40 | 0.0701 | 440 B |
| CreateSpan_ParentContext | 354.797 ns | 2.4225 ns | 2.2660 ns | 60.93 | 0.46 | 0.0787 | 496 B |
| CreateSpan_Attributes_Sampled | 460.082 ns | 8.7219 ns | 16.3818 ns | 81.52 | 2.88 | 0.1135 | 712 B |
| CreateSpan_WithSpan | 439.489 ns | 8.7722 ns | 21.3526 ns | 79.36 | 2.81 | 0.1030 | 648 B |
| CreateSpan_Active | 348.698 ns | 4.3437 ns | 3.8506 ns | 59.98 | 0.64 | 0.0701 | 440 B |
| CreateSpan_Active_GetCurrent | 357.866 ns | 7.1779 ns | 9.0777 ns | 62.41 | 1.51 | 0.0701 | 440 B |
| CreateSpan_Attributes_NotSampled | 360.546 ns | 3.6948 ns | 3.2753 ns | 61.96 | 0.63 | 0.0815 | 512 B |
| CreateSpan_Noop | 5.818 ns | 0.0248 ns | 0.0207 ns | 1.00 | 0.00 | - | - |
| CreateSpan_Attributes_Noop | 15.953 ns | 0.3446 ns | 0.3539 ns | 2.75 | 0.07 | 0.0115 | 72 B |
| CreateSpan_Propagate_Noop | 12.320 ns | 0.2486 ns | 0.2326 ns | 2.12 | 0.04 | - | - |
*/

namespace Benchmarks.Trace;

public class OpenTelemetrySdkBenchmarks
public class SpanCreationBenchmarks
{
private Tracer alwaysSampleTracer;
private Tracer neverSampleTracer;
Expand Down
37 changes: 17 additions & 20 deletions test/Benchmarks/Trace/TraceBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,26 @@
using OpenTelemetry.Trace;

/*
// * Summary *
BenchmarkDotNet v0.13.10, Windows 11 (10.0.23424.1000)
Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
BenchmarkDotNet=v0.13.2, OS=Windows 10 (10.0.19044.2130/21H2/November2021Update)
Intel Core i7-4790 CPU 3.60GHz(Haswell), 1 CPU, 8 logical and 4 physical cores
.NET SDK= 7.0.100-preview.7.22377.5
[Host] : .NET 6.0.10 (6.0.1022.47605), X64 RyuJIT AVX2
DefaultJob : .NET 6.0.10 (6.0.1022.47605), X64 RyuJIT AVX2
| Method | Mean | Error | StdDev | Gen0 | Allocated |
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|--------------------------------- |----------:|---------:|---------:|-------:|----------:|
| NoListener | 20.86 ns | 0.379 ns | 0.336 ns | - | - |
| PropagationDataListner | 376.51 ns | 1.361 ns | 1.273 ns | 0.0992 | 416 B |
| AllDataListner | 377.38 ns | 2.715 ns | 2.407 ns | 0.0992 | 416 B |
| AllDataAndRecordedListner | 375.79 ns | 3.393 ns | 3.008 ns | 0.0992 | 416 B |
| OneProcessor | 432.98 ns | 1.562 ns | 1.461 ns | 0.0992 | 416 B |
| TwoProcessors | 430.16 ns | 2.538 ns | 2.250 ns | 0.0992 | 416 B |
| ThreeProcessors | 427.39 ns | 3.243 ns | 2.875 ns | 0.0992 | 416 B |
| OneInstrumentation | 411.56 ns | 2.310 ns | 2.161 ns | 0.0992 | 416 B |
| TwoInstrumentations | 422.27 ns | 3.304 ns | 2.929 ns | 0.0992 | 416 B |
| LegacyActivity_ExactMatchMode | 726.59 ns | 4.852 ns | 4.301 ns | 0.0992 | 416 B |
| LegacyActivity_WildcardMatchMode | 825.79 ns | 7.846 ns | 6.955 ns | 0.0992 | 416 B |
| NoListener | 14.00 ns | 0.173 ns | 0.162 ns | - | - |
| PropagationDataListner | 265.96 ns | 4.022 ns | 3.762 ns | 0.0663 | 416 B |
| AllDataListner | 255.14 ns | 1.819 ns | 1.702 ns | 0.0663 | 416 B |
| AllDataAndRecordedListner | 258.32 ns | 2.387 ns | 2.116 ns | 0.0663 | 416 B |
| OneProcessor | 277.12 ns | 2.059 ns | 1.926 ns | 0.0663 | 416 B |
| TwoProcessors | 276.82 ns | 4.442 ns | 4.155 ns | 0.0663 | 416 B |
| ThreeProcessors | 283.12 ns | 1.970 ns | 1.645 ns | 0.0663 | 416 B |
| OneInstrumentation | 281.13 ns | 2.199 ns | 2.057 ns | 0.0663 | 416 B |
| TwoInstrumentations | 273.99 ns | 2.792 ns | 2.475 ns | 0.0663 | 416 B |
| LegacyActivity_ExactMatchMode | 471.38 ns | 2.211 ns | 1.960 ns | 0.0658 | 416 B |
| LegacyActivity_WildcardMatchMode | 496.84 ns | 2.138 ns | 2.000 ns | 0.0658 | 416 B |
*/

namespace Benchmarks.Trace;
Expand Down
16 changes: 16 additions & 0 deletions test/Benchmarks/Trace/TraceShimBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@
using OpenTelemetry;
using OpenTelemetry.Trace;

/*
BenchmarkDotNet v0.13.10, Windows 11 (10.0.23424.1000)
Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
.NET SDK 8.0.100
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|---------------- |-----------:|----------:|----------:|-------:|----------:|
| NoListener | 5.322 ns | 0.0314 ns | 0.0262 ns | - | - |
| OneProcessor | 326.566 ns | 3.4034 ns | 3.0170 ns | 0.0701 | 440 B |
| TwoProcessors | 335.646 ns | 3.8341 ns | 3.3988 ns | 0.0701 | 440 B |
| ThreeProcessors | 336.069 ns | 6.5628 ns | 8.5335 ns | 0.0701 | 440 B |
*/

namespace Benchmarks.Trace;

public class TraceShimBenchmarks
Expand Down

0 comments on commit 42da2d2

Please sign in to comment.