Skip to content

Commit

Permalink
fix issues from @simitt's code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Ron cohen committed Jul 17, 2018
1 parent 3513b8d commit 6963569
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 33 deletions.
6 changes: 0 additions & 6 deletions model/error/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ import (

var (
Metrics = monitoring.Default.NewRegistry("apm-server.processor.error", monitoring.PublishExpvar)

transformations = monitoring.NewInt(Metrics, "transformations")
errorCounter = monitoring.NewInt(Metrics, "errors")
stacktraceCounter = monitoring.NewInt(Metrics, "stacktraces")
frameCounter = monitoring.NewInt(Metrics, "frames")
processorEntry = common.MapStr{"name": processorName, "event": errorDocType}
)

const (
Expand Down
9 changes: 9 additions & 0 deletions model/error/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ import (
"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/libbeat/monitoring"
)

var (
transformations = monitoring.NewInt(Metrics, "transformations")
errorCounter = monitoring.NewInt(Metrics, "errors")
stacktraceCounter = monitoring.NewInt(Metrics, "stacktraces")
frameCounter = monitoring.NewInt(Metrics, "frames")
processorEntry = common.MapStr{"name": processorName, "event": errorDocType}
)

type Payload struct {
Expand Down
4 changes: 3 additions & 1 deletion model/metric/payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/apm-server/config"
m "github.com/elastic/apm-server/model"
Expand Down Expand Up @@ -252,7 +253,8 @@ func TestPayloadDecode(t *testing.T) {

// its ok to ignore the outcome of this cast here because
// we assert everything below
payload, _ := payloadInterface.(*Payload)
payload, ok := payloadInterface.(*Payload)
require.True(t, ok)

// compare metrics separately as they may be ordered differently
if test.p != nil && test.p.Metrics != nil {
Expand Down
18 changes: 0 additions & 18 deletions model/metric/processor.go

This file was deleted.

19 changes: 19 additions & 0 deletions model/transform/transform.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package transform

import (
"regexp"

"github.com/elastic/apm-server/model"
"github.com/elastic/apm-server/sourcemap"
)

type Context struct {
Config Config
Metadata model.Metadata
}

type Config struct {
LibraryPattern *regexp.Regexp
ExcludeFromGrouping *regexp.Regexp
SmapMapper sourcemap.Mapper
}
2 changes: 1 addition & 1 deletion processor/error/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

package processor
package error

import (
err "github.com/elastic/apm-server/model/error"
Expand Down
2 changes: 0 additions & 2 deletions processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"github.com/elastic/beats/libbeat/monitoring"
)

type NewProcessor func() Processor

type Processor interface {
Validate(map[string]interface{}) error
Decode(map[string]interface{}) (model.Payload, error)
Expand Down
9 changes: 4 additions & 5 deletions processor/sourcemap/sourcemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ import (
)

var (
validateCount = monitoring.NewInt(sm.Metrics, "validation.count")
validateError = monitoring.NewInt(sm.Metrics, "validation.errors")

Processor = &sourcemapProcessor{
processor.PayloadProcessor{
ProcessorName: "sourcemap",
DecodePayload: sm.DecodePayload,
PayloadSchema: sm.PayloadSchema(),
DecodingCount: monitoring.NewInt(sm.Metrics, "decoding.count"),
DecodingError: monitoring.NewInt(sm.Metrics, "decoding.errors"),
ValidateCount: monitoring.NewInt(sm.Metrics, "validation.count"),
ValidateError: monitoring.NewInt(sm.Metrics, "validation.errors"),
},
}
)
Expand All @@ -49,7 +48,7 @@ type sourcemapProcessor struct {
}

func (p *sourcemapProcessor) Validate(raw map[string]interface{}) error {
validateCount.Inc()
p.PayloadProcessor.ValidateCount.Inc()

smap, ok := raw["sourcemap"].(string)
if !ok {
Expand All @@ -67,7 +66,7 @@ func (p *sourcemapProcessor) Validate(raw map[string]interface{}) error {

err = validation.Validate(raw, p.PayloadSchema)
if err != nil {
validateError.Inc()
p.PayloadProcessor.ValidateError.Inc()
}
return err
}

0 comments on commit 6963569

Please sign in to comment.