Skip to content

Commit

Permalink
Merge pull request #2 from schanjr/merge_upstream
Browse files Browse the repository at this point in the history
Merge upstream
  • Loading branch information
__stan__ committed Nov 6, 2021
2 parents 49453be + ec5e556 commit eab3631
Show file tree
Hide file tree
Showing 593 changed files with 14,444 additions and 2,627 deletions.
77 changes: 77 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
name: Bug report
about: Notify us of an error or incorrect behaviour
title: ''
labels: 'bug'
assignees: ''

---

<!--
NOTE: Please use this form to submit bugs or demonstrations of non spec compliant behaviour
-->

**Description of the bug**

<!--
If this for behaviour that is not compliant with the OpenTelemetry Specification, please describe
what happened and what you expected with a link to the relevant portion of the spec.
-->

**Share details about your runtime**

Operating system details: Linux, Ubuntu 20.04 LTS
RUBY_ENGINE: "ruby"
RUBY_VERSION: "2.5.3"
RUBY_DESCRIPTION: "ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin19]"

**Share a simplified reproduction if possible**

```rb
require 'bundler/inline'

gemfile(true) do
source 'https://rubygems.org'

gem 'opentelemetry-api'
gem 'opentelemetry-sdk'
# gem 'opentelemetry-exporter-jaeger'
# gem 'opentelemetry-exporter-otlp'
# gem 'opentelemetry-exporter-zipkin'
end

require 'opentelemetry-api'
require 'opentelemetry-sdk'

span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(
OpenTelemetry::SDK::Trace::Export::ConsoleSpanExporter.new
)

# require 'opentelemetry/exporter/jaeger'
# exporter = OpenTelemetry::Exporter::Jaeger::AgentExporter.new(max_packet_size: 9 * 1024)
# span_processor = OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(exporter)

# require 'opentelemetry/shopify/exporters/otlp'
# exporter = OpenTelemetry::Exporter::OTLP::Exporter.new
# span_processor = OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(exporter)

# require 'opentelemetry/shopify/exporters/otlp'
# exporter = OpenTelemetry::Exporter::OTLP::Exporter.new
# span_processor = OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(exporter)

OpenTelemetry::SDK.configure do |c|
c.add_span_processor(span_processor)
end

SimpleTracer = OpenTelemetry.tracer_provider.tracer('Bug Report')

SimpleTracer.in_span('Parent span') do
1..10.times { SimpleTracer.in_span('child span') {} }
end

OpenTelemetry.tracer_provider.shutdown
```
68 changes: 68 additions & 0 deletions .github/workflows/ci-without-services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
if: ${{ github.repository == 'open-telemetry/opentelemetry-ruby' }}
strategy:
matrix:
include:
- name: Test MacOS / Ruby 3.0
os: macos-latest
ruby: "3.0"
# mysql2 omitted because it depends on the mysql C library which is not present
# redis omitted because it depends on redis-server which is not present
flags: >-
--include-simple --include-appraisal --omit-services
--exclude opentelemetry-instrumentation-mysql2
--exclude opentelemetry-instrumentation-redis
- name: Test Windows / Ruby 3.0
os: windows-latest
ruby: "3.0"
# active_record omitted because it depends on tzinfo which is not present
# action_pack omitted because it depends on tzinfo which is not present
# ethon omitted because it depends on libcurl which is not present
# mysql2 omitted because it depends on the mysql C library which is not present
# pg omitted because it depends on the postgres C library which is not present
# que omitted because it depends on the postgres C library which is not present
# rails omitted because it depends on tzinfo which is not present
# redis omitted because it depends on redis-server which is not present
# sidekiq omitted because it depends on redis-server which is not present
# resque omitted because it depends on redis-server which is not present
flags: >-
--include-simple --include-appraisal --omit-services
--exclude opentelemetry-instrumentation-active_record
--exclude opentelemetry-instrumentation-action_pack
--exclude opentelemetry-instrumentation-ethon
--exclude opentelemetry-instrumentation-mysql2
--exclude opentelemetry-instrumentation-pg
--exclude opentelemetry-instrumentation-que
--exclude opentelemetry-instrumentation-rails
--exclude opentelemetry-instrumentation-redis
--exclude opentelemetry-instrumentation-resque
--exclude opentelemetry-instrumentation-sidekiq
- name: Rubocop and build
os: ubuntu-latest
ruby: "2.7"
flags: --include-simple --include-appraisal --no-check-tests --check-rubocop --check-yard --check-build
fail-fast: false
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- name: Install Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: "${{ matrix.ruby }}"
- name: Checkout
uses: actions/checkout@v2
- name: Install tools
run: gem install --no-document bundler:2.1.4 toys:0.11.5
- name: Run tests
run: toys ci ${{ matrix.flags }}
75 changes: 42 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,30 @@ jobs:
strategy:
matrix:
include:
- name: Ruby 2.5
container: circleci/ruby:2.5-buster
- name: Test Linux / Ruby 2.5
os: ubuntu-latest
ruby: "2.5"
flags: --include-simple --include-appraisal
- name: Ruby 2.6
container: circleci/ruby:2.6-buster
- name: Test Linux / Ruby 2.6
os: ubuntu-latest
ruby: "2.6"
flags: --include-simple --include-appraisal
- name: Ruby 2.7
container: circleci/ruby:2.7-buster
flags: --include-simple --include-appraisal --check-rubocop --check-yard
- name: Ruby 3.0
container: circleci/ruby:3.0-buster
flags: --include-simple --include-appraisal --exclude opentelemetry-exporter-otlp
- name: JRuby
container: circleci/jruby:latest
flags: --include-simple --exclude opentelemetry-resource_detectors --exclude opentelemetry-exporter-otlp
- name: Test Linux / Ruby 2.7
os: ubuntu-latest
ruby: "2.7"
flags: --include-simple --include-appraisal
- name: Test Linux / Ruby 3.0
os: ubuntu-latest
ruby: "3.0"
flags: --include-simple --include-appraisal
- name: Test Linux / JRuby
os: ubuntu-latest
ruby: jruby
# otlp omitted because it depends on protobuf which does not work on JRuby
flags: --include-simple --exclude opentelemetry-exporter-otlp
fail-fast: false
name: Test ${{ matrix.name }} (${{ matrix.flags }})
runs-on: ubuntu-latest
container: ${{ matrix.container }}
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
env:
JRUBY_OPTS: --debug
services:
Expand All @@ -47,10 +52,11 @@ jobs:
image: confluentinc/cp-kafka:latest
ports:
- 9092:9092
- 29092:29092
env:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
Expand All @@ -76,9 +82,6 @@ jobs:
mysql:
image: mysql:5.6
env:
TEST_MYSQL_USER: root
TEST_MYSQL_ROOT_PASSWORD: root
TEST_MYSQ_DB: mysql
MYSQL_DATABASE: mysql
MYSQL_ROOT_PASSWORD: root
MYSQL_PASSWORD: mysql
Expand All @@ -98,28 +101,34 @@ jobs:
- 5432:5432
options: --health-cmd="pg_isready" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- name: Setup file system permissions
run: sudo chmod -R 777 $GITHUB_WORKSPACE /github /__w/_temp
- name: Install Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: "${{ matrix.ruby }}"
- name: Checkout
uses: actions/checkout@v2
- name: Install tools
run: gem install --no-document bundler:2.1.4 toys:0.11.4
run: gem install --no-document bundler:2.1.4 toys:0.11.5
- name: Run tests
env:
TEST_KAFKA_HOST: kafka
TEST_KAFKA_HOST: "127.0.0.1"
TEST_KAFKA_PORT: 29092
TEST_MYSQL_HOST: mysql
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: postgres
TEST_POSTGRES_HOST: localhost
TEST_POSTGRES_PORT: 5432
TEST_POSTGRES_DB: postgres
TEST_MEMCACHED_HOST: memcached
TEST_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
TEST_MONGODB_HOST: mongodb
TEST_MONGODB_PORT: ${{ job.services.mongodb.ports['27017'] }}
TEST_RABBITMQ_URL: amqp://guest:guest@rabbitmq:${{ job.services.rabbitmq.ports['5672'] }}
TEST_REDIS_HOST: redis
TEST_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
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
run: toys ci ${{ matrix.flags }}
37 changes: 37 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

