Skip to content

Commit

Permalink
Merge with origin/main
Browse files Browse the repository at this point in the history
  • Loading branch information
utpilla committed Mar 4, 2022
2 parents 204b214 + cee9006 commit 872a829
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 89 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/apicompatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,11 @@ on:
jobs:
build-test:
runs-on: windows-latest
# https://github.com/actions/setup-dotnet/issues/122
env:
CheckAPICompatibility: true
DOTNET_MULTILEVEL_LOOKUP: 1
steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: true

- name: Install dependencies
run: dotnet restore

Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,19 @@ on:
jobs:
build-test-report:
runs-on: ${{ matrix.os }}
# https://github.com/actions/setup-dotnet/issues/122

strategy:
fail-fast: false
matrix:
os: [windows-latest]
env:
OS: ${{ matrix.os }}
DOTNET_MULTILEVEL_LOOKUP: 1

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # fetching all

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: true

- name: Install dependencies
run: dotnet restore

Expand Down
32 changes: 0 additions & 32 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,80 +13,48 @@ on:
jobs:
redis-test:
runs-on: ubuntu-latest
# https://github.com/actions/setup-dotnet/issues/122
env:
DOTNET_MULTILEVEL_LOOKUP: 1
strategy:
fail-fast: false
matrix:
version: [netcoreapp3.1,net5.0,net6.0]
steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: true

- name: Run redis docker-compose.integration
run: docker-compose --file=test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/docker-compose.yml --file=build/docker-compose.${{ matrix.version }}.yml --project-directory=. up --exit-code-from=tests --build

sql-test:
runs-on: ubuntu-latest
# https://github.com/actions/setup-dotnet/issues/122
env:
DOTNET_MULTILEVEL_LOOKUP: 1
strategy:
fail-fast: false
matrix:
version: [netcoreapp3.1,net5.0,net6.0]
steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: true

- name: Run sql docker-compose.integration
run: docker-compose --file=test/OpenTelemetry.Instrumentation.SqlClient.Tests/docker-compose.yml --file=build/docker-compose.${{ matrix.version }}.yml --project-directory=. up --exit-code-from=tests --build

w3c-trace-context-test:
runs-on: ubuntu-latest
# https://github.com/actions/setup-dotnet/issues/122
env:
DOTNET_MULTILEVEL_LOOKUP: 1
strategy:
fail-fast: false
matrix:
version: [netcoreapp3.1,net5.0,net6.0]
steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: true

- name: Run W3C Trace Context docker-compose.integration
run: docker-compose --file=test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/docker-compose.yml --file=build/docker-compose.${{ matrix.version }}.yml --project-directory=. up --exit-code-from=tests --build

otlp-exporter-test:
runs-on: ubuntu-latest
# https://github.com/actions/setup-dotnet/issues/122
env:
DOTNET_MULTILEVEL_LOOKUP: 1
strategy:
fail-fast: false
matrix:
version: [netcoreapp3.1,net5.0,net6.0]
steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: true

- name: Run OTLP Exporter docker-compose.integration
run: docker-compose --file=test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/docker-compose.yml --file=build/docker-compose.${{ matrix.version }}.yml --project-directory=. up --exit-code-from=tests --build
18 changes: 0 additions & 18 deletions .github/workflows/linux-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ on:
jobs:
build-test:
runs-on: ubuntu-latest
# https://github.com/actions/setup-dotnet/issues/122
env:
DOTNET_MULTILEVEL_LOOKUP: 1

strategy:
matrix:
Expand All @@ -24,26 +21,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: true

- name: Install dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore

