-
Notifications
You must be signed in to change notification settings - Fork 31
Conversation
a040b7c
to
41348fc
Compare
agent/agent.go
Outdated
func (a *Agent) countAsDropped(t model.Trace) { | ||
// We get the address of the struct holding the stats associated to the tags | ||
ts := a.Receiver.stats.getTagStats(Tags{}) | ||
atomic.AddInt64(&ts.TracesDropped, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think traces discarded to comply with a user request should be counted separately from those discarded for being badly formatted. i.e. let's count TracesFiltered
as a distinct thing from TracesDropped
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it also bothers me the amount of coupling between the Agent
and the Receiver
. This seems to be a classic example of feature envy. Maybe we should abstract this away? @talwai
agent/agent.go
Outdated
@@ -35,6 +35,7 @@ func (pt *processedTrace) weight() float64 { | |||
type Agent struct { | |||
Receiver *HTTPReceiver | |||
Concentrator *Concentrator | |||
Filter Filter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe take a []Filter
here so it can accommodate several blacklists that check against different fields (name
service
etc.)
agent/agent.go
Outdated
@@ -56,6 +57,7 @@ func NewAgent(conf *config.AgentConfig) *Agent { | |||
conf.ExtraAggregators, | |||
conf.BucketInterval.Nanoseconds(), | |||
) | |||
f := NewResourceFilter(conf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as per above, call this NewFilters
so that it is more generalized. implementing a name- and service- blacklist can be out of the scope PR, but let's make it easy for us to add this in the future
config/agent.go
Outdated
@@ -65,6 +65,8 @@ type AgentConfig struct { | |||
|
|||
// http/s proxying | |||
Proxy *ProxySettings | |||
|
|||
ResourceBlacklist []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe Blacklist map[string][]string
and have the current implementation only populate blacklist["resource"]
agent/agent.go
Outdated
|
||
if !a.Filter.Keep(root) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the new "general" scheme, loop over a.Filters
and check against each. As of now there'll be only one
filters/base.go
Outdated
) | ||
|
||
// Interface handles Span filtering | ||
type Interface interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just call it Filter
filters/resource.go
Outdated
f.blacklist = blacklist | ||
|
||
return f | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just do func NewResource() *Resource
then in filters/base you can do return []Filter{NewResource(conf)}
filters/resource.go
Outdated
) | ||
|
||
// Resource implements a resource-based filter | ||
type Resource struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call this ResourceFilter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it shouldn't be exported?
5bd9879
to
219c31b
Compare
32d7386
to
1b78231
Compare
1b78231
to
221d4bb
Compare
This PR enables filtering out certain traces based on their root resource name. The underlying motivation for it is to prevent traces such as those originated from heartbeat requests to be sent to the backend services.
Usage
A blacklist of regular expressions can be set through the agent configuration file or through the environment variable
DD_IGNORE_RESOURCE
.Entries must surrounded by double quotes and separated by comas.
INI File
ENV variable
DD_IGNORE_RESOURCE='"(GET|POST) /heartbeat", "another_entry"'
The regular expressions are evaluated using the RE2 engine. Accepted syntax is described here.
Performance impact
The performance impact of this feature was measured against two scenarios:
In both cases the impact seems to be negligibe: