Skip to content

Commit

Permalink
log support for attribute processor
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger committed Oct 23, 2020
1 parent 0f669d2 commit 37dc5d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions processor/attributesprocessor/attributes_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,23 @@ func (a *logAttributesProcessor) ProcessLogs(_ context.Context, ld pdata.Logs) (
if rs.IsNil() {
continue
}
ilss := rls.At(i).InstrumentationLibraryLogs()
ilss := rs.InstrumentationLibraryLogs()
resource := rs.Resource()
for j := 0; j < ilss.Len(); j++ {
ils := ilss.At(j)
if ils.IsNil() {
continue
}
logs := ils.Logs()
library := ils.InstrumentationLibrary()
for k := 0; k < logs.Len(); k++ {
lr := logs.At(k)
if lr.IsNil() {
// Do not create empty log records just to add attributes
continue
}

if a.skipLog(lr) {
if a.skipLog(lr, resource, library) {
continue
}

Expand All @@ -78,17 +80,17 @@ func (a *logAttributesProcessor) ProcessLogs(_ context.Context, ld pdata.Logs) (
// The logic determining if a log should be processed is set
// in the attribute configuration with the include and exclude settings.
// Include properties are checked before exclude settings are checked.
func (a *logAttributesProcessor) skipLog(lr pdata.LogRecord) bool {
func (a *logAttributesProcessor) skipLog(lr pdata.LogRecord, resource pdata.Resource, library pdata.InstrumentationLibrary) bool {
if a.include != nil {
// A false returned in this case means the log should not be processed.
if include := a.include.MatchLogRecord(lr); !include {
if include := a.include.MatchLogRecord(lr, resource, library); !include {
return true
}
}

if a.exclude != nil {
// A true returned in this case means the log should not be processed.
if exclude := a.exclude.MatchLogRecord(lr); exclude {
if exclude := a.exclude.MatchLogRecord(lr, resource, library); exclude {
return true
}
}
Expand Down
2 changes: 1 addition & 1 deletion processor/attributesprocessor/attributes_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (a *spanAttributesProcessor) ProcessTraces(_ context.Context, td pdata.Trac
continue
}
resource := rs.Resource()
ilss := rss.At(i).InstrumentationLibrarySpans()
ilss := rs.InstrumentationLibrarySpans()
for j := 0; j < ilss.Len(); j++ {
ils := ilss.At(j)
if ils.IsNil() {
Expand Down

0 comments on commit 37dc5d2

Please sign in to comment.