Skip to content

Commit f5c1160

Browse files
CodeBlanchutpilla
andauthored
[api-logs] Define OTEL1000 & OTEL1001 diagnostics and decorate APIs (#4963)
Co-authored-by: Utkarsh Umesan Pillai <[email protected]>
1 parent 93fd7d3 commit f5c1160

17 files changed

+248
-5
lines changed

OpenTelemetry.sln

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E
3232
build\docfx.cmd = build\docfx.cmd
3333
build\docker-compose.net6.0.yml = build\docker-compose.net6.0.yml
3434
build\docker-compose.net7.0.yml = build\docker-compose.net7.0.yml
35-
build\docker-compose.net8.0.yml = build\docker-compose.net8.0.yml
3635
build\finalize-publicapi.ps1 = build\finalize-publicapi.ps1
3736
build\GlobalAttrExclusions.txt = build\GlobalAttrExclusions.txt
3837
build\opentelemetry-icon-color.png = build\opentelemetry-icon-color.png
@@ -92,8 +91,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
9291
ProjectSection(SolutionItems) = preProject
9392
.github\workflows\ci-aot-md.yml = .github\workflows\ci-aot-md.yml
9493
.github\workflows\ci-aot.yml = .github\workflows\ci-aot.yml
95-
.github\workflows\ci-concurrency.yml = .github\workflows\ci-concurrency.yml
9694
.github\workflows\ci-concurrency-md.yml = .github\workflows\ci-concurrency-md.yml
95+
.github\workflows\ci-concurrency.yml = .github\workflows\ci-concurrency.yml
9796
.github\workflows\ci-instrumentation-libraries-md.yml = .github\workflows\ci-instrumentation-libraries-md.yml
9897
.github\workflows\ci-instrumentation-libraries.yml = .github\workflows\ci-instrumentation-libraries.yml
9998
.github\workflows\ci-md.yml = .github\workflows\ci-md.yml
@@ -266,6 +265,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{A49299
266265
ProjectSection(SolutionItems) = preProject
267266
src\Shared\ActivityHelperExtensions.cs = src\Shared\ActivityHelperExtensions.cs
268267
src\Shared\ActivityInstrumentationHelper.cs = src\Shared\ActivityInstrumentationHelper.cs
268+
src\Shared\DiagnosticDefinitions.cs = src\Shared\DiagnosticDefinitions.cs
269269
src\Shared\ExceptionExtensions.cs = src\Shared\ExceptionExtensions.cs
270270
src\Shared\Guard.cs = src\Shared\Guard.cs
271271
src\Shared\HttpSemanticConventionHelper.cs = src\Shared\HttpSemanticConventionHelper.cs
@@ -323,6 +323,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "getting-started-aspnetcore"
323323
EndProject
324324
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "links-creation", "docs\trace\links-creation-with-new-activities\links-creation.csproj", "{B4856711-6D4C-4246-A686-49458D4C1301}"
325325
EndProject
326+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "diagnostics", "diagnostics", "{52AF6D7D-9E66-4234-9A2C-5D16C6F22B40}"
327+
ProjectSection(SolutionItems) = preProject
328+
docs\diagnostics\README.md = docs\diagnostics\README.md
329+
EndProjectSection
330+
EndProject
331+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "experimental-apis", "experimental-apis", "{17A22B0E-6EC3-4A39-B955-0A486AD06699}"
332+
ProjectSection(SolutionItems) = preProject
333+
docs\diagnostics\experimental-apis\OTEL1000.md = docs\diagnostics\experimental-apis\OTEL1000.md
334+
docs\diagnostics\experimental-apis\OTEL1001.md = docs\diagnostics\experimental-apis\OTEL1001.md
335+
docs\diagnostics\experimental-apis\README.md = docs\diagnostics\experimental-apis\README.md
336+
EndProjectSection
337+
EndProject
326338
Global
327339
GlobalSection(SolutionConfigurationPlatforms) = preSolution
328340
Debug|Any CPU = Debug|Any CPU
@@ -650,6 +662,8 @@ Global
650662
{1C459B5B-C702-46FF-BF1A-EE795E420FFA} = {A49299FB-C5CD-4E0E-B7E1-B7867BBD67CC}
651663
{99B4D965-8782-4694-8DFA-B7A3630CEF60} = {3862190B-E2C5-418E-AFDC-DB281FB5C705}
652664
{B4856711-6D4C-4246-A686-49458D4C1301} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
665+
{52AF6D7D-9E66-4234-9A2C-5D16C6F22B40} = {7C87CAF9-79D7-4C26-9FFB-F3F1FB6911F1}
666+
{17A22B0E-6EC3-4A39-B955-0A486AD06699} = {52AF6D7D-9E66-4234-9A2C-5D16C6F22B40}
653667
EndGlobalSection
654668
GlobalSection(ExtensibilityGlobals) = postSolution
655669
SolutionGuid = {55639B5C-0770-4A22-AB56-859604650521}

build/Common.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1010
<Nullable>enable</Nullable>
1111
<ImplicitUsings>enable</ImplicitUsings>
12+
<!-- Suppress warnings for repo code using experimental features -->
13+
<NoWarn>$(NoWarn);OTEL1000;OTEL1001</NoWarn>
1214
<!--temporarily disable. See 3958-->
1315
<!--<AnalysisLevel>latest-All</AnalysisLevel>-->
1416
</PropertyGroup>

docs/diagnostics/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenTelemetry Diagnostics
2+
3+
This document describes the diagnostic categories used in OpenTelemetry .NET
4+
components. Diagnostics are used by the compiler to report information to users
5+
about experimental and/or obsolete code being invoked or to suggest improvements
6+
to specific code patterns identified through static analysis.
7+
8+
## Experimental APIs
9+
10+
Range: OTEL1XXX
11+
12+
Experimental APIs exposed in OpenTelemetry .NET pre-relase builds. APIs are
13+
exposed experimentally when either the OpenTelemetry Specification has
14+
explicitly marked some feature as
15+
[experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/document-status.md)
16+
or when the SIG members are still working through the design for a feature and
17+
want to solicit feedback from the community.
18+
19+
> **Note** Experimental APIs are exposed as `public` in pre-release builds and
20+
> `internal` in stable builds.
21+
22+
For defined diagnostics see: [OpenTelemetry .NET Experimental
23+
APIs](./experimental-apis/README.md)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# OpenTelemetry .NET Diagnostic: OTEL1000
2+
3+
## Overview
4+
5+
This is an Experimental API diagnostic covering the following APIs:
6+
7+
* `LoggerProviderBuilder`
8+
* `LoggerProvider`
9+
* `IDeferredLoggerProviderBuilder`
10+
11+
Experimental APIs may be changed or removed in the future.
12+
13+
## Details
14+
15+
The OpenTelemetry Specification defines a `LoggerProvider` as part of its
16+
[API](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/bridge-api.md)
17+
&
18+
[SDK](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md)
19+
components.
20+
21+
The SDK allows calling `Shutdown` and `ForceFlush` on the `LoggerProvider` and
22+
also allows processors to be added dynamically to a pipeline after its creation.
23+
24+
Today the OpenTelemetry .NET log pipeline is built on top of the
25+
Microsoft.Extensions.Logging `ILogger` \ `ILoggerProvider` \ `ILoggerFactory`
26+
APIs which do not expose such features.
27+
28+
We also have an issue with the `ILoggingBuilder.AddOpenTelemetry` API in that it
29+
interacts with the `OpenTelemetryLoggerOptions` class. Options classes are NOT
30+
available until the `IServiceProvider` is available and services can no longer
31+
be registered at that point. This prevents the current logging pipeline from
32+
exposing the same dependency injection surface we have for traces and metrics.
33+
34+
We are exposing these APIs to solve these issues and gather feedback about their
35+
usefulness.
36+
37+
## Log Bridge API
38+
39+
The OpenTelemetry Specification defines a Log Bridge API which is rooted off of
40+
the `LoggerProvider` (`GetLogger`) and exposes a `Logger` API to submit log
41+
records. See [OTEL1001](./OTEL1001.md) for details about the Log Bridge API
42+
implementation status.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# OpenTelemetry .NET Diagnostic: OTEL1001
2+
3+
## Overview
4+
5+
This is an Experimental API diagnostic covering the following APIs:
6+
7+
* `LoggerProvider.GetLogger`
8+
* `Logger`
9+
* `LogRecordAttributeList`
10+
* `LogRecordData`
11+
* `LogRecordSeverity`
12+
13+
Experimental APIs may be changed or removed in the future.
14+
15+
## Details
16+
17+
The OpenTelemetry Specification defines a [Logs Bridge
18+
API](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/bridge-api.md).
19+
20+
The log bridge API is used by library authors to build log appenders which route
21+
messages from different log frameworks into OpenTelemetry.
22+
23+
Today the OpenTelemetry .NET log pipeline is built on top of the
24+
Microsoft.Extensions.Logging `ILogger` \ `ILoggerProvider` \ `ILoggerFactory`
25+
APIs.
26+
27+
We are exposing these APIs gather feedback about their usefulness. An
28+
alternative approach may be taken which would be to append into `ILogger`
29+
instead of OpenTelemetry directly.
30+
31+
## LoggerProvider API
32+
33+
The OpenTelemetry Specification defines a `LoggerProvider` API. See
34+
[OTEL1000](./OTEL1000.md) for details about the `LoggerProvider` implementation
35+
status.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# OpenTelemetry .NET Experimental APIs
2+
3+
This document describes experimental APIs exposed in OpenTelemetry .NET
4+
pre-relase builds. APIs are exposed experimentally when either the OpenTelemetry
5+
Specification has explicitly marked some feature as
6+
[experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/document-status.md)
7+
or when the SIG members are still working through the design for a feature and
8+
want to solicit feedback from the community.
9+
10+
> **Note**
11+
> Experimental APIs are exposed as `public` in pre-release builds and `internal`
12+
> in stable builds.
13+
14+
## Active
15+
16+
Experimental APIs available in the pre-release builds:
17+
18+
### OTEL1000
19+
20+
Description: `LoggerProvider` and `LoggerProviderBuilder`
21+
22+
Details: [OTEL1000](./OTEL1000.md)
23+
24+
### OTEL1001
25+
26+
Description: Log Bridge API
27+
28+
Details: [OTEL1001](./OTEL1001.md)
29+
30+
## Inactive
31+
32+
Experimental APIs which have been released stable or removed:
33+
34+
<!-- When an experimental API is released or removed:
35+
1) Move the section from above down here.
36+
2) Delete the individual file from the repo and switch the link here to a
37+
permalink to the last version.
38+
3) Add the version info for when the API was released stable or removed. If
39+
removed add details for alternative solution or reasoning.
40+
-->
41+
42+
None

