Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semconv 1.25: update in a non-breaking way #1651

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 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
1 change: 1 addition & 0 deletions semantic_conventions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp/
2 changes: 2 additions & 0 deletions semantic_conventions/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Metrics/MethodLength:
Metrics/ModuleLength:
Enabled: false

Naming/ClassAndModuleCamelCase: # because the source for generating module names isn't Rubyish enough
Enabled: false
Naming/FileName:
Exclude:
- lib/opentelemetry-semantic_conventions.rb
Expand Down
4 changes: 2 additions & 2 deletions semantic_conventions/.yardopts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
--no-private
--title=OpenTelemetry Semantic Conventions
--markup=markdown
--markup-provider=kramdown
--main=README.md
./lib/opentelemetry/semantic_conventions/**/*.rb
./lib/opentelemetry/semantic_conventions.rb
./lib/opentelemetry/**/*.rb
-
README.md
CHANGELOG.md
91 changes: 62 additions & 29 deletions semantic_conventions/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ require 'rake/testtask'
require 'yard'
require 'rubocop/rake_task'
require 'tmpdir'

SPEC_VERSION = '1.10.0'
require 'pathname'

RuboCop::RakeTask.new

Expand All @@ -31,34 +30,68 @@ else
task default: %i[generate test rubocop yard]
end

task :generate do
cwd = Dir.pwd
SPEC_VERSION = '1.25.0'
GENERATOR_VERSION = '0.24.0'
semconv_source_dir = Pathname.new('./tmp/semconvrepo')
conventions_output_dir = Pathname.new('./lib/opentelemetry/semantic_conventions')
candidates_output_dir = Pathname.new('./lib/opentelemetry/semantic_candidates')

EXCLUDED_ATTRIBUTES = %w[].freeze

task generate: %i[update_gem_version generate_stable_attributes generate_candidate_attributes]

Dir.mktmpdir('opentelemetry-specification', Dir.pwd) do |tmpdir|
`git clone https://github.com/open-telemetry/opentelemetry-specification.git #{tmpdir}`
Dir.chdir(tmpdir) do
`git fetch`
`git checkout "v#{SPEC_VERSION}"`
end

%w[trace resource].each do |kind|
cmd = %W[
docker run --rm
-v "#{tmpdir}/semantic_conventions/#{kind}":/source
-v "#{cwd}/templates":/templates
-v "#{cwd}/lib":/output
otel/semconvgen:0.11.1
-f /source code
--template /templates/semantic_conventions.j2
--output /output/opentelemetry/semantic_conventions/#{kind}.rb
-Dmodule=#{kind[0].upcase}#{kind[1..]}
]

puts "Running: #{cmd.join(' ')}"
`#{cmd.join(' ')}`
end
directory semconv_source_dir do
sh "git clone --tags --depth=1 --branch v#{SPEC_VERSION} https://github.com/open-telemetry/semantic-conventions.git #{semconv_source_dir}"
end

task check_out_semconv_version: [semconv_source_dir] do
Dir.chdir(semconv_source_dir) do
sh "git fetch --depth 1 origin tag v#{SPEC_VERSION}"
sh "git checkout 'v#{SPEC_VERSION}'"
end
end

task generate_stable_attributes: [:check_out_semconv_version] do
conventions_output_dir
.join('attributes')
.glob('*.rb')
.then { |files| FileUtils.rm(files) }
semconvgen(semconv_source_dir, output_root: conventions_output_dir, kind: 'attributes', selector: 'is_stable')
end

task generate_candidate_attributes: [:check_out_semconv_version] do
candidates_output_dir
.join('attributes')
.glob('*.rb')
.then { |files| FileUtils.rm(files) }
semconvgen(semconv_source_dir, output_root: candidates_output_dir, kind: 'attributes', selector: 'any')
end

def semconvgen(semconv_source, output_root:, kind:, selector:)
mkdir_p output_root + kind
cwd = Dir.pwd
output_filenames_template = Pathname.new('/output').join(output_root, kind, '{{snake_prefix}}.rb')
cmd = %W[
docker run --rm
-v "#{semconv_source}/model":/source
-v "#{cwd}/templates":/templates
-v "#{cwd}":/output
otel/semconvgen:#{GENERATOR_VERSION}
--yaml-root /source
--continue-on-validation-errors
code
--file-per-group root_namespace
--template /templates/#{kind}.j2
--output "#{output_filenames_template}"
-Dselector=#{selector}
-Dexcluded_attributes="#{EXCLUDED_ATTRIBUTES.join(' ')}"
]

puts "Running: #{cmd.join(' ')}"
sh cmd.join(' ')
end

