Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct OTelAttributeRenderer: FileRenderer {

private func renderAttribute(_ attribute: Attribute, _ namespace: Namespace, indent: Int) throws -> String {
var result = renderDocs(attribute)
if let deprecatedMessage = attribute.deprecated {
if let deprecatedMessage = attribute.deprecated?.note?.trimmingCharacters(in: .whitespacesAndNewlines) {
result.append("\n@available(*, deprecated, message: \"\(deprecatedMessage)\")")
}
try result.append(
Expand Down
4 changes: 2 additions & 2 deletions Generator/Sources/FileRenderers/SpanAttributeRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct SpanAttributeRenderer: FileRenderer {
propertyName = nameGenerator.swiftMemberName(for: propertyName)

var result = renderDocs(attribute)
if let deprecatedMessage = attribute.deprecated {
if let deprecatedMessage = attribute.deprecated?.note?.trimmingCharacters(in: .whitespacesAndNewlines) {
result.append("\n@available(*, deprecated, message: \"\(deprecatedMessage)\")")
}

Expand Down Expand Up @@ -247,7 +247,7 @@ struct SpanAttributeRenderer: FileRenderer {
case .templateBoolean, .templateBooleanArray, .templateInt, .templateIntArray, .templateDouble,
.templateDoubleArray, .templateString, .templateStringArray:
return true
case .boolean, .booleanArray, .int, .intArray, .double, .doubleArray, .string, .stringArray:
case .boolean, .booleanArray, .int, .intArray, .double, .doubleArray, .string, .stringArray, .any:
return false
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions Generator/Sources/Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct Generator: AsyncParsableCommand {
@Option(
name: .shortAndLong,
help:
"A comma-separated list of top-level namespaces to use in the generation. If not included, all namespaces except `aspnetcore`, `jvm`, `nodejs`, `signalr`, and `v8js` will be generated."
"A comma-separated list of top-level namespaces to use in the generation. If not included, all namespaces except `aspnetcore`, `jvm`, `nodejs`, `signalr`, `dotnet`, and `v8js` will be generated."
)
var namespaces: String? = nil

Expand Down Expand Up @@ -78,7 +78,7 @@ struct Generator: AsyncParsableCommand {
topLevelNamespaces = topLevelNamespaces.filter { namespaceSet.contains($0.id) }
} else {
// Filter to exclude these namespaces by default
let excludedNamespaces: Set<String> = ["aspnetcore", "jvm", "nodejs", "signalr", "v8js"]
let excludedNamespaces: Set<String> = ["aspnetcore", "jvm", "nodejs", "signalr", "dotnet", "v8js"]
topLevelNamespaces = topLevelNamespaces.filter { !excludedNamespaces.contains($0.id) }
}

Expand Down
9 changes: 7 additions & 2 deletions Generator/Sources/RegistryFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct Attribute: Decodable {
let stability: Stability
let brief: String?
let note: String?
let deprecated: String?
let deprecated: Deprecated?
let examples: [String]?

enum RequirementLevel: String, Codable {
Expand All @@ -66,7 +66,7 @@ struct Attribute: Decodable {
stability = try container.decodeIfPresent(Stability.self, forKey: .stability) ?? .experimental
brief = try container.decodeIfPresent(String.self, forKey: .brief)
note = try container.decodeIfPresent(String.self, forKey: .note)
deprecated = try container.decodeIfPresent(String.self, forKey: .deprecated)
deprecated = try container.decodeIfPresent(Deprecated.self, forKey: .deprecated)
if !container.contains(.examples) {
examples = nil
} else if let example = try? container.decode(String.self, forKey: .examples) {
Expand Down Expand Up @@ -107,6 +107,7 @@ struct Attribute: Decodable {
case stringArray = "string[]"
case templateString = "template[string]"
case templateStringArray = "template[string[]]"
case any
}

struct EnumType: AttributeType {
Expand All @@ -130,6 +131,10 @@ extension Double: AttributeExample {}
extension Int: AttributeExample {}
extension String: AttributeExample {}

struct Deprecated: Codable {
let note: String?
}

enum Stability: String, Codable {
case development
case experimental
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ However, this package uses a Swift generator instead for the following reasons:
- To support the desired API where Swift usage nests namespaces with the `.` notation just like the attributes, a namespace tree must be constructed and traversed. Doing this in the Weaver Jinja templating language is difficult.
- Swift will be more familiar than Jinja templates to users of this package, leading to easier maintenance.

[semconv-badge]: https://img.shields.io/badge/semconv-1.29.0-blue.svg
[semconv-badge]: https://img.shields.io/badge/semconv-1.34.0-blue.svg
[semconv-url]: https://github.com/open-telemetry/semantic-conventions.git
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift OTel open source project
//
// Copyright (c) 2025 the Swift OTel project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// DO NOT EDIT. This file is generated automatically. See README for details.

extension OTelAttribute {
/// `code` namespace
public enum code {
/// `code.stacktrace`: A stacktrace as a string in the natural representation for the language runtime. The representation is identical to [`exception.stacktrace`](/docs/exceptions/exceptions-spans.md#stacktrace-representation). This attribute MUST NOT be used on the Profile signal since the data is already captured in 'message Location'. This constraint is imposed to prevent redundancy and maintain data integrity.
///
/// - Stability: stable
///
/// - Type: string
///
/// - Example: `at com.example.GenerateTrace.methodB(GenerateTrace.java:13)\n at com.example.GenerateTrace.methodA(GenerateTrace.java:9)\n at com.example.GenerateTrace.main(GenerateTrace.java:5)
/// `
public static let stacktrace = "code.stacktrace"

/// `code.column` namespace
public enum column {
/// `code.column.number`: The column number in `code.file.path` best representing the operation. It SHOULD point within the code unit named in `code.function.name`. This attribute MUST NOT be used on the Profile signal since the data is already captured in 'message Line'. This constraint is imposed to prevent redundancy and maintain data integrity.
///
/// - Stability: stable
///
/// - Type: int
///
/// - Example: `16`
public static let number = "code.column.number"
}

/// `code.file` namespace
public enum file {
/// `code.file.path`: The source code file name that identifies the code unit as uniquely as possible (preferably an absolute file path). This attribute MUST NOT be used on the Profile signal since the data is already captured in 'message Function'. This constraint is imposed to prevent redundancy and maintain data integrity.
///
/// - Stability: stable
///
/// - Type: string
///
/// - Example: `/usr/local/MyApplication/content_root/app/index.php`
public static let path = "code.file.path"
}

/// `code.function` namespace
public enum function {
/// `code.function.name`: The method or function fully-qualified name without arguments. The value should fit the natural representation of the language runtime, which is also likely the same used within `code.stacktrace` attribute value. This attribute MUST NOT be used on the Profile signal since the data is already captured in 'message Function'. This constraint is imposed to prevent redundancy and maintain data integrity.
///
/// - Stability: stable
///
/// - Type: string
///
/// Values and format depends on each language runtime, thus it is impossible to provide an exhaustive list of examples. The values are usually the same (or prefixes of) the ones found in native stack trace representation stored in `code.stacktrace` without information on arguments. Examples: * Java method: `com.example.MyHttpService.serveRequest` * Java anonymous class method: `com.mycompany.Main$1.myMethod` * Java lambda method: `com.mycompany.Main$$Lambda/0x0000748ae4149c00.myMethod` * PHP function: `GuzzleHttp\Client::transfer` * Go function: `github.com/my/repo/pkg.foo.func5` * Elixir: `OpenTelemetry.Ctx.new` * Erlang: `opentelemetry_ctx:new` * Rust: `playground::my_module::my_cool_func` * C function: `fopen`
///
/// - Examples:
/// - `com.example.MyHttpService.serveRequest`
/// - `GuzzleHttp\Client::transfer`
/// - `fopen`
public static let name = "code.function.name"
}

/// `code.line` namespace
public enum line {
/// `code.line.number`: The line number in `code.file.path` best representing the operation. It SHOULD point within the code unit named in `code.function.name`. This attribute MUST NOT be used on the Profile signal since the data is already captured in 'message Line'. This constraint is imposed to prevent redundancy and maintain data integrity.
///
/// - Stability: stable
///
/// - Type: int
///
/// - Example: `42`
public static let number = "code.line.number"
}
}
}
Loading