env:
CODEQL_ENABLE_EXPERIMENTAL_FEATURES: true

strategy:
fail-fast: false
matrix:
language: [ 'ruby' ]

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
tools: latest

- name: Autobuild
uses: github/codeql-action/autobuild@v1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
# Appraisals
instrumentation/**/*.gemfile.lock

# Sqlite file for tests
instrumentation/active_record/db

# Vendored gems
**/vendor/**/*

# IDE Settings
/.idea/

# rbenv configuration
.ruby-version
9 changes: 7 additions & 2 deletions .instrumentation_generator/instrumentation_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# SPDX-License-Identifier: Apache-2.0

require_relative '../api/lib/opentelemetry/version'
require_relative '../instrumentation/base/lib/opentelemetry/instrumentation/version'
require 'thor'

class InstrumentationGenerator < Thor::Group
Expand Down Expand Up @@ -36,7 +37,7 @@ def lib_files
def test_files
template('templates/test/.rubocop.yml', "#{instrumentation_path}/test/.rubocop.yml")
template('templates/test/test_helper.rb', "#{instrumentation_path}/test/test_helper.rb")
template('templates/test/instrumentation.rb', "#{instrumentation_path}/test/#{instrumentation_path}/instrumentation_test.rb")
template('templates/test/instrumentation.rb', "#{instrumentation_path}/test/opentelemetry/#{instrumentation_path}/instrumentation_test.rb")
end

