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

NH-90184: add feature - add_tracer on function #153

Merged
merged 1 commit into from
Dec 12, 2024
Merged

Conversation

xuan-cao-swi
Copy link
Contributor

@xuan-cao-swi xuan-cao-swi commented Sep 3, 2024

Description

Add the feature that can instrument functions.

Usage
(Both examples should produce an additional span for the new_method function):

For Ruby script:

class MyClass
  include SolarWindsAPM::API::Tracer

  def new_method(param1, param2)
    param1 + param2
  end

  add_tracer :new_method, 'custom_name', { attributes: { 'foo' => 'bar' }, kind: :consumer }
end

my_class = MyClass.new
my_class.new_method(1, 2)

For Rails (e.g., controller):

class PagesController < ApplicationController
  include SolarWindsAPM::API::Tracer

  def new_method(param1, param2)
    param1 + param2
  end

  add_tracer :new_method, 'custom_name', { attributes: { 'foo' => 'bar' }, kind: :consumer }

  # e.g., curl http://0.0.0.0:8002/about
  def about
    new_method(1, 2)
  end
end

Test (if applicable)

Added unit test
Ad-hoc test on rails controller

@xuan-cao-swi xuan-cao-swi requested a review from a team as a code owner September 3, 2024 18:44
Copy link

@jerrytfleung jerrytfleung left a comment

Choose a reason for hiding this comment

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

LGTM

@xuan-cao-swi xuan-cao-swi merged commit 5fc31a2 into main Dec 12, 2024
14 checks passed
@xuan-cao-swi xuan-cao-swi changed the title Nh-90184: add feature - add_tracer on function NH-90184: add feature - add_tracer on function Dec 12, 2024
@xuan-cao-swi xuan-cao-swi deleted the NH-90184 branch December 12, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants