Skip to content

Commit

Permalink
[exporter/datadog]: resolve conflicts merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmustin committed Jan 4, 2021
2 parents f34c7ee + 330f787 commit d457e6b
Show file tree
Hide file tree
Showing 80 changed files with 4,384 additions and 155 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ exporter/jaegerthrifthttpexporter/ @open-telemetry/collector-contrib-app
exporter/kinesisexporter/ @open-telemetry/collector-contrib-approvers @owais
exporter/loadbalancingexporter/ @open-telemetry/collector-contrib-approvers @jpkrohling
exporter/logzioexporter/ @open-telemetry/collector-contrib-approvers @yyyogev
exporter/lokiexporter/ @open-telemetry/collector-contrib-approvers @gramidt
exporter/newrelicexporter/ @open-telemetry/collector-contrib-approvers @MrAlias
exporter/sapmexporter/ @open-telemetry/collector-contrib-approvers @owais @dmitryax
exporter/sentryexporter/ @open-telemetry/collector-contrib-approvers @AbhiPrasad
Expand Down
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ updates:
directory: "/exporter/logzioexporter"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/exporter/lokiexporter"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/exporter/newrelicexporter"
schedule:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "CodeQL Analysis"

on:
workflow_dispatch:
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '30 1 * * *'

jobs:
CodeQL-Build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: go

- name: Autobuild
uses: github/codeql-action/autobuild@v1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
4 changes: 2 additions & 2 deletions exporter/awsemfexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemf
go 1.14

