Qyl.OpenTelemetry.SemanticConventions.SourceGeneration
3.0.1
dotnet add package Qyl.OpenTelemetry.SemanticConventions.SourceGeneration --version 3.0.1
NuGet\Install-Package Qyl.OpenTelemetry.SemanticConventions.SourceGeneration -Version 3.0.1
<PackageReference Include="Qyl.OpenTelemetry.SemanticConventions.SourceGeneration" Version="3.0.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Qyl.OpenTelemetry.SemanticConventions.SourceGeneration" Version="3.0.1" />
<PackageReference Include="Qyl.OpenTelemetry.SemanticConventions.SourceGeneration"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Qyl.OpenTelemetry.SemanticConventions.SourceGeneration --version 3.0.1
#r "nuget: Qyl.OpenTelemetry.SemanticConventions.SourceGeneration, 3.0.1"
#:package Qyl.OpenTelemetry.SemanticConventions.SourceGeneration@3.0.1
#addin nuget:?package=Qyl.OpenTelemetry.SemanticConventions.SourceGeneration&version=3.0.1
#tool nuget:?package=Qyl.OpenTelemetry.SemanticConventions.SourceGeneration&version=3.0.1
Qyl.OpenTelemetry.SemanticConventions.SourceGeneration
Roslyn source generator for OpenTelemetry semantic-convention constants,
descriptors, and thin helper APIs. It does not collect telemetry. Consumers own
their Meter, ActivitySource, Logger, instrumentation scope, versioning,
and enablement.
Use
using Qyl.OpenTelemetry.SemanticConventions.SourceGeneration;
[SemanticConventionAttributes("http")]
internal static partial class HttpAttributes;
[SemanticConventionIncubatingAttributes("http")]
internal static partial class HttpIncubatingAttributes;
[SemanticConventionMetrics("http.server")]
internal static partial class HttpServerMetrics;
[SemanticConventionIncubatingEvents("session")]
internal static partial class SessionEvents;
[SemanticConventionMeters("http.server")]
internal static partial class HttpServerMeters;
[SemanticConventionActivities("http")]
internal static partial class HttpActivityExtensions;
// Generated:
// public const string AttributeHttpRequestMethod = "http.request.method";
// public static partial class HttpServerRequestDurationDescriptor { ... }
// public readonly record struct SessionStartPayload { ... }
// public static Histogram<double> CreateHttpServerRequestDurationHistogram(this Meter meter)
// public static Activity SetHttpRoute(this Activity activity, string value)
Generator surfaces
All five source generators use the same Roslyn shape: publish stable and
incubating marker attributes during post-initialization, discover annotated
partial classes with ForAttributeWithMetadataName, extract the requested
semantic-convention prefix into a marker model, then emit source from the
matching registry projection.
| Surface | Marker attributes | Registry projection | Emitter | Generated shape |
|---|---|---|---|---|
| Attributes | SemanticConventionAttributes, SemanticConventionIncubatingAttributes |
RegistryLoader.Registry |
AttributesEmitter |
Attribute-key constants and typed enum-value helpers. |
| Activities | SemanticConventionActivities, SemanticConventionIncubatingActivities |
ActivityRegistryLoader.Registry |
ActivityExtensionsEmitter |
Activity extension methods that set typed semantic tags. |
| Metrics | SemanticConventionMetrics, SemanticConventionIncubatingMetrics |
RegistryLoader.Instruments |
MetricsEmitter |
Metric names, descriptors, units, instrument kinds, and attribute keys. |
| Meters | SemanticConventionMeters, SemanticConventionIncubatingMeters |
RegistryLoader.Instruments |
MetersEmitter |
Meter extension methods that create semantic instruments. |
| Events | SemanticConventionEvents, SemanticConventionIncubatingEvents |
RegistryLoader.Instruments |
EventsEmitter |
Event names, descriptors, and payload record structs. |
The marker attributes are themselves generated via
RegisterPostInitializationOutput; no runtime dependency is added by consuming
this package. The events generator also emits
SemanticConventionEvents.IsExternalInit.g.cs so generated record structs work
on older target frameworks.
Stable markers emit stable rows plus deprecated migration symbols. Incubating markers are supersets: stable + development/alpha/beta/release-candidate + deprecated. This mirrors Java/Python's incubating package behavior and avoids breaking consumers when conventions are promoted.
Choose one projection per prefix in normal consumer code. Incubating is a superset, so declaring both stable and incubating meter/activity helpers for the same prefix in the same namespace can make shared extension methods ambiguous. If a test fixture intentionally declares both, call the generated static helper class explicitly.
Event rows in semconv v1.41.0 do not carry an ActivityEvent-vs-Logger/Event discriminator. The generator emits event names and payload structs; the caller chooses the emission API at use-site. If upstream adds a discriminator later, the event emitter has a single routing point for that field.
Versioning
Tracks open-telemetry/semantic-conventions v1.41.0 (commit
e018fe6f91862f5ed63c082f87697cddac596784), embedded via Weaver v0.23.0.
The embedded registry is regenerated by scripts/generate.sh. The projection
preserves the resolved group surface across attribute groups, spans, entities,
metrics, and events, then exposes metric/event convenience arrays for the
signal-specific emitters.
The generated member shape is snapshot-tested per stability tier. Full-surface
consumer smoke builds cover net472, netstandard2.0, net6.0, net8.0,
net9.0, and net10.0.
Licensed under MIT (qyl); generated content is derived from OpenTelemetry semantic conventions, Apache-2.0.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.Analyzers (>= 5.3.0)
- Microsoft.CodeAnalysis.CSharp (>= 5.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.