- name: Test ${{ matrix.version }}
env:
DOTNET_MULTILEVEL_LOOKUP: 1
run: dotnet test **/bin/**/${{ matrix.version }}/*.Tests.dll --configuration Release --no-build --logger:"console;verbosity=detailed"
5 changes: 0 additions & 5 deletions .github/workflows/publish-packages-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ jobs:
fetch-depth: 0 # fetching all
ref: ${{ matrix.branches }}

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: true

- name: Install dependencies
run: dotnet restore

Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ on:
jobs:
build-test:
runs-on: windows-latest
# https://github.com/actions/setup-dotnet/issues/122
env:
DOTNET_MULTILEVEL_LOOKUP: 1

strategy:
matrix:
Expand All @@ -24,11 +21,6 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: true

- name: Install dependencies
run: dotnet restore

Expand Down
31 changes: 31 additions & 0 deletions docs/trace/extending-the-sdk/MyResourceDetector.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// <copyright file="MyResourceDetector.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.Collections.Generic;
using OpenTelemetry.Resources;

internal class MyResourceDetector : IResourceDetector
{
public Resource Detect()
{
var attributes = new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("key", "val"),
};

return new Resource(attributes);
}
}
2 changes: 2 additions & 0 deletions docs/trace/extending-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

using System.Diagnostics;
using OpenTelemetry;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;

public class Program
Expand All @@ -27,6 +28,7 @@ public static void Main()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.SetSampler(new MySampler())
.AddSource("OTel.Demo")
.SetResourceBuilder(ResourceBuilder.CreateEmpty().AddDetector(new MyResourceDetector()))
.AddProcessor(new MyProcessor("ProcessorA"))
.AddProcessor(new MyProcessor("ProcessorB"))
.AddProcessor(new SimpleActivityExportProcessor(new MyExporter("ExporterX")))
Expand Down
18 changes: 18 additions & 0 deletions docs/trace/extending-the-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [Building your own instrumentation library](#instrumentation-library)
* [Building your own processor](#processor)
* [Building your own sampler](#sampler)
* [Building your own resource detector](#resource-detector)
* [References](#references)

## Exporter
Expand Down Expand Up @@ -293,11 +294,28 @@ class MySampler : Sampler

A demo sampler is shown [here](./MySampler.cs).

## Resource Detector

OpenTelemetry .NET SDK provides a resource detector for detecting
resource information from the `OTEL_RESOURCE_ATTRIBUTES` and
`OTEL_SERVICE_NAME` environment variables.

Custom resource detectors can be implemented:

* ResourceDetectors should inherit from
`OpenTelemetry.Resources.IResourceDetector`, (which belongs
to the [OpenTelemetry](../../../src/OpenTelemetry/README.md)
package), and implement the `Detect` method.

A demo ResourceDetector is shown [here](./MyResourceDetector.cs).

## References

* [Exporter
specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#span-exporter)
* [Processor
specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#span-processor)
* [Resource
specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md)
* [Sampler
specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#sampler)
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override ExportResult Export(in Batch<Metric> batch)
{
if (resourceAttribute.Key.Equals("service.name"))
{
this.WriteLine("Service.Name" + resourceAttribute.Value);
this.WriteLine("Service.Name=" + resourceAttribute.Value);
}
}
}
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 @@ -114,6 +114,8 @@ OpenTelemetry.ReadOnlyTagCollection.GetEnumerator() -> OpenTelemetry.ReadOnlyTag
OpenTelemetry.ReadOnlyTagCollection.ReadOnlyTagCollection() -> void
OpenTelemetry.Resources.IResourceDetector
OpenTelemetry.Resources.IResourceDetector.Detect() -> OpenTelemetry.Resources.Resource
OpenTelemetry.Resources.Resource.Resource(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>> attributes) -> void
OpenTelemetry.Resources.ResourceBuilder.AddDetector(OpenTelemetry.Resources.IResourceDetector resourceDetector) -> OpenTelemetry.Resources.ResourceBuilder
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 @@ -114,6 +114,8 @@ OpenTelemetry.ReadOnlyTagCollection.GetEnumerator() -> OpenTelemetry.ReadOnlyTag
OpenTelemetry.ReadOnlyTagCollection.ReadOnlyTagCollection() -> void
OpenTelemetry.Resources.IResourceDetector
OpenTelemetry.Resources.IResourceDetector.Detect() -> OpenTelemetry.Resources.Resource
OpenTelemetry.Resources.Resource.Resource(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>> attributes) -> void
OpenTelemetry.Resources.ResourceBuilder.AddDetector(OpenTelemetry.Resources.IResourceDetector resourceDetector) -> OpenTelemetry.Resources.ResourceBuilder
OpenTelemetry.Trace.BatchExportActivityProcessorOptions
OpenTelemetry.Trace.BatchExportActivityProcessorOptions.BatchExportActivityProcessorOptions() -> void
override OpenTelemetry.BaseExportProcessor<T>.OnForceFlush(int timeoutMilliseconds) -> bool
Expand Down
14 changes: 7 additions & 7 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## Unreleased

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

* Perf improvement for Histogram and HistogramSumCount by implementing lock-free
updates.
Expand All @@ -16,18 +16,18 @@
Released 2022-Feb-02

* Make `MetricPoint` of `MetricPointAccessor` readonly.
([2736](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2736))
([#2736](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2736))

* Fail-fast when using AddView with guaranteed conflict.
([2751](https://github.com/open-telemetry/opentelemetry-dotnet/issues/2751))
([#2751](https://github.com/open-telemetry/opentelemetry-dotnet/issues/2751))

* Swallow `ObjectDisposedException` from the `BatchExportProcessor` worker
thread.
([2844](https://github.com/open-telemetry/opentelemetry-dotnet/issues/2844))
([#2844](https://github.com/open-telemetry/opentelemetry-dotnet/issues/2844))

* Performance improvement: when emitting metrics, users are strongly advised to
provide tags with same Key order, to achieve maximum performance.
([2805](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2805/files))
([#2805](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2805/files))

## 1.2.0-rc1

Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry/Resources/Resource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Resource
/// Initializes a new instance of the <see cref="Resource"/> class.
/// </summary>
/// <param name="attributes">An <see cref="IEnumerable{T}"/> of attributes that describe the resource.</param>
internal Resource(IEnumerable<KeyValuePair<string, object>> attributes)
public Resource(IEnumerable<KeyValuePair<string, object>> attributes)
{
if (attributes == null)
{
Expand Down
4 changes: 1 addition & 3 deletions src/OpenTelemetry/Resources/ResourceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ public Resource Build()
return finalResource;
}

// Internal until spec is finalized.
// https://github.com/open-telemetry/oteps/blob/master/text/0111-auto-resource-detection.md
internal ResourceBuilder AddDetector(IResourceDetector resourceDetector)
public ResourceBuilder AddDetector(IResourceDetector resourceDetector)
{
Guard.ThrowIfNull(resourceDetector);

Expand Down

0 comments on commit 872a829

Please sign in to comment.