Skip to content

Conversation

xuan-cao-swi
Copy link
Contributor

@xuan-cao-swi xuan-cao-swi commented Sep 22, 2025

Description

Copilot generated this doc that state what it may suggest now with agents.md and compare to without agents.md

Without AGENTS.md Knowledge

❌ What I might suggest incorrectly:

# WRONG: Manual OpenTelemetry setup
require 'opentelemetry/sdk'

OpenTelemetry::SDK.configure do |c|
  c.service_name = 'my-app'
  c.use_all()
end

# WRONG: Generic tracer acquisition
tracer = OpenTelemetry.tracer_provider.tracer('my-app')

# WRONG: Manual span creation
tracer.in_span('database.query') do |span|
  span.set_attribute('query', sql)
  # database work
end

With AGENTS.md Knowledge

✅ What I suggest correctly now:

# CORRECT: Let the gem auto-initialize
require 'solarwinds_apm'

# CORRECT: Use service key, not manual config
# Set: SW_APM_SERVICE_KEY=api_token:service_name

# CORRECT: Use SolarWindsAPM API helpers
SolarWindsAPM::API.in_span('database.query', attributes: { 'query' => sql }) do
  # database work
end

# CORRECT: Method instrumentation
class DatabaseService
  include SolarWindsAPM::API::Tracer
  add_tracer :fetch_user, 'db.fetch_user', { 
    attributes: { 'table' => 'users' }, 
    kind: :client 
  }
  
  def fetch_user(id)
    # method implementation
  end
end

Gemfile Placement

❌ Without knowledge:

# WRONG: Early placement
gem 'solarwinds_apm'
gem 'rails'
gem 'pg'

✅ With AGENTS.md:

gem 'rails'
gem 'pg'
# ... other gems

# CORRECT: At the END
gem 'solarwinds_apm'

Testing Approach

❌ Without knowledge:

# WRONG: Running tests on host
bundle exec rspec

✅ With AGENTS.md:

# CORRECT: Container-based testing
bundle exec rake 'docker_tests[,,,APM_RUBY_TEST_KEY=<key>]'

# CORRECT: Single test file
bundle exec ruby -I test test/opentelemetry/solarwinds_propagator_test.rb

Metrics (Version-Aware)

❌ Without knowledge:

# WRONG: Using deprecated helpers in 7.0+
SolarWindsAPM::API.increment_metric('requests.count')

✅ With AGENTS.md:

# CORRECT: Use standard OTel Metrics API for 7.0+
Meter = OpenTelemetry.meter_provider.meter('solarwinds_apm.custom')
counter = Meter.create_counter('requests.count', 
  description: 'HTTP request count', 
  unit: '{request}'
)
counter.add(1, attributes: { 'method' => 'GET' })

Test (if applicable)

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