docs/metrics/exemplars/docker-compose.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,3 @@ services:
4848
- GF_FEATURE_TOGGLES_ENABLE=traceqlEditor
4949
ports:
5050
- "3000:3000"
51-

src/OpenTelemetry.Api/Logs/IDeferredLoggerProviderBuilder.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
#nullable enable
55

6+
#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES
7+
using System.Diagnostics.CodeAnalysis;
8+
using OpenTelemetry.Internal;
9+
#endif
10+
611
namespace OpenTelemetry.Logs;
712

813
#if EXPOSE_EXPERIMENTAL_FEATURES
@@ -12,6 +17,9 @@ namespace OpenTelemetry.Logs;
1217
/// dependency injection.
1318
/// </summary>
1419
/// <remarks><inheritdoc cref="Logger" path="/remarks"/></remarks>
20+
#if NET8_0_OR_GREATER
21+
[Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
22+
#endif
1523
public
1624
#else
1725
/// <summary>
@@ -21,7 +29,7 @@ namespace OpenTelemetry.Logs;
2129
/// </summary>
2230
internal
2331
#endif
24-
interface IDeferredLoggerProviderBuilder
32+
interface IDeferredLoggerProviderBuilder
2533
{
2634
/// <summary>
2735
/// Register a callback action to configure the <see

src/OpenTelemetry.Api/Logs/LogRecordAttributeList.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
using System.Collections;
77
using System.ComponentModel;
88
using System.Diagnostics;
9+
#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES
10+
using System.Diagnostics.CodeAnalysis;
11+
#endif
912
using OpenTelemetry.Internal;
1013
using OpenTelemetry.Trace;
1114

@@ -16,6 +19,9 @@ namespace OpenTelemetry.Logs;
1619
/// Stores attributes to be added to a log message.
1720
/// </summary>
1821
/// <remarks><inheritdoc cref="Logger" path="/remarks"/></remarks>
22+
#if NET8_0_OR_GREATER
23+
[Experimental(DiagnosticDefinitions.LogBridgeApiExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
24+
#endif
1925
public
2026
#else
2127
/// <summary>

src/OpenTelemetry.Api/Logs/LogRecordData.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#nullable enable
55

66
using System.Diagnostics;
7+
#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES
8+
using System.Diagnostics.CodeAnalysis;
9+
using OpenTelemetry.Internal;
10+
#endif
711

812
namespace OpenTelemetry.Logs;
913

@@ -12,6 +16,9 @@ namespace OpenTelemetry.Logs;
1216
/// Stores details about a log message.
1317
/// </summary>
1418
/// <remarks><inheritdoc cref="Logger" path="/remarks"/></remarks>
19+
#if NET8_0_OR_GREATER
20+
[Experimental(DiagnosticDefinitions.LogBridgeApiExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
21+
#endif
1522
public
1623
#else
1724
/// <summary>

0 commit comments

Comments
 (0)