`sed -i.bak "s/VERSION = '.*'/VERSION = '#{SPEC_VERSION}'/g" lib/opentelemetry/semantic_conventions/version.rb`
`rm lib/opentelemetry/semantic_conventions/version.rb.bak`
task :update_gem_version do
sh %(sed -i.bak "s/VERSION = '.*'/VERSION = '#{SPEC_VERSION}'/g" lib/opentelemetry/semantic_conventions/version.rb)
sh 'rm lib/opentelemetry/semantic_conventions/version.rb.bak'
end
19 changes: 19 additions & 0 deletions semantic_conventions/lib/opentelemetry/semantic_candidates.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
# OpenTelemetry Semantic Conventions attribute names as constants.
# These are auto-generated from source YAML in {https://github.com/open-telemetry/semantic-conventions the semantic-conventions repository}.
#
# The constants in this namespace are all of the attribute names at all stability levels present in the OpenTelemetry semantic conventions as of {SemanticConventions::VERSION}.
#
# @note The constants here ought to remain within major versions of this library.
# However, there are risks with auto-generated code.
# The maintainers try to prevent constants disappearing, but we cannot guarantee this.
# We strongly recommend that any constants you use in your code are exercised in your test suite to catch missing constants before release or production runtime.
module SemanticCandidates
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
# This file was autogenerated. Do not edit it by hand.

module OpenTelemetry
module SemanticCandidates
module ANDROID
# @!group Attribute Names

# Uniquely identifies the framework API revision offered by a version (`os.version`) of the android operating system. More information can be found [here](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)
#
# @note StabilityLevel.EXPERIMENTAL
ANDROID_OS_API_LEVEL = 'android.os.api_level'

# This attribute represents the state the application has transitioned into at the occurrence of the event
#
# The Android lifecycle states are defined in [Activity lifecycle callbacks](https://developer.android.com/guide/components/activities/activity-lifecycle#lc), and from which the `OS identifiers` are derived
#
# @note StabilityLevel.EXPERIMENTAL
ANDROID_STATE = 'android.state'

# @!endgroup
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
# This file was autogenerated. Do not edit it by hand.

module OpenTelemetry
module SemanticCandidates
module ASPNETCORE
# @!group Attribute Names

# ASP.NET Core exception middleware handling result
#
# @note StabilityLevel.STABLE
#
# @deprecated Now available in the stable namespace at {OpenTelemetry::SemanticConventions::ASPNETCORE::ASPNETCORE_DIAGNOSTICS_EXCEPTION_RESULT}.
ASPNETCORE_DIAGNOSTICS_EXCEPTION_RESULT = 'aspnetcore.diagnostics.exception.result'

# Full type name of the [`IExceptionHandler`](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.diagnostics.iexceptionhandler) implementation that handled the exception
#
# @note StabilityLevel.STABLE
#
# @deprecated Now available in the stable namespace at {OpenTelemetry::SemanticConventions::ASPNETCORE::ASPNETCORE_DIAGNOSTICS_HANDLER_TYPE}.
ASPNETCORE_DIAGNOSTICS_HANDLER_TYPE = 'aspnetcore.diagnostics.handler.type'

# Rate limiting policy name
#
# @note StabilityLevel.STABLE
#
# @deprecated Now available in the stable namespace at {OpenTelemetry::SemanticConventions::ASPNETCORE::ASPNETCORE_RATE_LIMITING_POLICY}.
ASPNETCORE_RATE_LIMITING_POLICY = 'aspnetcore.rate_limiting.policy'

# Rate-limiting result, shows whether the lease was acquired or contains a rejection reason
#
# @note StabilityLevel.STABLE
#
# @deprecated Now available in the stable namespace at {OpenTelemetry::SemanticConventions::ASPNETCORE::ASPNETCORE_RATE_LIMITING_RESULT}.
ASPNETCORE_RATE_LIMITING_RESULT = 'aspnetcore.rate_limiting.result'

# Flag indicating if request was handled by the application pipeline
#
# @note StabilityLevel.STABLE
#
# @deprecated Now available in the stable namespace at {OpenTelemetry::SemanticConventions::ASPNETCORE::ASPNETCORE_REQUEST_IS_UNHANDLED}.
ASPNETCORE_REQUEST_IS_UNHANDLED = 'aspnetcore.request.is_unhandled'

# A value that indicates whether the matched route is a fallback route
#
# @note StabilityLevel.STABLE
#
# @deprecated Now available in the stable namespace at {OpenTelemetry::SemanticConventions::ASPNETCORE::ASPNETCORE_ROUTING_IS_FALLBACK}.
ASPNETCORE_ROUTING_IS_FALLBACK = 'aspnetcore.routing.is_fallback'

# Match result - success or failure
#
# @note StabilityLevel.STABLE
#
# @deprecated Now available in the stable namespace at {OpenTelemetry::SemanticConventions::ASPNETCORE::ASPNETCORE_ROUTING_MATCH_STATUS}.
ASPNETCORE_ROUTING_MATCH_STATUS = 'aspnetcore.routing.match_status'

# @!endgroup
end
end
end
Loading
Loading