From d04528d5d9667c47e44681ad5328be609a276627 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Tue, 25 Jul 2023 22:31:30 -0400 Subject: [PATCH] feat: Initial commit for Logs API --- .github/actions/test_gem/action.yml | 59 +++-- .gitignore | 5 +- api/CHANGELOG.md | 4 + api/lib/opentelemetry/version.rb | 2 +- exporter/otlp/Appraisals | 12 ++ exporter/otlp/CHANGELOG.md | 5 + exporter/otlp/README.md | 53 ++++- exporter/otlp/Rakefile | 32 ++- .../opentelemetry/exporter/otlp/version.rb | 2 +- .../logs/v1/logs_service_services_pb.rb | 50 ----- .../metrics/v1/metrics_service_services_pb.rb | 50 ----- .../trace/v1/trace_service_services_pb.rb | 50 ----- .../proto/trace/v1/trace_config_pb.rb | 49 ----- .../otlp/opentelemetry-exporter-otlp.gemspec | 3 +- logs_api/.rubocop.yml | 24 +++ logs_api/.yardopts | 9 + logs_api/CHANGELOG.md | 1 + logs_api/Gemfile | 9 + logs_api/LICENSE | 201 ++++++++++++++++++ logs_api/Rakefile | 28 +++ logs_api/lib/opentelemetry-logs-api.rb | 8 + logs_api/lib/opentelemetry/logs.rb | 13 ++ logs_api/lib/opentelemetry/logs/version.rb | 12 ++ logs_api/opentelemetry-logs-api.gemspec | 43 ++++ logs_api/test/test_helper.rb | 16 ++ 25 files changed, 482 insertions(+), 258 deletions(-) create mode 100644 exporter/otlp/Appraisals delete mode 100644 exporter/otlp/lib/opentelemetry/proto/collector/logs/v1/logs_service_services_pb.rb delete mode 100644 exporter/otlp/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_services_pb.rb delete mode 100644 exporter/otlp/lib/opentelemetry/proto/collector/trace/v1/trace_service_services_pb.rb delete mode 100644 exporter/otlp/lib/opentelemetry/proto/trace/v1/trace_config_pb.rb create mode 100644 logs_api/.rubocop.yml create mode 100644 logs_api/.yardopts create mode 100644 logs_api/CHANGELOG.md create mode 100644 logs_api/Gemfile create mode 100644 logs_api/LICENSE create mode 100644 logs_api/Rakefile create mode 100644 logs_api/lib/opentelemetry-logs-api.rb create mode 100644 logs_api/lib/opentelemetry/logs.rb create mode 100644 logs_api/lib/opentelemetry/logs/version.rb create mode 100644 logs_api/opentelemetry-logs-api.gemspec create mode 100644 logs_api/test/test_helper.rb diff --git a/.github/actions/test_gem/action.yml b/.github/actions/test_gem/action.yml index ed89114bf5..bbc484bc85 100644 --- a/.github/actions/test_gem/action.yml +++ b/.github/actions/test_gem/action.yml @@ -32,6 +32,7 @@ runs: id: setup shell: bash run: | + # 🛠️ Setup 🛠️ dir=$(find . -iname '${{ inputs.gem }}.gemspec' -exec dirname {} \;) echo "gem_dir=${dir}" >> $GITHUB_OUTPUT @@ -57,76 +58,68 @@ runs: # ...but not for appraisals, sadly. - name: Install Ruby ${{ inputs.ruby }} with dependencies if: "${{ steps.setup.outputs.appraisals == 'false' }}" - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@v1.144.1 with: ruby-version: "${{ inputs.ruby }}" working-directory: "${{ steps.setup.outputs.gem_dir }}" + bundler: "latest" bundler-cache: true cache-version: "v1-${{ steps.setup.outputs.cache_key }}" # If we're using appraisals, do it all manually. - name: Install Ruby ${{ inputs.ruby }} without dependencies if: "${{ steps.setup.outputs.appraisals == 'true' }}" - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@v1.144.1 with: ruby-version: "${{ inputs.ruby }}" - - name: Install dependencies and appraisals + bundler: "latest" + working-directory: "${{ steps.setup.outputs.gem_dir }}" + - name: Install dependencies and generate appraisals if: "${{ steps.setup.outputs.appraisals == 'true' }}" shell: bash run: | - cd "${{ steps.setup.outputs.gem_dir }}" - bundle install - bundle exec appraisal install + # 💎 Install dependencies and generate appraisals 💎 + bundle install --quiet --jobs=3 --retry=4 + bundle exec appraisal generate + working-directory: "${{ steps.setup.outputs.gem_dir }}" - name: Test Gem shell: bash run: | - cd "${{ steps.setup.outputs.gem_dir }}" - + # 🍿 Test Gem 🍿 if [[ -f "Appraisals" ]]; then - bundle exec appraisal rake test + for i in `bundle exec appraisal list | sed 's/-/_/g' `; do + echo "::group::🔎 Appraising ${i}" + BUNDLE_GEMFILE=gemfiles/${i}.gemfile bundle install --quiet --jobs=3 --retry=4 && \ + BUNDLE_GEMFILE=gemfiles/${i}.gemfile bundle show && \ + BUNDLE_GEMFILE=gemfiles/${i}.gemfile bundle exec rake test + echo "::endgroup::" + done else bundle exec rake test fi - env: - TEST_KAFKA_HOST: "127.0.0.1" - TEST_KAFKA_PORT: 29092 - TEST_MYSQL_HOST: "127.0.0.1" - TEST_MYSQL_PORT: 3306 - TEST_MYSQL_USER: mysql - TEST_MYSQL_PASSWORD: mysql - TEST_POSTGRES_PASSWORD: postgres - TEST_POSTGRES_USER: postgres - TEST_POSTGRES_HOST: localhost - TEST_POSTGRES_PORT: 5432 - TEST_POSTGRES_DB: postgres - TEST_MEMCACHED_HOST: localhost - TEST_MEMCACHED_PORT: 11211 - TEST_MONGODB_HOST: localhost - TEST_MONGODB_PORT: 27017 - TEST_RABBITMQ_HOST: localhost - TEST_RABBITMQ_PORT: 5672 - TEST_RABBITMQ_URL: amqp://guest:guest@localhost:5672 - TEST_REDIS_HOST: localhost - TEST_REDIS_PORT: 6379 + working-directory: "${{ steps.setup.outputs.gem_dir }}" - name: YARD shell: bash if: "${{ inputs.yard == 'true' }}" run: | - cd "${{ steps.setup.outputs.gem_dir }}" + # 📄 Yard Docs 📄 bundle exec rake yard + working-directory: "${{ steps.setup.outputs.gem_dir }}" - name: Rubocop shell: bash if: "${{ inputs.rubocop == 'true' }}" run: | - cd "${{ steps.setup.outputs.gem_dir }}" + # 🤖 Rubocop 🤖 bundle exec rake rubocop + working-directory: "${{ steps.setup.outputs.gem_dir }}" - name: Build Gem shell: bash if: "${{ inputs.build == 'true' }}" run: | - cd "${{ steps.setup.outputs.gem_dir }}" + # 📦 Build Gem 📦 gem build ${{ inputs.gem }}.gemspec + working-directory: "${{ steps.setup.outputs.gem_dir }}" diff --git a/.gitignore b/.gitignore index ebf9e801f3..c8016688c9 100644 --- a/.gitignore +++ b/.gitignore @@ -11,10 +11,7 @@ # Appraisals -instrumentation/**/gemfiles - -# Sqlite file for tests -instrumentation/active_record/db +**/*/gemfiles # Vendored gems **/vendor/**/* diff --git a/api/CHANGELOG.md b/api/CHANGELOG.md index efbc0cdc2f..3fca19e874 100644 --- a/api/CHANGELOG.md +++ b/api/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-api +### v1.2.1 / 2023-07-29 + +* DOCS: Describe Tracer#in_span arguments + ### v1.2.0 / 2023-06-08 * BREAKING CHANGE: Remove support for EoL Ruby 2.7 diff --git a/api/lib/opentelemetry/version.rb b/api/lib/opentelemetry/version.rb index 5484efe908..cb629c1dc5 100644 --- a/api/lib/opentelemetry/version.rb +++ b/api/lib/opentelemetry/version.rb @@ -6,5 +6,5 @@ module OpenTelemetry ## Current OpenTelemetry version - VERSION = '1.2.0' + VERSION = '1.2.1' end diff --git a/exporter/otlp/Appraisals b/exporter/otlp/Appraisals new file mode 100644 index 0000000000..362c129911 --- /dev/null +++ b/exporter/otlp/Appraisals @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +(14..23).each do |i| + version = "3.#{i}" + appraise "google-protobuf-#{version}" do + gem 'google-protobuf', "~> #{version}" + end +end diff --git a/exporter/otlp/CHANGELOG.md b/exporter/otlp/CHANGELOG.md index 2288d5f024..8b2d7c12e9 100644 --- a/exporter/otlp/CHANGELOG.md +++ b/exporter/otlp/CHANGELOG.md @@ -1,5 +1,10 @@ # Release History: opentelemetry-exporter-otlp +### v0.26.1 / 2023-07-29 + +* FIXED: Regenerate v0.20.0 protos +* ADDED: Allow google-protobuf ~> 3.14 + ### v0.26.0 / 2023-06-13 * ADDED: Use OTLP 0.20.0 protos diff --git a/exporter/otlp/README.md b/exporter/otlp/README.md index 8d5b70e618..55d09b8470 100644 --- a/exporter/otlp/README.md +++ b/exporter/otlp/README.md @@ -16,15 +16,17 @@ Generally, *libraries* that produce telemetry data should avoid depending direct ### Supported protocol version -This gem supports the [v0.4.0 release](https://github.com/open-telemetry/opentelemetry-proto/releases/tag/v0.4.0) of OTLP. +This gem supports the [v0.20.0 release][otel-proto-release] of OTLP. ## How do I get started? Install the gem using: -``` +```console + gem install opentelemetry-sdk gem install opentelemetry-exporter-otlp + ``` Or, if you use [bundler][bundler-home], include `opentelemetry-sdk` in your `Gemfile`. @@ -93,6 +95,48 @@ The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special int The `opentelemetry-exporter-otlp` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. +## Working with Proto Definitions + +The OTel community maintains a [repository with protobuf definitions][otel-proto-github] that language and collector implementors use to generate code. + +Maintainers are expected to keep up to date with the latest version of protos. This guide will provide you with step-by-step instructions on updating the OTLP Exporter gem with the latest definitions. + +### System Requirements + +- [`git` 2.41+][git-install] +- [`protoc` 22.5][protoc-install] +- [Ruby 3+][ruby-downloads] + +> :warning: `protoc 23.x` *changes the Ruby code generator to emit a serialized proto instead of a DSL.* . Please ensure you use `protoc` version `22.x` in order to ensure we remain compatible with versions of protobuf prior to `google-protobuf` gem `3.18`. + +### Upgrade Proto Definitions + +**Update the target otel-proto version in the `Rakefile` that matches a release `tag` in the proto repo, e.g.** + +```ruby + # Rakefile + + # https://github.com/open-telemetry/opentelemetry-proto/tree/v0.20.0 + PROTO_VERSION = `v0.20.0` +``` + +**Generate the Ruby source files using `rake`:** + +```console + +$> bundle exec rake protobuf:generate + +``` + +**Run tests and fix any errors:** + +```console + +$> bundle exec rake test + +``` + +**Commit the chnages and open a PR!** [opentelemetry-collector-home]: https://opentelemetry.io/docs/collector/about/ [opentelemetry-home]: https://opentelemetry.io @@ -103,3 +147,8 @@ The `opentelemetry-exporter-otlp` gem is distributed under the Apache 2.0 licens [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig [community-meetings]: https://github.com/open-telemetry/community#community-meetings [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions +[git-install]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git +[protoc-install]: https://github.com/protocolbuffers/protobuf/releases/tag/v22.5 +[ruby-downloads]: https://www.ruby-lang.org/en/downloads/ +[otel-proto-github]: https://github.com/open-telemetry/opentelemetry-proto +[otel-proto-release]: https://github.com/open-telemetry/opentelemetry-proto/releases/tag/v0.20.0 diff --git a/exporter/otlp/Rakefile b/exporter/otlp/Rakefile index 5aaabc603d..ce1edbd6e9 100644 --- a/exporter/otlp/Rakefile +++ b/exporter/otlp/Rakefile @@ -29,23 +29,21 @@ else task default: %i[test rubocop yard] end +# https://github.com/open-telemetry/opentelemetry-proto/tree/v0.20.0 PROTO_VERSION = 'v0.20.0' -PROTOBUF_FILES = [ - 'collector/logs/v1/logs_service.proto', - 'collector/metrics/v1/metrics_service.proto', - 'collector/trace/v1/trace_service.proto', - 'common/v1/common.proto', - 'logs/v1/logs.proto', - 'metrics/v1/metrics.proto', - 'resource/v1/resource.proto', - 'trace/v1/trace.proto', - 'trace/v1/trace_config.proto' -].freeze - -task :update_protobuf do - system("git clone -b #{PROTO_VERSION} https://github.com/open-telemetry/opentelemetry-proto") - PROTOBUF_FILES.each do |file| - system("protoc --ruby_out=lib/ --proto_path=opentelemetry-proto opentelemetry/proto/#{file}") + +namespace :protobuf do + task :clean do + FileUtils.rm_rf('lib/opentelemetry/proto') + FileUtils.rm_rf('opentelemetry-proto') + end + + desc "Generate Ruby Source files from OTel Proto Version #{PROTO_VERSION}" + task generate: [:clean] do + system("git clone -b #{PROTO_VERSION} https://github.com/open-telemetry/opentelemetry-proto", exception: true) + Dir['opentelemetry-proto/opentelemetry/proto/**/*.proto'].each do |file| + system("protoc --ruby_out=lib/ --proto_path=opentelemetry-proto #{file.gsub('opentelemetry-proto/', '')}", exception: true) + end + FileUtils.rm_rf('opentelemetry-proto') end - system('rm -rf opentelemetry-proto') end diff --git a/exporter/otlp/lib/opentelemetry/exporter/otlp/version.rb b/exporter/otlp/lib/opentelemetry/exporter/otlp/version.rb index 56359d9c1b..de097997a8 100644 --- a/exporter/otlp/lib/opentelemetry/exporter/otlp/version.rb +++ b/exporter/otlp/lib/opentelemetry/exporter/otlp/version.rb @@ -8,7 +8,7 @@ module OpenTelemetry module Exporter module OTLP ## Current OpenTelemetry OTLP exporter version - VERSION = '0.26.0' + VERSION = '0.26.1' end end end diff --git a/exporter/otlp/lib/opentelemetry/proto/collector/logs/v1/logs_service_services_pb.rb b/exporter/otlp/lib/opentelemetry/proto/collector/logs/v1/logs_service_services_pb.rb deleted file mode 100644 index 98712758d0..0000000000 --- a/exporter/otlp/lib/opentelemetry/proto/collector/logs/v1/logs_service_services_pb.rb +++ /dev/null @@ -1,50 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# Source: opentelemetry/proto/collector/logs/v1/logs_service.proto for package 'opentelemetry.proto.collector.logs.v1' -# Original file comments: -# Copyright 2020, 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. -# - -require 'grpc' -require 'opentelemetry/proto/collector/logs/v1/logs_service_pb' - -module Opentelemetry - module Proto - module Collector - module Logs - module V1 - module LogsService - # Service that can be used to push logs between one Application instrumented with - # OpenTelemetry and an collector, or between an collector and a central collector (in this - # case logs are sent/received to/from multiple Applications). - class Service - - include ::GRPC::GenericService - - self.marshal_class_method = :encode - self.unmarshal_class_method = :decode - self.service_name = 'opentelemetry.proto.collector.logs.v1.LogsService' - - # For performance reasons, it is recommended to keep this RPC - # alive for the entire life of the application. - rpc :Export, ::Opentelemetry::Proto::Collector::Logs::V1::ExportLogsServiceRequest, ::Opentelemetry::Proto::Collector::Logs::V1::ExportLogsServiceResponse - end - - Stub = Service.rpc_stub_class - end - end - end - end - end -end diff --git a/exporter/otlp/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_services_pb.rb b/exporter/otlp/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_services_pb.rb deleted file mode 100644 index 13be8cb414..0000000000 --- a/exporter/otlp/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_services_pb.rb +++ /dev/null @@ -1,50 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# Source: opentelemetry/proto/collector/metrics/v1/metrics_service.proto for package 'opentelemetry.proto.collector.metrics.v1' -# Original file comments: -# Copyright 2019, 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. -# - -require 'grpc' -require 'opentelemetry/proto/collector/metrics/v1/metrics_service_pb' - -module Opentelemetry - module Proto - module Collector - module Metrics - module V1 - module MetricsService - # Service that can be used to push metrics between one Application - # instrumented with OpenTelemetry and a collector, or between a collector and a - # central collector. - class Service - - include ::GRPC::GenericService - - self.marshal_class_method = :encode - self.unmarshal_class_method = :decode - self.service_name = 'opentelemetry.proto.collector.metrics.v1.MetricsService' - - # For performance reasons, it is recommended to keep this RPC - # alive for the entire life of the application. - rpc :Export, ::Opentelemetry::Proto::Collector::Metrics::V1::ExportMetricsServiceRequest, ::Opentelemetry::Proto::Collector::Metrics::V1::ExportMetricsServiceResponse - end - - Stub = Service.rpc_stub_class - end - end - end - end - end -end diff --git a/exporter/otlp/lib/opentelemetry/proto/collector/trace/v1/trace_service_services_pb.rb b/exporter/otlp/lib/opentelemetry/proto/collector/trace/v1/trace_service_services_pb.rb deleted file mode 100644 index aa9a167155..0000000000 --- a/exporter/otlp/lib/opentelemetry/proto/collector/trace/v1/trace_service_services_pb.rb +++ /dev/null @@ -1,50 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# Source: opentelemetry/proto/collector/trace/v1/trace_service.proto for package 'opentelemetry.proto.collector.trace.v1' -# Original file comments: -# Copyright 2019, 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. -# - -require 'grpc' -require 'opentelemetry/proto/collector/trace/v1/trace_service_pb' - -module Opentelemetry - module Proto - module Collector - module Trace - module V1 - module TraceService - # Service that can be used to push spans between one Application instrumented with - # OpenTelemetry and a collector, or between a collector and a central collector (in this - # case spans are sent/received to/from multiple Applications). - class Service - - include ::GRPC::GenericService - - self.marshal_class_method = :encode - self.unmarshal_class_method = :decode - self.service_name = 'opentelemetry.proto.collector.trace.v1.TraceService' - - # For performance reasons, it is recommended to keep this RPC - # alive for the entire life of the application. - rpc :Export, ::Opentelemetry::Proto::Collector::Trace::V1::ExportTraceServiceRequest, ::Opentelemetry::Proto::Collector::Trace::V1::ExportTraceServiceResponse - end - - Stub = Service.rpc_stub_class - end - end - end - end - end -end diff --git a/exporter/otlp/lib/opentelemetry/proto/trace/v1/trace_config_pb.rb b/exporter/otlp/lib/opentelemetry/proto/trace/v1/trace_config_pb.rb deleted file mode 100644 index 540dc2d65d..0000000000 --- a/exporter/otlp/lib/opentelemetry/proto/trace/v1/trace_config_pb.rb +++ /dev/null @@ -1,49 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: opentelemetry/proto/trace/v1/trace_config.proto - -require 'google/protobuf' - -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("opentelemetry/proto/trace/v1/trace_config.proto", :syntax => :proto3) do - add_message "opentelemetry.proto.trace.v1.TraceConfig" do - optional :max_number_of_attributes, :int64, 4 - optional :max_number_of_timed_events, :int64, 5 - optional :max_number_of_attributes_per_timed_event, :int64, 6 - optional :max_number_of_links, :int64, 7 - optional :max_number_of_attributes_per_link, :int64, 8 - oneof :sampler do - optional :constant_sampler, :message, 1, "opentelemetry.proto.trace.v1.ConstantSampler" - optional :trace_id_ratio_based, :message, 2, "opentelemetry.proto.trace.v1.TraceIdRatioBased" - optional :rate_limiting_sampler, :message, 3, "opentelemetry.proto.trace.v1.RateLimitingSampler" - end - end - add_message "opentelemetry.proto.trace.v1.ConstantSampler" do - optional :decision, :enum, 1, "opentelemetry.proto.trace.v1.ConstantSampler.ConstantDecision" - end - add_enum "opentelemetry.proto.trace.v1.ConstantSampler.ConstantDecision" do - value :ALWAYS_OFF, 0 - value :ALWAYS_ON, 1 - value :ALWAYS_PARENT, 2 - end - add_message "opentelemetry.proto.trace.v1.TraceIdRatioBased" do - optional :samplingRatio, :double, 1 - end - add_message "opentelemetry.proto.trace.v1.RateLimitingSampler" do - optional :qps, :int64, 1 - end - end -end - -module Opentelemetry - module Proto - module Trace - module V1 - TraceConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.TraceConfig").msgclass - ConstantSampler = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.ConstantSampler").msgclass - ConstantSampler::ConstantDecision = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.ConstantSampler.ConstantDecision").enummodule - TraceIdRatioBased = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.TraceIdRatioBased").msgclass - RateLimitingSampler = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.RateLimitingSampler").msgclass - end - end - end -end diff --git a/exporter/otlp/opentelemetry-exporter-otlp.gemspec b/exporter/otlp/opentelemetry-exporter-otlp.gemspec index a8bd0c13f0..0fb029cec0 100644 --- a/exporter/otlp/opentelemetry-exporter-otlp.gemspec +++ b/exporter/otlp/opentelemetry-exporter-otlp.gemspec @@ -26,12 +26,13 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 3.0' spec.add_dependency 'googleapis-common-protos-types', '~> 1.3' - spec.add_dependency 'google-protobuf', '~> 3.19' + spec.add_dependency 'google-protobuf', '~> 3.14' spec.add_dependency 'opentelemetry-api', '~> 1.1' spec.add_dependency 'opentelemetry-common', '~> 0.20' spec.add_dependency 'opentelemetry-sdk', '~> 1.2' spec.add_dependency 'opentelemetry-semantic_conventions' + spec.add_development_dependency 'appraisal', '~> 2.2.0' spec.add_development_dependency 'bundler', '>= 1.17' spec.add_development_dependency 'faraday', '~> 0.13' spec.add_development_dependency 'minitest', '~> 5.0' diff --git a/logs_api/.rubocop.yml b/logs_api/.rubocop.yml new file mode 100644 index 0000000000..9113b35375 --- /dev/null +++ b/logs_api/.rubocop.yml @@ -0,0 +1,24 @@ +# inherit_from: .rubocop_todo.yml + +AllCops: + TargetRubyVersion: '3.0' + +Lint/UnusedMethodArgument: + Enabled: false +Metrics/AbcSize: + Enabled: false +Metrics/LineLength: + Enabled: false +Metrics/MethodLength: + Max: 50 +Metrics/PerceivedComplexity: + Max: 30 +Metrics/CyclomaticComplexity: + Max: 20 +Metrics/ParameterLists: + Enabled: false +Naming/FileName: + Exclude: + - "lib/opentelemetry-logs-api.rb" +Style/ModuleFunction: + Enabled: false diff --git a/logs_api/.yardopts b/logs_api/.yardopts new file mode 100644 index 0000000000..0247c556cc --- /dev/null +++ b/logs_api/.yardopts @@ -0,0 +1,9 @@ +--no-private +--title=OpenTelemetry Logs API +--markup=markdown +--main=README.md +./lib/opentelemetry/**/*.rb +./lib/opentelemetry.rb +- +README.md +CHANGELOG.md diff --git a/logs_api/CHANGELOG.md b/logs_api/CHANGELOG.md new file mode 100644 index 0000000000..5a2fa37308 --- /dev/null +++ b/logs_api/CHANGELOG.md @@ -0,0 +1 @@ +# Release History: opentelemetry-logs-api diff --git a/logs_api/Gemfile b/logs_api/Gemfile new file mode 100644 index 0000000000..f649e2f64a --- /dev/null +++ b/logs_api/Gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +source 'https://rubygems.org' + +gemspec diff --git a/logs_api/LICENSE b/logs_api/LICENSE new file mode 100644 index 0000000000..1ef7dad2c5 --- /dev/null +++ b/logs_api/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + 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. diff --git a/logs_api/Rakefile b/logs_api/Rakefile new file mode 100644 index 0000000000..99808b5ac0 --- /dev/null +++ b/logs_api/Rakefile @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require 'bundler/gem_tasks' +require 'rake/testtask' +require 'yard' + +require 'rubocop/rake_task' +RuboCop::RakeTask.new + +Rake::TestTask.new :test do |t| + t.libs << 'test' + t.libs << 'lib' + t.test_files = FileList['test/**/*_test.rb'] +end + +YARD::Rake::YardocTask.new do |t| + t.stats_options = ['--list-undoc'] +end + +if RUBY_ENGINE == 'truffleruby' + task default: %i[test] +else + task default: %i[test rubocop yard] +end diff --git a/logs_api/lib/opentelemetry-logs-api.rb b/logs_api/lib/opentelemetry-logs-api.rb new file mode 100644 index 0000000000..2619ff26fd --- /dev/null +++ b/logs_api/lib/opentelemetry-logs-api.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require_relative 'opentelemetry/logs' +require_relative 'opentelemetry/logs/version' diff --git a/logs_api/lib/opentelemetry/logs.rb b/logs_api/lib/opentelemetry/logs.rb new file mode 100644 index 0000000000..212e0db3af --- /dev/null +++ b/logs_api/lib/opentelemetry/logs.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require 'opentelemetry' + +module OpenTelemetry + # OpenTelemetry Logs API + module Logs + end +end diff --git a/logs_api/lib/opentelemetry/logs/version.rb b/logs_api/lib/opentelemetry/logs/version.rb new file mode 100644 index 0000000000..e5b1a1495e --- /dev/null +++ b/logs_api/lib/opentelemetry/logs/version.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module Logs + ## Current OpenTelemetry logs version + VERSION = '0.1.0' + end +end diff --git a/logs_api/opentelemetry-logs-api.gemspec b/logs_api/opentelemetry-logs-api.gemspec new file mode 100644 index 0000000000..01411920b3 --- /dev/null +++ b/logs_api/opentelemetry-logs-api.gemspec @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +lib = File.expand_path('lib', __dir__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'opentelemetry/logs/version' + +Gem::Specification.new do |spec| + spec.name = 'opentelemetry-logs-api' + spec.version = OpenTelemetry::Logs::VERSION + spec.authors = ['OpenTelemetry Authors'] + spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] + + spec.summary = 'Logs API implementation for OpenTelemetry' + spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' + spec.license = 'Apache-2.0' + + spec.files = Dir.glob('lib/**/*.rb') + + Dir.glob('*.md') + + ['LICENSE', '.yardopts'] + spec.require_paths = ['lib'] + spec.required_ruby_version = '>= 3.0' + + spec.add_dependency 'opentelemetry-api', '~> 1.0' + + spec.add_development_dependency 'bundler', '>= 1.17' + spec.add_development_dependency 'minitest', '~> 5.0' + spec.add_development_dependency 'rake', '~> 12.0' + spec.add_development_dependency 'rubocop', '~> 1.3' + spec.add_development_dependency 'simplecov', '~> 0.17' + spec.add_development_dependency 'yard', '~> 0.9' + spec.add_development_dependency 'yard-doctest', '~> 0.1.6' + + if spec.respond_to?(:metadata) + spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-logs-api/v#{OpenTelemetry::Logs::VERSION}/file.CHANGELOG.html" + spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/logs_api' + spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' + spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-logs-api/v#{OpenTelemetry::Logs::VERSION}" + end +end diff --git a/logs_api/test/test_helper.rb b/logs_api/test/test_helper.rb new file mode 100644 index 0000000000..412d26ac78 --- /dev/null +++ b/logs_api/test/test_helper.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require 'simplecov' +SimpleCov.start +SimpleCov.minimum_coverage 85 + +require 'opentelemetry-test-helpers' +require 'opentelemetry-metrics-api' +require 'minitest/autorun' +require 'pry' + +OpenTelemetry.logger = Logger.new(File::NULL)