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

cloudtrace: not working anymore with rails >= v7.1.4 #27522

Open
koljaa opened this issue Oct 28, 2024 · 3 comments
Open

cloudtrace: not working anymore with rails >= v7.1.4 #27522

koljaa opened this issue Oct 28, 2024 · 3 comments
Assignees

Comments

@koljaa
Copy link

koljaa commented Oct 28, 2024

https://github.com/googleapis/google-cloud-ruby/blob/main/google-cloud-trace/lib/google/cloud/trace/notifications.rb#L121 This patch is not valid anymore for Rails version >= v7.1.4

See https://github.com/rails/rails/blob/v7.1.4/activesupport/lib/active_support/notifications/instrumenter.rb#L123

In our case the traces were arriving the service but with broken start times. Therefore the traces were not displayed in the Graph.

Environment details

  • Ruby version: 3.3.5
  • Gem name and version: google-cloud-trace 0.44.0
  • Rails version: >= v7.1.4

Steps to reproduce

Update to Rails >= v7.1.4

Code example

# example

Full backtrace

Traces are arriving the service but with broken start times so that the traces are not displayed in the Graph. However some traces can be found by directly searching with the trace id. That way i could see the broken start times.

@koljaa koljaa changed the title Cloud Trace Gem not working anymore with rails >= v7.1.4 cloudtrace: not working anymore with rails >= v7.1.4 Oct 30, 2024
@dazuma
Copy link
Member

dazuma commented Nov 22, 2024

The google-cloud-trace gem's instrumentation features are not currently actively maintained. I recommend using OpenTelemetry instead for trace instrumentation.

@koljaa
Copy link
Author

koljaa commented Nov 25, 2024

@dazuma thanks for your answer. So basically i would need to implement the complete rails instrumentation part? I think the fix is really easy by just adding another condition to check for rails version >=7.1.4. Any chance to get this implemented or can i provide a PR to add it?

@koljaa
Copy link
Author

koljaa commented Nov 26, 2024

        ##
        # @private
        #
        # active support event's time is:
        #
        # - rails <  7: time
        # - rails >= 7 && < 7.1.4 : timestamp in milliseconds
        # - rails >= 7.1.4: time
        def self.normalize_time time_or_float
          return time_or_float if Rails::VERSION::MAJOR < 7 || Gem::Version.new(Rails.version) >= Gem::Version.new('7.1.4')

          Time.at time_or_float / 1000
        end
      end

https://github.com/googleapis/google-cloud-ruby/blob/main/google-cloud-trace/lib/google/cloud/trace/notifications.rb#L121

That way its working again.

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

No branches or pull requests

2 participants