Skip to content

Commit

Permalink
Merge branch 'main' into vibankwa/add-otlp-log-integration-test
Browse files Browse the repository at this point in the history
  • Loading branch information
utpilla authored Sep 18, 2023
2 parents 24f01e6 + 224a4cc commit cafcb0c
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 130 deletions.
22 changes: 9 additions & 13 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,23 @@ jobs:
- name: Install dependencies
run: dotnet restore

- name: dotnet build
- name: Build
run: dotnet build --configuration Release --no-restore --property:ExposeExperimentalFeatures=true

# - name: dotnet test
# run: dotnet test --collect:"XPlat Code Coverage" --results-directory:"TestResults" --configuration Release --no-build -- RunConfiguration.DisableAppDomain=true
- name: Test
run: dotnet test --collect:"Code Coverage" --results-directory:"TestResults" --configuration Release --no-restore --no-build -- RunConfiguration.DisableAppDomain=true

- name: dotnet test
run: dotnet test --collect:"Code Coverage" --results-directory:"TestResults" --configuration Release --no-build -- RunConfiguration.DisableAppDomain=true

- name: Process code coverage
run: .\build\process-codecoverage.ps1
shell: powershell

- name: Install report tool
run: dotnet tool install -g dotnet-reportgenerator-globaltool
- name: Install coverage tool
run: dotnet tool install -g dotnet-coverage

- name: Merging test results
run: reportgenerator -reports:TestResults/**/*.xml -targetdir:TestResults -reporttypes:Cobertura -assemblyFilters:"-microsoft.data.sqlclient*;-grpc.core*;-opentracing*"
run: dotnet-coverage merge -r -f cobertura -o ./TestResults/Cobertura.xml ./TestResults/*.coverage

- uses: codecov/[email protected]
env:
OS: ${{ matrix.os }}
with:
file: TestResults/Cobertura.xml
env_vars: OS
flags: unittests
name: Code Coverage for ${{ matrix.os }}
3 changes: 1 addition & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,13 @@
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="7.0.9" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.9" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="[3.11.0-beta1.23402.2]" />
<PackageVersion Include="Microsoft.CodeCoverage" Version="[17.6.3]" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="2.1.2" />
<PackageVersion Include="Microsoft.DotNet.ApiCompat" Version="6.0.0-beta.21308.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="[3.1.6,5.0)" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="3.1.20" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="[6.0.0,)" />
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="[1.0.3,2.0)" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.6.3]" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.7.2,18.0.0)" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="[1.1.1,2.0)" />
<PackageVersion Include="MinVer" Version="[4.3.0,5.0)" />
<PackageVersion Include="Moq" Version="[4.18.4,5.0)" />
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ If you have trouble accessing the doc, please get in touch on

* [Cijo Thomas](https://github.com/cijothomas), Microsoft
* [Reiley Yang](https://github.com/reyang), Microsoft
* [Robert Paj&#x105;k](https://github.com/pellared), Splunk
* [Vishwesh Bankwar](https://github.com/vishweshbankwar), Microsoft

[Emeritus
Expand All @@ -132,6 +131,7 @@ Maintainer/Approver/Triager](https://github.com/open-telemetry/community/blob/ma
* [Liudmila Molkova](https://github.com/lmolkova)
* [Mike Goldsmith](https://github.com/MikeGoldsmith)
* [Paulo Janotti](https://github.com/pjanotti)
* [Robert Paj&#x105;k](https://github.com/pellared)
* [Sergey Kanzhelev](https://github.com/SergeyKanzhelev)
* [Victor Lu](https://github.com/victlu)

Expand Down
1 change: 0 additions & 1 deletion build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" Condition="'$(SkipAnalysis)'!='true'" />
<PackageReference Include="Microsoft.CodeCoverage" PrivateAssets="All" Condition="'$(Configuration)'=='Release'" />
<!--
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" PrivateAssets="All" Condition="'$(SkipAnalysis)'!='true'" />
-->
Expand Down
16 changes: 0 additions & 16 deletions build/process-codecoverage.ps1

This file was deleted.

40 changes: 0 additions & 40 deletions docs/logs/getting-started-console/FoodSupplyLogs.cs

This file was deleted.

53 changes: 29 additions & 24 deletions docs/logs/getting-started-console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,38 @@
using Microsoft.Extensions.Logging;
using OpenTelemetry.Logs;

namespace SourceGeneration;

public class Program
using var loggerFactory = LoggerFactory.Create(builder =>
{
public static void Main()
builder.AddOpenTelemetry(logging =>
{
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(options =>
{
options.IncludeScopes = true;
options.ParseStateValues = true;
options.IncludeFormattedMessage = true;
options.AddConsoleExporter();
});
});
logging.AddConsoleExporter();
});
});

var logger = loggerFactory.CreateLogger<Program>();

var logger = loggerFactory.CreateLogger<Program>();
logger.FoodPriceChanged("artichoke", 9.99);

logger.FoodPriceChanged("artichoke", 9.99);
logger.FoodRecallNotice(
logLevel: LogLevel.Critical,
brandName: "Contoso",
productDescription: "Salads",
productType: "Food & Beverages",
recallReasonDescription: "due to a possible health risk from Listeria monocytogenes",
companyName: "Contoso Fresh Vegetables, Inc.");

public static partial class ApplicationLogs
{
[LoggerMessage(EventId = 1, Level = LogLevel.Information, Message = "Food `{name}` price changed to `{price}`.")]
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);

logger.FoodRecallNotice(
logLevel: LogLevel.Critical,
brandName: "Contoso",
productDescription: "Salads",
productType: "Food & Beverages",
recallReasonDescription: "due to a possible health risk from Listeria monocytogenes",
companyName: "Contoso Fresh Vegetables, Inc.");
}
[LoggerMessage(EventId = 2, Message = "A `{productType}` recall notice was published for `{brandName} {productDescription}` produced by `{companyName}` ({recallReasonDescription}).")]
public static partial void FoodRecallNotice(
this ILogger logger,
LogLevel logLevel,
string brandName,
string productDescription,
string productType,
string recallReasonDescription,
string companyName);
}
25 changes: 7 additions & 18 deletions docs/logs/getting-started-console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,16 @@ package:
dotnet add package OpenTelemetry.Exporter.Console
```

Copy the [FoodSupplyLogs.cs](./FoodSupplyLogs.cs) and [Program.cs](./Program.cs)
files to the project folder.
Update the `Program.cs` file with the code from [Program.cs](./Program.cs).

Run the application again (using `dotnet run`) and you should see the log output
on the console.

```text
LogRecord.Timestamp: 2023-08-03T22:53:51.0194130Z
LogRecord.CategoryName: SourceGeneration.Program
LogRecord.Timestamp: 2023-09-15T06:07:03.5502083Z
LogRecord.CategoryName: Program
LogRecord.Severity: Info
LogRecord.SeverityText: Information
LogRecord.FormattedMessage: Food `artichoke` price changed to `9.99`.
LogRecord.Body: Food `{name}` price changed to `{price}`.
LogRecord.Attributes (Key:Value):
name: artichoke
Expand All @@ -51,17 +49,12 @@ LogRecord.Attributes (Key:Value):
LogRecord.EventId: 1
LogRecord.EventName: FoodPriceChanged
Resource associated with LogRecord:
telemetry.sdk.name: opentelemetry
telemetry.sdk.language: dotnet
telemetry.sdk.version: 1.6.0-alpha.1.55
service.name: unknown_service:getting-started
...
LogRecord.Timestamp: 2023-08-03T22:53:51.0403466Z
LogRecord.CategoryName: SourceGeneration.Program
LogRecord.Timestamp: 2023-09-15T06:07:03.5683511Z
LogRecord.CategoryName: Program
LogRecord.Severity: Fatal
LogRecord.SeverityText: Critical
LogRecord.FormattedMessage: A `Food & Beverages` recall notice was published for `Contoso Salads` produced by `Contoso Fresh Vegetables, Inc.` (due to a possible health risk from Listeria monocytogenes).
LogRecord.Body: A `{productType}` recall notice was published for `{brandName} {productDescription}` produced by `{companyName}` ({recallReasonDescription}).
LogRecord.Attributes (Key:Value):
brandName: Contoso
Expand All @@ -73,11 +66,7 @@ LogRecord.Attributes (Key:Value):
LogRecord.EventId: 2
LogRecord.EventName: FoodRecallNotice
Resource associated with LogRecord:
telemetry.sdk.name: opentelemetry
telemetry.sdk.language: dotnet
telemetry.sdk.version: 1.6.0-alpha.1.55
service.name: unknown_service:getting-started
...
```

Congratulations! You are now collecting logs using OpenTelemetry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ OpenTelemetry.Shims.OpenTracing.TracerShim.BuildSpan(string operationName) -> Op
OpenTelemetry.Shims.OpenTracing.TracerShim.Extract<TCarrier>(OpenTracing.Propagation.IFormat<TCarrier> format, TCarrier carrier) -> OpenTracing.ISpanContext
OpenTelemetry.Shims.OpenTracing.TracerShim.Inject<TCarrier>(OpenTracing.ISpanContext spanContext, OpenTracing.Propagation.IFormat<TCarrier> format, TCarrier carrier) -> void
OpenTelemetry.Shims.OpenTracing.TracerShim.ScopeManager.get -> OpenTracing.IScopeManager
OpenTelemetry.Shims.OpenTracing.TracerShim.TracerShim(OpenTelemetry.Trace.Tracer tracer, OpenTelemetry.Context.Propagation.TextMapPropagator textFormat) -> void
OpenTelemetry.Shims.OpenTracing.TracerShim.TracerShim(OpenTelemetry.Trace.TracerProvider tracerProvider) -> void
OpenTelemetry.Shims.OpenTracing.TracerShim.TracerShim(OpenTelemetry.Trace.TracerProvider tracerProvider, OpenTelemetry.Context.Propagation.TextMapPropagator textFormat) -> void
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ OpenTelemetry.Shims.OpenTracing.TracerShim.BuildSpan(string operationName) -> Op
OpenTelemetry.Shims.OpenTracing.TracerShim.Extract<TCarrier>(OpenTracing.Propagation.IFormat<TCarrier> format, TCarrier carrier) -> OpenTracing.ISpanContext
OpenTelemetry.Shims.OpenTracing.TracerShim.Inject<TCarrier>(OpenTracing.ISpanContext spanContext, OpenTracing.Propagation.IFormat<TCarrier> format, TCarrier carrier) -> void
OpenTelemetry.Shims.OpenTracing.TracerShim.ScopeManager.get -> OpenTracing.IScopeManager
OpenTelemetry.Shims.OpenTracing.TracerShim.TracerShim(OpenTelemetry.Trace.Tracer tracer, OpenTelemetry.Context.Propagation.TextMapPropagator textFormat) -> void
OpenTelemetry.Shims.OpenTracing.TracerShim.TracerShim(OpenTelemetry.Trace.TracerProvider tracerProvider) -> void
OpenTelemetry.Shims.OpenTracing.TracerShim.TracerShim(OpenTelemetry.Trace.TracerProvider tracerProvider, OpenTelemetry.Context.Propagation.TextMapPropagator textFormat) -> void
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ OpenTelemetry.Shims.OpenTracing.TracerShim.BuildSpan(string operationName) -> Op
OpenTelemetry.Shims.OpenTracing.TracerShim.Extract<TCarrier>(OpenTracing.Propagation.IFormat<TCarrier> format, TCarrier carrier) -> OpenTracing.ISpanContext
OpenTelemetry.Shims.OpenTracing.TracerShim.Inject<TCarrier>(OpenTracing.ISpanContext spanContext, OpenTracing.Propagation.IFormat<TCarrier> format, TCarrier carrier) -> void
OpenTelemetry.Shims.OpenTracing.TracerShim.ScopeManager.get -> OpenTracing.IScopeManager
OpenTelemetry.Shims.OpenTracing.TracerShim.TracerShim(OpenTelemetry.Trace.Tracer tracer, OpenTelemetry.Context.Propagation.TextMapPropagator textFormat) -> void
OpenTelemetry.Shims.OpenTracing.TracerShim.TracerShim(OpenTelemetry.Trace.TracerProvider tracerProvider) -> void
OpenTelemetry.Shims.OpenTracing.TracerShim.TracerShim(OpenTelemetry.Trace.TracerProvider tracerProvider, OpenTelemetry.Context.Propagation.TextMapPropagator textFormat) -> void
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Shims.OpenTracing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

* Remove obsolete `TracerShim(Tracer, TextMapPropagator)` constructor.
Use `TracerShim(TracerProvider)`
or `TracerShim(TracerProvider, TextMapPropagator)` constructors.
([#4862](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4862))

## 1.6.0-beta.1

Released 2023-Sep-05
Expand Down
12 changes: 0 additions & 12 deletions src/OpenTelemetry.Shims.OpenTracing/TracerShim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ public TracerShim(Trace.TracerProvider tracerProvider, TextMapPropagator textFor
this.ScopeManager = new ScopeManagerShim();
}

[Obsolete("Use TracerShim(TracerProvider, TextMapPropagator) or TracerShim(TracerProvider) constructor.")]

public TracerShim(Trace.Tracer tracer, TextMapPropagator textFormat)
{
Guard.ThrowIfNull(tracer);
Guard.ThrowIfNull(textFormat);

this.tracer = tracer;
this.definedPropagator = textFormat;
this.ScopeManager = new ScopeManagerShim();
}

/// <inheritdoc/>
public global::OpenTracing.IScopeManager ScopeManager { get; }

Expand Down

0 comments on commit cafcb0c

Please sign in to comment.