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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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
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.

1 participant