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

feat: WIP: Ruby Logger instrumentation #1

Draft
wants to merge 79 commits into
base: main
Choose a base branch
from

Conversation

kaylareopelle
Copy link
Owner

@kaylareopelle kaylareopelle commented Oct 2, 2023

This PR leverages the Logs SDK implementation pending review in kaylareopelle/opentelemetry-ruby#6 to instrument Ruby's Logger class.

It also includes a workaround to prevent broadcasted logs in Rails < 7.1 from creating duplicate log records.

Co-Authored by: @khushijain21

@kaylareopelle kaylareopelle marked this pull request as draft October 16, 2023 22:22
@kaylareopelle kaylareopelle changed the title WIP Ruby Logger instrumentation WIP: Ruby Logger instrumentation Oct 16, 2023
Comment on lines 17 to 20
gem 'opentelemetry-api', path: '/Users/kreopelle/dev/opentelemetry-ruby/api'
gem 'opentelemetry-logs-api', path: '/Users/kreopelle/dev/opentelemetry-ruby/logs_api'
gem 'opentelemetry-logs-sdk', path: '/Users/kreopelle/dev/opentelemetry-ruby/logs_sdk'
gem 'opentelemetry-sdk', path: '/Users/kreopelle/dev/opentelemetry-ruby/sdk'
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, didn't mean to commit my local paths. This will install things with the latest SDK branch, but Appraisal is having trouble installing gems via git, so this might not be the best solution:

Suggested change
gem 'opentelemetry-api', path: '/Users/kreopelle/dev/opentelemetry-ruby/api'
gem 'opentelemetry-logs-api', path: '/Users/kreopelle/dev/opentelemetry-ruby/logs_api'
gem 'opentelemetry-logs-sdk', path: '/Users/kreopelle/dev/opentelemetry-ruby/logs_sdk'
gem 'opentelemetry-sdk', path: '/Users/kreopelle/dev/opentelemetry-ruby/sdk'
gem 'opentelemetry-api', git: 'https://github.com/kaylareopelle/opentelemetry-ruby', branch: 'log-record-processor3', glob: 'api/*.gemspec'
gem 'opentelemetry-logs-api', git: 'https://github.com/kaylareopelle/opentelemetry-ruby', branch: 'log-record-processor3', glob: 'logs_api/*.gemspec'
gem 'opentelemetry-logs-sdk', git: 'https://github.com/kaylareopelle/opentelemetry-ruby', branch: 'log-record-processor3', glob: 'logs_sdk/*.gemspec'
gem 'opentelemetry-sdk', git: 'https://github.com/kaylareopelle/opentelemetry-ruby', branch: 'log-record-processor3', glob: 'sdk/*.gemspec'

@kaylareopelle kaylareopelle changed the title WIP: Ruby Logger instrumentation feat: WIP: Ruby Logger instrumentation Mar 30, 2024
kaylareopelle and others added 30 commits September 17, 2024 12:07
…ntelemetry-ruby-contrib into logger-instrumentation
Rails 7.1+ uses ActiveSupport::BroadcastLogger. This needs to protect
against emitting duplicate logs in a different way than
ActiveSupport::Logger.broadcast.

Emits the log record for the first logger in the broadcast,
skip the others. Reset everything at the end of the method call.
)

* fix: get correct table name if table name is quoted

* Remove double test

* Add new line to sql_table_name.json

* Stop accepting table name in single quotes

---------

Co-authored-by: Kayla Reopelle <[email protected]>
Co-authored-by: Ariel Valentin <[email protected]>
…elemetry#1243)

Bumps [DavidAnson/markdownlint-cli2-action](https://github.com/davidanson/markdownlint-cli2-action) from 17 to 18.
- [Release notes](https://github.com/davidanson/markdownlint-cli2-action/releases)
- [Commits](DavidAnson/markdownlint-cli2-action@v17...v18)

---
updated-dependencies:
- dependency-name: DavidAnson/markdownlint-cli2-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ariel Valentin <[email protected]>
…ry#1222)

* Main
Created a readable constant in 8 files to freeze ranges 100..399 .

Relate to open-telemetry#1172

* refactor: Create a readable constant in 8 files to freeze ranges 100..399 .

Reviewed-by: kaylareopelle
Refs: open-telemetry#1172

* refactor: Fix rubocop ruby linter failures
Reviewed-by: kaylareopelle
Refs: open-telemetry#1172

* refactor: Fix rubocop ruby linter failures
Reviewed-by: kaylareopelle
Refs: open-telemetry#1172

---------

Co-authored-by: Kayla Reopelle <[email protected]>
Co-authored-by: Ariel Valentin <[email protected]>
* feat: add grpc instrumentation

See <https://github.com/hibachrach/opentelemetry-instrumentation-grpc/>
for previous git history

* Apply suggestions from code review

* chore: Markdown lint, class updates for CI

* Update instrumentation/grpc/README.md

---------

Co-authored-by: Kayla Reopelle <[email protected]>
Co-authored-by: Kayla Reopelle <[email protected]>
* release: Release 20 gems

* opentelemetry-processor-baggage 0.2.1 (was 0.2.0)
* opentelemetry-resource-detector-azure 0.1.1 (was 0.1.0)
* opentelemetry-resource-detector-container 0.1.2 (was 0.1.1)
* opentelemetry-resource-detector-google_cloud_platform 0.1.1 (was 0.1.0)
* opentelemetry-propagator-ottrace 0.21.4 (was 0.21.3)
* opentelemetry-propagator-vitess 0.1.1 (was 0.1.0)
* opentelemetry-propagator-xray 0.22.3 (was 0.22.2)
* opentelemetry-helpers-mysql 0.1.2 (was 0.1.1)
* opentelemetry-helpers-sql-obfuscation 0.2.1 (was 0.2.0)
* opentelemetry-instrumentation-all 0.69.1 (was 0.69.0)
* opentelemetry-instrumentation-rails 0.33.1 (was 0.33.0)
* opentelemetry-instrumentation-ethon 0.21.9 (was 0.21.8)
* opentelemetry-instrumentation-excon 0.22.5 (was 0.22.4)
* opentelemetry-instrumentation-faraday 0.24.7 (was 0.24.6)
* opentelemetry-instrumentation-http 0.23.5 (was 0.23.4)
* opentelemetry-instrumentation-http_client 0.22.8 (was 0.22.7)
* opentelemetry-instrumentation-httpx 0.1.3 (was 0.1.2)
* opentelemetry-instrumentation-net_http 0.22.8 (was 0.22.7)
* opentelemetry-instrumentation-restclient 0.22.8 (was 0.22.7)
* opentelemetry-instrumentation-pg 0.29.1 (was 0.29.0)

* squash: Apply suggestions from code review

---------

Co-authored-by: OpenTelemetry Bot <[email protected]>
Co-authored-by: Ariel Valentin <[email protected]>
* fix: use AS::N subscriber for serialize events

The details for Context management (i.e. setting current span) are
already handled by the OTel ActiveSupport instrumentation. Reuse
the notifications subscriber here for ActiveModel serialization events.

Reworked the example app into two: one Rails which works with the usual
SDK configuration and one standalone (no Rails) to demonstrate that the
subscription needs to be made after the SDK configuration is complete.
If the subscription is created during instrumentation install, the
subscription's tracer will be a NO-OP API tracer and won't produce
spans.

* update comments to reference Rails components consistently

Co-authored-by: Kayla Reopelle <[email protected]>

* default to console exporter

... but leave OTLP exporter gem in dependencies so that a curious person
can override without code changes to send to some OTLP receiver by
setting the appropriate environment variables.

* differentiate example app output from trace console output

* fixup! default to console exporter

* fixup! differentiate example app output from trace console output

---------

Co-authored-by: Kayla Reopelle <[email protected]>
Co-authored-by: Ariel Valentin <[email protected]>
…rs 0.20.3 (was 0.20.2) (open-telemetry#1287)

* release: Release opentelemetry-instrumentation-active_model_serializers 0.20.3 (was 0.20.2)

* docs: Update instrumentation/active_model_serializers/CHANGELOG.md

* ci: Workaround for JRuby

Fixes open-telemetry#1289

* squash: Make the release tooling happy

---------

Co-authored-by: OpenTelemetry Bot <[email protected]>
Co-authored-by: Ariel Valentin <[email protected]>
Co-authored-by: Ariel Valentin <[email protected]>
* Add references to released logs gems
* Test Rails 7.0 - 8.0
* Rubocop
* Set gem version
…ntelemetry-ruby-contrib into logger-instrumentation
Test the outcome rather than the presence of variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants