- Overview
- Quick Start
- Configuration Options
- Configuration Examples
- Filter Priority
- Performance Considerations
- Troubleshooting
This instrumentation provides visibility into JBoss Weld CDI (Contexts and Dependency Injection) proxy method invocations with configurable filtering to control which methods are traced.
- Weld Core 3.x
- Weld Core 4.x (including Weld 6.0.2+)
- Custom/Weld/ProxyCall: Traces from CDI interceptor chains (requires transaction context)
- Custom/Weld/ContextBean: Traces from Weld context bean invocations (standalone apps)
- Custom/Weld/BeanInstance: Traces from bean instance invocations (web applications)
By default, all CDI proxy methods are traced. No configuration needed:
# newrelic.yml - default behavior
common: &default_settings
app_name: my-weld-app
# Weld configuration optional - defaults to trace everythingTrace only specific methods to reduce overhead:
common: &default_settings
app_name: my-weld-app
weld:
filtering_enabled: true
proxycall:
track_full_names:
- "com.example.MyService:businessMethod"
- "com.example.OrderService:processOrder"| Setting | Type | Default | Description |
|---|---|---|---|
weld.filtering_enabled |
boolean | false |
Enable whitelist filtering. When true, ONLY methods in whitelist are traced |
weld.ignore_traces_enabled |
boolean | false |
Enable blacklist filtering. When true, methods matching ignore patterns are NOT traced |
| Setting | Type | Description |
|---|---|---|
weld.proxycall.track_full_names |
list | Exact class:method names to trace (e.g., "com.example.MyClass:myMethod") |
weld.proxycall.track_regex_patterns |
list | Regex patterns for matching methods (e.g., "com\\.example\\..*Service:process.*") |
| Setting | Type | Description |
|---|---|---|
weld.beaninstance.track_full_names |
list | Exact class:method names for BeanInstance tracing |
weld.beaninstance.track_regex_patterns |
list | Regex patterns for BeanInstance tracing |
| Setting | Type | Description |
|---|---|---|
weld.ignored_trace_patterns |
list | Wildcard patterns for methods to ignore (e.g., "com.example.MyClass:*", "*.Internal*:*") |
Trace only explicitly listed methods:
weld:
filtering_enabled: true
proxycall:
track_full_names:
- "com.example.OrderService:createOrder"
- "com.example.OrderService:updateOrder"
- "com.example.PaymentService:processPayment"
beaninstance:
track_full_names: [] # Don't trace BeanInstanceResult:
- ✅ Traces:
OrderService:createOrder,OrderService:updateOrder,PaymentService:processPayment - ❌ Ignores: All other methods
Trace methods matching patterns:
weld:
filtering_enabled: true
proxycall:
track_regex_patterns:
- "com\\.example\\..*Service:process.*" # All *Service classes, process* methods
- "com\\.example\\.core\\..*:execute.*" # All core.* classes, execute* methodsResult:
- ✅ Traces:
OrderService:processOrder,PaymentService:processPayment,core.TaskExecutor:executeTask - ❌ Ignores:
OrderService:createOrder,DataRepository:findAll
Use both exact names and patterns:
weld:
filtering_enabled: true
proxycall:
track_full_names:
- "com.example.CriticalService:importantMethod" # Must trace this
track_regex_patterns:
- "com\\.example\\..*Service:process.*" # Plus all process* methodsResult:
- ✅ Traces:
CriticalService:importantMethod(exact),OrderService:processPayment(regex) - ❌ Ignores: Everything else
Trace everything EXCEPT specific methods:
weld:
filtering_enabled: false # Don't use whitelist
ignore_traces_enabled: true
ignored_trace_patterns:
- "com.example.HealthCheck:*" # Ignore all HealthCheck methods
- "com.example.Metrics:*" # Ignore all Metrics methods
- "*.Internal*:*" # Ignore all classes containing "Internal"Result:
- ✅ Traces: All methods except HealthCheck, Metrics, and Internal classes
- ❌ Ignores:
HealthCheck:ping,Metrics:collect,InternalService:process
Whitelist specific methods, then blacklist a subset:
weld:
filtering_enabled: true
proxycall:
track_regex_patterns:
- "com\\.example\\..*Service:.*" # Whitelist all *Service methods
ignore_traces_enabled: true
ignored_trace_patterns:
- "com.example.HealthCheckService:*" # But ignore HealthCheckService
- "*.MetricsService:collect*" # And ignore collect* methodsResult:
- ✅ Traces:
OrderService:createOrder,PaymentService:processPayment - ❌ Ignores:
HealthCheckService:ping(blacklisted),MetricsService:collectStats(blacklisted) - Note: Blacklist takes precedence over whitelist
Disable all tracing with empty whitelist:
weld:
filtering_enabled: true
proxycall:
track_full_names: []
track_regex_patterns: []Result:
- ❌ No methods traced (empty whitelist blocks everything)
Minimal overhead for production:
weld:
filtering_enabled: true
proxycall:
track_regex_patterns:
- "com\\.mycompany\\.business\\..*:execute.*" # Only business logic
- "com\\.mycompany\\.api\\..*Controller:.*" # And API controllers
ignore_traces_enabled: true
ignored_trace_patterns:
- "*.health.*:*" # Skip health checks
- "*.metrics.*:*" # Skip metrics
- "*.logging.*:*" # Skip logging utilities
beaninstance:
track_regex_patterns: [] # Disable BeanInstance tracingVerbose tracing for development:
weld:
filtering_enabled: false # Trace everything
ignore_traces_enabled: false # Don't ignore anything
log_level: finest # See all filter decisions in agent logFilters are applied in this order:
- Blacklist (ignore patterns) - Checked first, takes highest precedence
- Whitelist (track patterns) - Checked second, only if not blacklisted
- Default - If filtering disabled, all methods traced
Method invoked
↓
Is blacklisted? (ignore patterns)
↓ YES → Skip tracing (no metric created)
↓ NO
↓
Is filtering enabled?
↓ NO → Create trace (default behavior)
↓ YES
↓
Is whitelisted? (exact name OR regex pattern)
↓ YES → Create trace
↓ NO → Skip tracing (no metric created)
weld:
filtering_enabled: true
proxycall:
track_regex_patterns:
- "com\\.example\\..*:.*" # Whitelist all com.example.*
ignore_traces_enabled: true
ignored_trace_patterns:
- "com.example.Test*:*" # Blacklist Test* classesResults:
com.example.OrderService:create→ ✅ Traced (whitelisted, not blacklisted)com.example.TestHelper:setup→ ❌ Ignored (whitelisted BUT blacklisted - blacklist wins)com.other.Service:method→ ❌ Ignored (not whitelisted)
Filtered methods (not traced):
- No tracer objects created
- No metric data collected
- No span events generated
- Minimal CPU for filter check only
Traced methods:
- Creates tracer object (~1-2 KB memory)
- Collects timing and metric data
- Generates span events (if enabled)
-
Use Whitelist in Production
filtering_enabled: true proxycall: track_regex_patterns: - "com\\.mycompany\\.critical\\..*:.*" # Only business-critical classes
-
Blacklist High-Frequency Methods
ignore_traces_enabled: true ignored_trace_patterns: - "*.HealthCheck:*" # Called every 10s - "*.Heartbeat:*" # Called every 5s
-
Avoid Over-Broad Patterns
# ❌ BAD: Matches everything track_regex_patterns: - ".*:.*" # ✅ GOOD: Matches specific packages track_regex_patterns: - "com\\.mycompany\\.business\\..*:.*"
-
Combine Strategies for Optimal Performance
# Whitelist business logic + blacklist high-frequency filtering_enabled: true proxycall: track_regex_patterns: - "com\\.mycompany\\.business\\..*:.*" ignore_traces_enabled: true ignored_trace_patterns: - "*.Cache*:*" - "*.Pool*:*"
Configuration changes in newrelic.yml are detected automatically via AgentConfigListener:
- Edit
newrelic.ymlwith new filter patterns - Changes take effect within 60 seconds (next config poll)
- No agent restart required
- Check agent log for confirmation:
INFO: New Relic WeldTraceFilterConfig: Filtering enabled: true INFO: New Relic WeldTraceFilterConfig: Loaded 3 ProxyCall regex patterns
Format: "fully.qualified.ClassName:methodName"
track_full_names:
- "com.example.OrderService:createOrder"
- "com.example.PaymentService:processPayment"Format: Java regex with escaped dots
track_regex_patterns:
- "com\\.example\\..*Service:.*" # All *Service classes, all methods
- "com\\.example\\.core\\..*:execute.*" # core.* package, execute* methods
- ".*\\.business\\..*:process.*" # Any business package, process* methodsImportant: Escape dots in package names as \\. (YAML requires double backslash)
Format: Simple wildcards with *
ignored_trace_patterns:
- "com.example.TestHelper:*" # All methods on TestHelper
- "*.Internal*:*" # All classes containing "Internal"
- "com.example.*:toString" # All toString methods in com.exampleCheck:
weld:
filtering_enabled: true # ← Must be true!
proxycall:
track_full_names:
- "com.example.MyService:myMethod"Verify in agent log:
grep "WeldTraceFilterConfig: Filtering enabled" newrelic/logs/*.log
# Should show: "Filtering enabled: true"Check wildcard syntax:
# ✅ CORRECT:
ignored_trace_patterns:
- "com.example.MyClass:*" # Simple wildcard
# ❌ WRONG:
ignored_trace_patterns:
- "com.example.MyClass:.*" # This is regex syntax, won't workVerify pattern loading:
grep "TraceIgnoreConfig: Added ignore pattern" newrelic/logs/*.log
# Check the converted regex patternExample: Custom/Weld/ProxyCall/com.example.MyService$Proxy$_$$_WeldSubclass/method
Solution: Upgrade to v2.0.0+ which automatically cleans proxy class names.
Expected: Custom/Weld/ProxyCall/com.example.MyService/method
Check log level (set to fine or finest for debugging):
log_level: fineCheck agent log for filtering decisions:
# See which methods are whitelisted/blacklisted
grep -E "(whitelisted|blacklisted|matched pattern)" newrelic/logs/*.log
# See filter configuration loading
grep -E "(WeldTraceFilterConfig|TraceIgnoreConfig)" newrelic/logs/*.logSolution: Enable filtering to reduce traced methods:
weld:
filtering_enabled: true
proxycall:
track_regex_patterns:
- "com\\.mycompany\\.critical\\..*:.*" # Only critical packages
ignore_traces_enabled: true
ignored_trace_patterns:
- "*.Cache*:*" # High-frequency methods
- "*.Pool*:*"
- "*.health.*:*"Match all methods in a package:
track_regex_patterns:
- "com\\.example\\.services\\..*:.*"Match specific method patterns:
track_regex_patterns:
- ".*:execute.*" # All execute* methods
- ".*:process.*" # All process* methods
- ".*Service:handle.*" # All *Service classes, handle* methodsMatch nested packages:
track_regex_patterns:
- "com\\.example\\.(api|business)\\..*:.*" # Match api OR business packagesMatch class hierarchies:
ignored_trace_patterns:
- "com.example.base.*:*" # All classes in base package and subpackagesMatch method name patterns:
ignored_trace_patterns:
- "*:get*" # All getter methods (not recommended - too broad)
- "*:toString" # All toString methods
- "*:hashCode" # All hashCode methods-
Enable verbose logging:
log_level: finest
-
Test a method invocation
-
Check agent log:
# See filter decisions grep "WeldTraceFilterConfig" newrelic/logs/*.log | tail -50 # See what patterns matched grep "matched pattern" newrelic/logs/*.log # See what was blacklisted grep "Ignoring trace" newrelic/logs/*.log
-
Verify metrics created:
# In New Relic, run NRQL: SELECT count(*) FROM Metric WHERE appName = 'your-app-name' AND metricName LIKE 'Custom/Weld/%' FACET metricName
All v1.0.0 configurations continue to work unchanged. New filtering features are opt-in.
If experiencing high memory usage:
# Add whitelist to reduce traced methods
weld:
filtering_enabled: true
proxycall:
track_regex_patterns:
- "com\\.yourcompany\\.business\\..*:.*"If seeing proxy suffixes in metric names:
- Upgrade to v2.0.0+ (automatic cleaning)
- No configuration change needed
If using custom ignore patterns:
- Verify wildcard patterns work correctly:
# v2.0.0+ correctly handles wildcards ignored_trace_patterns: - "com.example.MyClass:*" # Now works correctly
For issues or questions:
- GitHub Issues: https://github.com/newrelic-experimental/newrelic-java-weld/issues
- New Relic Docs: https://docs.newrelic.com/
See CHANGELOG.md for detailed version history.