Skip to content

Commit 8a4baa3

Browse files
authored
fix(semconv): correct & simplify codegen templates (#2059)
* fix(semconv): template, treat deprecated as a dict (attribute|metric).deprecated is a dict, so dropping it into Yard doc content gets weird with Yard treating {} as a reference to other Yard content elsewhere. This change uses deprecated.note (if present) or deprecated.reason (always present, but less info) capitalized with a period. * fix(semconv): result of the template update for deprecated * fix(semconv): template, remove @examples attribute.examples come in too many shapes to include in generated code docs without a complicated template to interpret their shape. WWJD: What Would Java Do? Java doesn't include examples. Let's not, also. * fix(semconv): result of the template removal for examples * fix(semconv): correct typo carried over from semconv model data * fix(semconv): let toys manage the VERSION constant Record the current semconv version in a separate constant. * Maybe some comments about how these differ? * docs: update words about these version constants Better directions for how to hold this update process.
1 parent 86e979e commit 8a4baa3

108 files changed

Lines changed: 221 additions & 3387 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

semantic_conventions/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ upstream [OpenTelemetry Semantic Conventions version][semconv].
8787

8888
## How do I rebuild the conventions?
8989

90-
Bump the version number in the Rakefile, and then run `rake generate`.
90+
To build the library against a new version of the semantic conventions, update SPEC_VERSION in the Rakefile, and then run `rake generate`.
91+
92+
Do not update the library's VERSION in version.rb.
93+
That will be handled by the automation for releasing the gem.
9194

9295
## How can I get involved?
9396

semantic_conventions/Rakefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ default_tasks =
4848
task default: default_tasks
4949

5050
desc 'update semantic conventions'
51-
task generate: %i[update_gem_version generate_semconv generate_require_rollups rubocop_autocorrect]
51+
task generate: %i[update_spec_version_constant generate_semconv generate_require_rollups rubocop_autocorrect]
5252

5353
SPEC_VERSION = '1.37.0'
5454
OTEL_WEAVER_VERSION = 'v0.17.1'
@@ -125,8 +125,9 @@ task generate_require_rollups: %i[generate_semconv] do
125125
end
126126

127127
desc 'Bump the semantic_conventions gem version to match the spec'
128-
task :update_gem_version do
129-
puts "\n+++ Updating gem version to #{SPEC_VERSION}\n"
130-
sh %(sed -i.bak "s/VERSION = '.*'/VERSION = '#{SPEC_VERSION}'/g" lib/opentelemetry/semantic_conventions/version.rb)
128+
task :update_spec_version_constant do
129+
puts "\n+++ Updating library SPEC_VERSION constant to #{SPEC_VERSION}.\n"
130+
puts " ℹ️ VERSION is managed by release automation and left unchanged.\n"
131+
sh %(sed -i.bak "s/SPEC_VERSION = '.*'/SPEC_VERSION = '#{SPEC_VERSION}'/g" lib/opentelemetry/semantic_conventions/version.rb)
131132
sh 'rm lib/opentelemetry/semantic_conventions/version.rb.bak'
132133
end

semantic_conventions/lib/opentelemetry/semantic_conventions/version.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
module OpenTelemetry
88
module SemanticConventions
9-
VERSION = '1.37.0'
9+
# Version of the OpenTelemetry Semantic Conventions from which this library was generated.
10+
SPEC_VERSION = '1.37.0'
11+
# Release version of this gem. May not match SPEC_VERSION until gem is released after a spec update.
12+
VERSION = '1.36.0'
1013
end
1114
end

semantic_conventions/lib/opentelemetry/semconv/aspnetcore/attributes.rb

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,70 +26,41 @@ module ASPNETCORE
2626
# ASP.NET Core exception middleware handling result.
2727
#
2828
# @note Stability Level: stable
29-
#
30-
# @example Sample Values
31-
# handled
32-
# unhandled
3329
ASPNETCORE_DIAGNOSTICS_EXCEPTION_RESULT = 'aspnetcore.diagnostics.exception.result'
3430

3531
# Full type name of the [`IExceptionHandler`](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.diagnostics.iexceptionhandler) implementation that handled the exception.
3632
#
3733
# @note Stability Level: stable
38-
#
39-
# @example Sample Values
40-
# Contoso.MyHandler
4134
ASPNETCORE_DIAGNOSTICS_HANDLER_TYPE = 'aspnetcore.diagnostics.handler.type'
4235

4336
# Rate limiting policy name.
4437
#
4538
# @note Stability Level: stable
46-
#
47-
# @example Sample Values
48-
# fixed
49-
# sliding
50-
# token
5139
ASPNETCORE_RATE_LIMITING_POLICY = 'aspnetcore.rate_limiting.policy'
5240

5341
# Rate-limiting result, shows whether the lease was acquired or contains a rejection reason
5442
#
5543
# @note Stability Level: stable
56-
#
57-
# @example Sample Values
58-
# acquired
59-
# request_canceled
6044
ASPNETCORE_RATE_LIMITING_RESULT = 'aspnetcore.rate_limiting.result'
6145

6246
# Flag indicating if request was handled by the application pipeline.
6347
#
6448
# @note Stability Level: stable
65-
#
66-
# @example Sample Values
67-
# true
6849
ASPNETCORE_REQUEST_IS_UNHANDLED = 'aspnetcore.request.is_unhandled'
6950

7051
# A value that indicates whether the matched route is a fallback route.
7152
#
7253
# @note Stability Level: stable
73-
#
74-
# @example Sample Values
75-
# true
7654
ASPNETCORE_ROUTING_IS_FALLBACK = 'aspnetcore.routing.is_fallback'
7755

7856
# Match result - success or failure
7957
#
8058
# @note Stability Level: stable
81-
#
82-
# @example Sample Values
83-
# success
84-
# failure
8559
ASPNETCORE_ROUTING_MATCH_STATUS = 'aspnetcore.routing.match_status'
8660

8761
# A value that indicates whether the user is authenticated.
8862
#
8963
# @note Stability Level: stable
90-
#
91-
# @example Sample Values
92-
# true
9364
ASPNETCORE_USER_IS_AUTHENTICATED = 'aspnetcore.user.is_authenticated'
9465

9566
# @!endgroup

semantic_conventions/lib/opentelemetry/semconv/client/attributes.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,13 @@ module CLIENT
2828
# When observed from the server side, and when communicating through an intermediary, `client.address` SHOULD represent the client address behind any intermediaries, for example proxies, if it's available.
2929
#
3030
# @note Stability Level: stable
31-
#
32-
# @example Sample Values
33-
# client.example.com
34-
# 10.1.2.80
35-
# /tmp/my.sock
3631
CLIENT_ADDRESS = 'client.address'
3732

3833
# Client port number.
3934
#
4035
# When observed from the server side, and when communicating through an intermediary, `client.port` SHOULD represent the client port behind any intermediaries, for example proxies, if it's available.
4136
#
4237
# @note Stability Level: stable
43-
#
44-
# @example Sample Values
45-
# 65123
4638
CLIENT_PORT = 'client.port'
4739

4840
# @!endgroup

semantic_conventions/lib/opentelemetry/semconv/code/attributes.rb

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,11 @@ module CODE
2626
# 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.
2727
#
2828
# @note Stability Level: stable
29-
#
30-
# @example Sample Values
31-
# 16
32-
#
3329
CODE_COLUMN_NUMBER = 'code.column.number'
3430

3531
# 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.
3632
#
3733
# @note Stability Level: stable
38-
#
39-
# @example Sample Values
40-
# /usr/local/MyApplication/content_root/app/index.php
41-
#
4234
CODE_FILE_PATH = 'code.file.path'
4335

4436
# 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.
@@ -60,29 +52,16 @@ module CODE
6052
# - C function: `fopen`
6153
#
6254
# @note Stability Level: stable
63-
#
64-
# @example Sample Values
65-
# com.example.MyHttpService.serveRequest
66-
# GuzzleHttp\Client::transfer
67-
# fopen
6855
CODE_FUNCTION_NAME = 'code.function.name'
6956

7057
# 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.
7158
#
7259
# @note Stability Level: stable
73-
#
74-
# @example Sample Values
75-
# 42
76-
#
7760
CODE_LINE_NUMBER = 'code.line.number'
7861

7962
# 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.
8063
#
8164
# @note Stability Level: stable
82-
#
83-
# @example Sample Values
84-
# 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)
85-
8665
CODE_STACKTRACE = 'code.stacktrace'
8766

8867
# @!endgroup

semantic_conventions/lib/opentelemetry/semconv/db/attributes.rb

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ module DB
3636
# collection name then that collection name SHOULD be used.
3737
#
3838
# @note Stability Level: stable
39-
#
40-
# @example Sample Values
41-
# public.users
42-
# customers
4339
DB_COLLECTION_NAME = 'db.collection.name'
4440

4541
# The name of the database, fully qualified within the server address and port.
@@ -49,22 +45,13 @@ module DB
4945
# It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization.
5046
#
5147
# @note Stability Level: stable
52-
#
53-
# @example Sample Values
54-
# customers
55-
# test.users
5648
DB_NAMESPACE = 'db.namespace'
5749

5850
# The number of queries included in a batch operation.
5951
#
6052
# Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`.
6153
#
6254
# @note Stability Level: stable
63-
#
64-
# @example Sample Values
65-
# 2
66-
# 3
67-
# 4
6855
DB_OPERATION_BATCH_SIZE = 'db.operation.batch.size'
6956

7057
# The name of the operation or command being executed.
@@ -85,11 +72,6 @@ module DB
8572
# system specific term if more applicable.
8673
#
8774
# @note Stability Level: stable
88-
#
89-
# @example Sample Values
90-
# findAndModify
91-
# HMSET
92-
# SELECT
9375
DB_OPERATION_NAME = 'db.operation.name'
9476

9577
# Low cardinality summary of a database query.
@@ -105,11 +87,6 @@ module DB
10587
# section.
10688
#
10789
# @note Stability Level: stable
108-
#
109-
# @example Sample Values
110-
# SELECT wuser_table
111-
# INSERT shipping_details SELECT orders
112-
# get user by id
11390
DB_QUERY_SUMMARY = 'db.query.summary'
11491

11592
# The database query being executed.
@@ -119,10 +96,6 @@ module DB
11996
# Parameterized query text SHOULD NOT be sanitized. Even though parameterized query text can potentially have sensitive data, by using a parameterized query the user is giving a strong signal that any sensitive data will be passed as parameter values, and the benefit to observability of capturing the static part of the query text by default outweighs the risk.
12097
#
12198
# @note Stability Level: stable
122-
#
123-
# @example Sample Values
124-
# SELECT * FROM wuser_table where username = ?
125-
# SET mykey ?
12699
DB_QUERY_TEXT = 'db.query.text'
127100

128101
# Database response status code.
@@ -131,12 +104,6 @@ module DB
131104
# Semantic conventions for individual database systems SHOULD document what `db.response.status_code` means in the context of that system.
132105
#
133106
# @note Stability Level: stable
134-
#
135-
# @example Sample Values
136-
# 102
137-
# ORA-17002
138-
# 08P01
139-
# 404
140107
DB_RESPONSE_STATUS_CODE = 'db.response.status_code'
141108

142109
# The name of a stored procedure within the database.
@@ -148,9 +115,6 @@ module DB
148115
# stored procedure name then that stored procedure name SHOULD be used.
149116
#
150117
# @note Stability Level: stable
151-
#
152-
# @example Sample Values
153-
# GetCustomer
154118
DB_STORED_PROCEDURE_NAME = 'db.stored_procedure.name'
155119

156120
# The database management system (DBMS) product as identified by the client instrumentation.

semantic_conventions/lib/opentelemetry/semconv/dotnet/attributes.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ module DOTNET
2626
# Name of the garbage collector managed heap generation.
2727
#
2828
# @note Stability Level: stable
29-
#
30-
# @example Sample Values
31-
# gen0
32-
# gen1
33-
# gen2
3429
DOTNET_GC_HEAP_GENERATION = 'dotnet.gc.heap.generation'
3530

3631
# @!endgroup

semantic_conventions/lib/opentelemetry/semconv/error/attributes.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ module ERROR
4646
# - Set `error.type` to capture all errors, regardless of whether they are defined within the domain-specific set or not.
4747
#
4848
# @note Stability Level: stable
49-
#
50-
# @example Sample Values
51-
# timeout
52-
# java.net.UnknownHostException
53-
# server_certificate_invalid
54-
# 500
5549
ERROR_TYPE = 'error.type'
5650

5751
# @!endgroup

semantic_conventions/lib/opentelemetry/semconv/exception/attributes.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,22 @@ module EXCEPTION
2626
# Indicates that the exception is escaping the scope of the span.
2727
#
2828
# @note Stability Level: stable
29-
# @deprecated {"note": "It's no longer recommended to record exceptions that are handled and do not escape the scope of a span.\n", "reason": "obsoleted"}
29+
# @deprecated It's no longer recommended to record exceptions that are handled and do not escape the scope of a span.
3030
EXCEPTION_ESCAPED = 'exception.escaped'
3131

3232
# The exception message.
3333
#
3434
# @note Stability Level: stable
35-
#
36-
# @example Sample Values
37-
# Division by zero
38-
# Can't convert 'int' object to str implicitly
3935
EXCEPTION_MESSAGE = 'exception.message'
4036

4137
# A stacktrace as a string in the natural representation for the language runtime. The representation is to be determined and documented by each language SIG.
4238
#
4339
# @note Stability Level: stable
44-
#
45-
# @example Sample Values
46-
# Exception in thread "main" java.lang.RuntimeException: Test exception\n 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)
47-
4840
EXCEPTION_STACKTRACE = 'exception.stacktrace'
4941

5042
# The type of the exception (its fully-qualified class name, if applicable). The dynamic type of the exception should be preferred over the static type in languages that support it.
5143
#
5244
# @note Stability Level: stable
53-
#
54-
# @example Sample Values
55-
# java.net.ConnectException
56-
# OSError
5745
EXCEPTION_TYPE = 'exception.type'
5846

5947
# @!endgroup

0 commit comments

Comments
 (0)