def add_to_releases
Expand All @@ -54,7 +55,7 @@ def add_to_instrumentation_all
gemfile_text = "\ngem '#{instrumentation_gem_name}', path: '../#{instrumentation_name}'"
insert_into_file("#{instrumentation_all_path}/Gemfile", gemfile_text, after: "gemspec\n")

gemspec_text = "\n spec.add_dependency '#{instrumentation_gem_name}', '~> #{opentelemetry_version}'"
gemspec_text = "\n spec.add_dependency '#{instrumentation_gem_name}', '~> 0.0.0'"
insert_into_file("#{instrumentation_all_path}/opentelemetry-instrumentation-all.gemspec", gemspec_text, after: "spec.required_ruby_version = '>= 2.5.0'\n")

all_rb_text = "\nrequire '#{instrumentation_gem_name}'"
Expand All @@ -67,6 +68,10 @@ def opentelemetry_version
OpenTelemetry::VERSION
end

def instrumentation_base_version
OpenTelemetry::Instrumentation::VERSION
end

def instrumentation_path
"instrumentation/#{instrumentation_name}"
end
Expand Down
1 change: 1 addition & 0 deletions .instrumentation_generator/templates/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ gem 'opentelemetry-api', path: '../../api'
group :test do
gem 'opentelemetry-common', path: '../../common'
gem 'opentelemetry-sdk', path: '../../sdk'
gem 'opentelemetry-semantic_conventions', path: '../../semantic_conventions'
end
3 changes: 2 additions & 1 deletion .instrumentation_generator/templates/gemspec.tt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.5.0'

spec.add_dependency 'opentelemetry-api', '~> <%= opentelemetry_version %>'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> <%= instrumentation_base_version %>'

spec.add_development_dependency 'appraisal', '~> 2.2.0'
spec.add_development_dependency 'bundler', '>= 1.17'
spec.add_development_dependency 'minitest', '~> 5.0'
spec.add_development_dependency 'opentelemetry-sdk', '~> 0.0'
spec.add_development_dependency 'opentelemetry-sdk', '~> 1.0'
spec.add_development_dependency 'rake', '~> 12.3.3'
spec.add_development_dependency 'rubocop', '~> 0.73.0'
spec.add_development_dependency 'simplecov', '~> 0.17.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# SPDX-License-Identifier: Apache-2.0

require 'opentelemetry'
require 'opentelemetry-instrumentation-base'

module OpenTelemetry
module Instrumentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'opentelemetry'

module OpenTelemetry
module Instrumentation
module <%= pascal_cased_instrumentation_name %>
Expand Down

0 comments on commit eab3631

Please sign in to comment.