require (
github.com/aws/aws-sdk-go v1.36.9
github.com/aws/aws-sdk-go v1.36.19
github.com/census-instrumentation/opencensus-proto v0.3.0
github.com/golang/protobuf v1.4.3
github.com/google/uuid v1.1.2
github.com/google/uuid v1.1.3
github.com/stretchr/testify v1.6.1
go.opentelemetry.io/collector v0.17.0
go.uber.org/zap v1.16.0
Expand Down
6 changes: 4 additions & 2 deletions exporter/awsemfexporter/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:o
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.35.5/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k=
github.com/aws/aws-sdk-go v1.36.9 h1:TS667yc08a/EHGBqFrfOItpnzSrBFwIf2gQGlDhhQsg=
github.com/aws/aws-sdk-go v1.36.9/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.36.19 h1:zbJZKkxeDiYxUYFjymjWxPye+qa1G2gRVyhIzZrB9zA=
github.com/aws/aws-sdk-go v1.36.19/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down Expand Up @@ -449,6 +449,8 @@ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.3 h1:twObb+9XcuH5B9V1TBCvvvZoO6iEdILi2a76PYn5rJI=
github.com/google/uuid v1.1.3/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
Expand Down
2 changes: 1 addition & 1 deletion exporter/awsprometheusremotewriteexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awspro
go 1.15

require (
github.com/aws/aws-sdk-go v1.36.9
github.com/aws/aws-sdk-go v1.36.19
github.com/stretchr/testify v1.6.1
go.opentelemetry.io/collector v0.17.0
go.uber.org/zap v1.16.0
Expand Down
4 changes: 2 additions & 2 deletions exporter/awsprometheusremotewriteexporter/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:o
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.35.5/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k=
github.com/aws/aws-sdk-go v1.36.9 h1:TS667yc08a/EHGBqFrfOItpnzSrBFwIf2gQGlDhhQsg=
github.com/aws/aws-sdk-go v1.36.9/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.36.19 h1:zbJZKkxeDiYxUYFjymjWxPye+qa1G2gRVyhIzZrB9zA=
github.com/aws/aws-sdk-go v1.36.19/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down
2 changes: 1 addition & 1 deletion exporter/awsxrayexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxra
go 1.14

require (
github.com/aws/aws-sdk-go v1.36.9
github.com/aws/aws-sdk-go v1.36.19
github.com/open-telemetry/opentelemetry-collector-contrib/internal/awsxray v0.0.0-00010101000000-000000000000
github.com/stretchr/testify v1.6.1
go.opentelemetry.io/collector v0.17.0
Expand Down
4 changes: 2 additions & 2 deletions exporter/awsxrayexporter/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:o
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.35.5/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k=
github.com/aws/aws-sdk-go v1.36.9 h1:TS667yc08a/EHGBqFrfOItpnzSrBFwIf2gQGlDhhQsg=
github.com/aws/aws-sdk-go v1.36.9/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.36.19 h1:zbJZKkxeDiYxUYFjymjWxPye+qa1G2gRVyhIzZrB9zA=
github.com/aws/aws-sdk-go v1.36.19/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down
70 changes: 70 additions & 0 deletions exporter/awsxrayexporter/translator/cause.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ func parseException(exceptionType string, message string, stacktrace string, lan
exceptions = fillJavaStacktrace(stacktrace, exceptions)
case "python":
exceptions = fillPythonStacktrace(stacktrace, exceptions)
case "javascript":
exceptions = fillJavaScriptStacktrace(stacktrace, exceptions)
}

return exceptions
Expand Down Expand Up @@ -346,3 +348,71 @@ func fillPythonStacktrace(stacktrace string, exceptions []awsxray.Exception) []a

return exceptions
}

func fillJavaScriptStacktrace(stacktrace string, exceptions []awsxray.Exception) []awsxray.Exception {
r := textproto.NewReader(bufio.NewReader(strings.NewReader(stacktrace)))

// Skip first line containing top level exception / message
r.ReadLine()
exception := &exceptions[0]
var line string
line, err := r.ReadLine()
if err != nil {
return exceptions
}

exception.Stack = make([]awsxray.StackFrame, 0)
for {
if strings.HasPrefix(line, " at ") {
parenIdx := strings.IndexByte(line, '(')
label := ""
path := ""
lineIdx := 0
if parenIdx >= 0 && line[len(line)-1] == ')' {
label = line[7:parenIdx]
path = line[parenIdx+1 : len(line)-1]
} else if parenIdx < 0 {
label = ""
path = line[7:]
}

colonFirstIdx := strings.IndexByte(path, ':')
colonSecondIdx := indexOf(path, ':', colonFirstIdx)

if colonFirstIdx >= 0 && colonSecondIdx >= 0 && colonFirstIdx != colonSecondIdx {
lineStr := path[colonFirstIdx+1 : colonSecondIdx]
path = path[0:colonFirstIdx]
lineIdx, _ = strconv.Atoi(lineStr)
} else if colonFirstIdx < 0 && strings.Contains(path, "native") {
path = "native"
}

// only append the exception if all the values of the exception are not default
if path != "" || label != "" || lineIdx != 0 {
stack := awsxray.StackFrame{
Path: aws.String(path),
Label: aws.String(label),
Line: aws.Int(lineIdx),
}
exception.Stack = append(exception.Stack, stack)
}
}
line, err = r.ReadLine()
if err != nil {
break
}
}
return exceptions
}

// indexOf returns position of the first occurrence of a Byte in str starting at pos index.
func indexOf(str string, c byte, pos int) int {
if pos < 0 {
return -1
}
index := strings.IndexByte(str[pos+1:], c)
if index > -1 {
return index + pos + 1
}
return -1
}
75 changes: 75 additions & 0 deletions exporter/awsxrayexporter/translator/cause_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,3 +629,78 @@ TypeError: must be str, not int`
assert.Equal(t, "main.py", *exceptions[0].Stack[1].Path)
assert.Equal(t, 14, *exceptions[0].Stack[1].Line)
}

func TestParseExceptionWithJavaScriptStacktrace(t *testing.T) {
exceptionType := "TypeError"
message := "Cannot read property 'value' of null"
// We ignore the exception type / message from the stacktrace
stacktrace := `TypeError: Cannot read property 'value' of null
at speedy (/home/gbusey/file.js:6:11)
at makeFaster (/home/gbusey/file.js:5:3)
at Object.<anonymous> (/home/gbusey/file.js:10:1)
at node.js:906:3
at Array.forEach (native)
at native`

exceptions := parseException(exceptionType, message, stacktrace, "javascript")
assert.Len(t, exceptions, 1)
assert.NotEmpty(t, exceptions[0].ID)
assert.Equal(t, "TypeError", *exceptions[0].Type)
assert.Equal(t, "Cannot read property 'value' of null", *exceptions[0].Message)
assert.Len(t, exceptions[0].Stack, 6)
assert.Equal(t, "speedy ", *exceptions[0].Stack[0].Label)
assert.Equal(t, "/home/gbusey/file.js", *exceptions[0].Stack[0].Path)
assert.Equal(t, 6, *exceptions[0].Stack[0].Line)
assert.Equal(t, "makeFaster ", *exceptions[0].Stack[1].Label)
assert.Equal(t, "/home/gbusey/file.js", *exceptions[0].Stack[1].Path)
assert.Equal(t, 5, *exceptions[0].Stack[1].Line)
assert.Equal(t, "Object.<anonymous> ", *exceptions[0].Stack[2].Label)
assert.Equal(t, "/home/gbusey/file.js", *exceptions[0].Stack[2].Path)
assert.Equal(t, 10, *exceptions[0].Stack[2].Line)
assert.Equal(t, "", *exceptions[0].Stack[3].Label)
assert.Equal(t, "node.js", *exceptions[0].Stack[3].Path)
assert.Equal(t, 906, *exceptions[0].Stack[3].Line)
assert.Equal(t, "Array.forEach ", *exceptions[0].Stack[4].Label)
assert.Equal(t, "native", *exceptions[0].Stack[4].Path)
assert.Equal(t, 0, *exceptions[0].Stack[4].Line)
assert.Equal(t, "", *exceptions[0].Stack[5].Label)
assert.Equal(t, "native", *exceptions[0].Stack[5].Path)
assert.Equal(t, 0, *exceptions[0].Stack[5].Line)
}

func TestParseExceptionWithStacktraceNotJavaScript(t *testing.T) {
exceptionType := "TypeError"
message := "Cannot read property 'value' of null"
// We ignore the exception type / message from the stacktrace
stacktrace := `TypeError: Cannot read property 'value' of null
at speedy (/home/gbusey/file.js:6:11)
at makeFaster (/home/gbusey/file.js:5:3)
at Object.<anonymous> (/home/gbusey/file.js:10:1)`

exceptions := parseException(exceptionType, message, stacktrace, "")
assert.Len(t, exceptions, 1)
assert.NotEmpty(t, exceptions[0].ID)
assert.Equal(t, "TypeError", *exceptions[0].Type)
assert.Equal(t, "Cannot read property 'value' of null", *exceptions[0].Message)
assert.Empty(t, exceptions[0].Stack)
}

func TestParseExceptionWithJavaScriptStactracekMalformedLines(t *testing.T) {
exceptionType := "TypeError"
message := "Cannot read property 'value' of null"
// We ignore the exception type / message from the stacktrace
stacktrace := `TypeError: Cannot read property 'value' of null
at speedy (/home/gbusey/file.js)
at makeFaster (/home/gbusey/file.js:5:3)malformed123
at Object.<anonymous> (/home/gbusey/file.js:10`

exceptions := parseException(exceptionType, message, stacktrace, "javascript")
assert.Len(t, exceptions, 1)
assert.NotEmpty(t, exceptions[0].ID)
assert.Equal(t, "TypeError", *exceptions[0].Type)
assert.Equal(t, "Cannot read property 'value' of null", *exceptions[0].Message)
assert.Len(t, exceptions[0].Stack, 1)
assert.Equal(t, "speedy ", *exceptions[0].Stack[0].Label)
assert.Equal(t, "/home/gbusey/file.js", *exceptions[0].Stack[0].Path)
assert.Equal(t, 0, *exceptions[0].Stack[0].Line)
}
13 changes: 11 additions & 2 deletions exporter/datadogexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ The exporter will try to retrieve a hostname following the OpenTelemetry semanti

See the sample configuration file under the `example` folder for other available options.

## Trace Export Configuration

## Trace exporter
### **Important Pipeline Setup Details**

This exporter assumes a pipeline using the datadog exporter also includes a [batch processor](https://github.com/open-telemetry/opentelemetry-collector/tree/master/processor/batchprocessor) configured with the following:
Expand Down Expand Up @@ -67,3 +66,13 @@ service:
processors: [batch]
exporters: [datadog/api]
```

## Metric exporter

The metrics exporter does not assume any specific pipeline setup.
There are a number of optional settings for configuring how to send your metrics:

| Option name | Description | Default |
|-|-|-|
| `send_monotonic_counters` | Cumulative monotonic metrics are sent as time-normalized deltas between successive measurements. Disable this flag to send get the raw, monotonically increasing value. | `true` |
| `delta_ttl` | Maximum number of seconds values from cumulative monotonic metrics are kept in memory. | 3600 |
8 changes: 8 additions & 0 deletions exporter/datadogexporter/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ type MetricsConfig struct {
// Buckets states whether to report buckets from distribution metrics
Buckets bool `mapstructure:"report_buckets"`

// SendMonotonic states whether to report cumulative monotonic metrics as counters
// or gauges
SendMonotonic bool `mapstructure:"send_monotonic_counter"`

// DeltaTTL defines the time that previous points of a cumulative monotonic
// metric are kept in memory to calculate deltas
DeltaTTL int64 `mapstructure:"delta_ttl"`

// TCPAddr.Endpoint is the host of the Datadog intake server to send metrics to.
// If unset, the value is obtained from the Site.
confignet.TCPAddr `mapstructure:",squash"`
Expand Down
13 changes: 13 additions & 0 deletions exporter/datadogexporter/example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ exporters:
#
# report_buckets: false

## @param send_monotonic_counter - boolean - optional - default: true
## Whether to report monotonic metrics as counters or gauges (raw value).
## See https://docs.datadoghq.com/integrations/guide/prometheus-metrics/#counter
## for further details
#
# send_monotonic_counter: true

## @param - delta_ttl - integer - optional - default: 3600
## The amount of time (in seconds) that values are kept in memory for
## calculating deltas for cumulative monotonic metrics.
#
# delta_ttl: 3600

## @param endpoint - string - optional
## The host of the Datadog intake server to send metrics to.
## If unset the value is obtained through the `site` parameter in the `api` section.
Expand Down
2 changes: 2 additions & 0 deletions exporter/datadogexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func createDefaultConfig() configmodels.Exporter {
TCPAddr: confignet.TCPAddr{
Endpoint: "", // set during config sanitization
},
SendMonotonic: true,
DeltaTTL: 3600,
ExporterConfig: config.MetricsExporterConfig{
ResourceAttributesAsTags: false,
},
Expand Down
6 changes: 6 additions & 0 deletions exporter/datadogexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ func TestCreateDefaultConfig(t *testing.T) {
Traces: config.TracesConfig{
SampleRate: 1,
},
Metrics: config.MetricsConfig{
DeltaTTL: 3600,
SendMonotonic: true,
},
SendMetadata: true,
OnlyMetadata: false,
}, cfg, "failed to create default config")
Expand Down Expand Up @@ -94,6 +98,8 @@ func TestLoadConfig(t *testing.T) {
TCPAddr: confignet.TCPAddr{
Endpoint: "https://api.datadoghq.eu",
},
DeltaTTL: 3600,
SendMonotonic: true,
},

Traces: config.TracesConfig{
Expand Down
7 changes: 5 additions & 2 deletions exporter/datadogexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ go 1.14

require (
github.com/DataDog/datadog-agent/pkg/trace/exportable v0.0.0-20201016145401-4646cf596b02
github.com/aws/aws-sdk-go v1.36.9
github.com/aws/aws-sdk-go v1.36.15
github.com/gogo/protobuf v1.3.1
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.0.0-00010101000000-000000000000
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/stretchr/testify v1.6.1
github.com/zorkian/go-datadog-api v2.29.0+incompatible // indirect
go.opentelemetry.io/collector v0.17.0
go.uber.org/zap v1.16.0
gopkg.in/DataDog/dd-trace-go.v1 v1.27.1
gopkg.in/DataDog/dd-trace-go.v1 v1.28.0
gopkg.in/zorkian/go-datadog-api.v2 v2.30.0
)

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => ../../internal/common
Loading

0 comments on commit d457e6b

Please sign in to comment.