Skip to content

Commit 2cfd787

Browse files
Merge branch 'main' into http-propagation
2 parents 1ade316 + 1a65aec commit 2cfd787

File tree

14 files changed

+44
-45
lines changed

14 files changed

+44
-45
lines changed

.github/workflows/apicompatibility.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- uses: actions/checkout@v3
1717
with:
1818
fetch-depth: 0 # fetching all
19-
- uses: actions/setup-dotnet@v3.0.2
19+
- uses: actions/setup-dotnet@v3.0.3
2020
with:
2121
dotnet-version: '7.0.x'
2222

.github/workflows/code-coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- uses: actions/checkout@v3
2424
with:
2525
fetch-depth: 0 # fetching all
26-
- uses: actions/setup-dotnet@v3.0.2
26+
- uses: actions/setup-dotnet@v3.0.3
2727
with:
2828
dotnet-version: '7.0.x'
2929

.github/workflows/dotnet-format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: actions/checkout@v3
2222

2323
- name: Setup .NET Core 7.0
24-
uses: actions/setup-dotnet@v3.0.2
24+
uses: actions/setup-dotnet@v3.0.3
2525
with:
2626
dotnet-version: '7.0.x'
2727

.github/workflows/linux-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ jobs:
2323
with:
2424
fetch-depth: 0 # fetching all
2525

26-
- uses: actions/setup-dotnet@v3.0.2
26+
- uses: actions/setup-dotnet@v3.0.3
2727
with:
2828
dotnet-version: '6.0.x'
2929

30-
- uses: actions/setup-dotnet@v3.0.2
30+
- uses: actions/setup-dotnet@v3.0.3
3131
with:
3232
dotnet-version: '7.0.x'
3333

.github/workflows/publish-packages-1.0.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
fetch-depth: 0 # fetching all
2424
ref: ${{ github.ref || 'main' }}
2525

26-
- uses: actions/setup-dotnet@v3.0.2
26+
- uses: actions/setup-dotnet@v3.0.3
2727
with:
2828
dotnet-version: '7.0.x'
2929

.github/workflows/windows-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
fetch-depth: 0 # fetching all
2525

26-
- uses: actions/setup-dotnet@v3.0.2
26+
- uses: actions/setup-dotnet@v3.0.3
2727
with:
2828
dotnet-version: '7.0.x'
2929

docs/metrics/customizing-the-sdk/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ with the metric are of interest to you.
204204
instrumentName: "MyFruitCounter",
205205
metricStreamConfiguration: new MetricStreamConfiguration
206206
{
207-
TagKeys = new string[] { },
207+
TagKeys = Array.Empty<string>(),
208208
})
209209

210210
...
@@ -255,7 +255,7 @@ default boundaries. This requires the use of
255255
// There are no buckets exported in this case.
256256
.AddView(
257257
instrumentName: "MyHistogram",
258-
new ExplicitBucketHistogramConfiguration { Boundaries = new double[] { } })
258+
new ExplicitBucketHistogramConfiguration { Boundaries = Array.Empty<double>() })
259259
```
260260

261261
```csharp

docs/trace/extending-the-sdk/MyFilteringProcessor.cs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,32 @@
1717
using System;
1818
using System.Diagnostics;
1919
using OpenTelemetry;
20-
using OpenTelemetry.Resources;
21-
using OpenTelemetry.Trace;
2220

2321
/// <summary>
2422
/// A custom processor for filtering <see cref="Activity"/> instances.
2523
/// </summary>
26-
/// <remarks>
27-
/// Note: <see cref="CompositeProcessor{T}"/> is used as the base class because
28-
/// the SDK needs to understand that <c>MyFilteringProcessor</c> wraps an inner
29-
/// processor. Without that understanding some features such as <see
30-
/// cref="Resource"/> would be unavailable because the SDK needs to push state
31-
/// about the parent <see cref="TracerProvider"/> to all processors in the
32-
/// chain.
33-
/// </remarks>
34-
internal sealed class MyFilteringProcessor : CompositeProcessor<Activity>
24+
internal sealed class MyFilteringProcessor : BaseProcessor<Activity>
3525
{
3626
private readonly Func<Activity, bool> filter;
3727

38-
public MyFilteringProcessor(BaseProcessor<Activity> processor, Func<Activity, bool> filter)
39-
: base(new[] { processor })
28+
/// <summary>
29+
/// Initializes a new instance of the <see cref="MyFilteringProcessor"/>
30+
/// class.
31+
/// </summary>
32+
/// <param name="filter">Function used to test if an <see cref="Activity"/>
33+
/// should be recorded or dropped. Return <see langword="true"/> to record
34+
/// or <see langword="false"/> to drop.</param>
35+
public MyFilteringProcessor(Func<Activity, bool> filter)
4036
{
4137
this.filter = filter ?? throw new ArgumentNullException(nameof(filter));
4238
}
4339

4440
public override void OnEnd(Activity activity)
4541
{
46-
// Call the underlying processor
47-
// only if the Filter returns true.
48-
if (this.filter(activity))
42+
// Bypass export if the Filter returns false.
43+
if (!this.filter(activity))
4944
{
50-
base.OnEnd(activity);
45+
activity.ActivityTraceFlags &= ~ActivityTraceFlags.Recorded;
5146
}
5247
}
5348
}

docs/trace/extending-the-sdk/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,20 +270,19 @@ capabilities such as offering easy access to more context (library specific).
270270
### Filtering Processor
271271

272272
Another common use case of writing custom processor is to filter Activities from
273-
being exported. Such a "FilteringProcessor" can be written as a wrapper around
274-
an underlying processor. An example "FilteringProcessor" is shown
273+
being exported. Such a "FilteringProcessor" can be written to toggle the
274+
`Activity.Recorded` flag. An example "FilteringProcessor" is shown
275275
[here](./MyFilteringProcessor.cs).
276276

277-
When using such a filtering processor, instead of using extension method to
278-
register the exporter, they must be registered manually as shown below:
277+
When using such a filtering processor if should be registered BEFORE the
278+
processor containing the exporter which should be bypassed:
279279

280280
```csharp
281281
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
282282
.SetSampler(new MySampler())
283283
.AddSource("OTel.Demo")
284-
.AddProcessor(new MyFilteringProcessor(
285-
new SimpleActivityExportProcessor(new MyExporter("ExporterX")),
286-
(act) => true))
284+
.AddProcessor(new MyFilteringProcessor(activity => true))
285+
.AddProcessor(new SimpleActivityExportProcessor(new MyExporter("ExporterX")))
287286
.Build();
288287
```
289288

src/OpenTelemetry/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
* Fix instrument naming enforcement implementation to match the spec.
6+
([#3821](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3821))
7+
58
* Added support for loading environment variables from `IConfiguration` when
69
using the `MetricReaderOptions` & `BatchExportActivityProcessorOptions`
710
classes.

0 commit comments

Comments
 (0)