Skip to content

Commit

Permalink
datadoglogreceiver
Browse files Browse the repository at this point in the history
  • Loading branch information
meenal-developer committed Apr 29, 2024
1 parent 2785568 commit a21977d
Show file tree
Hide file tree
Showing 13 changed files with 1,060 additions and 0 deletions.
1 change: 1 addition & 0 deletions receiver/datadoglogreceiver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
10 changes: 10 additions & 0 deletions receiver/datadoglogreceiver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Datadog Log

Example:

```yaml
receivers:
datadoglog:
endpoint: localhost:8121
read_timeout: 60s
```
17 changes: 17 additions & 0 deletions receiver/datadoglogreceiver/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0 language governing permissions and
// limitations under the License.

package datadoglogreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/datadoglogreceiver"

import (
"time"

"go.opentelemetry.io/collector/config/confighttp"
)

type Config struct {
confighttp.HTTPServerSettings `mapstructure:",squash"`
// ReadTimeout of the http server
ReadTimeout time.Duration `mapstructure:"read_timeout"`
}
16 changes: 16 additions & 0 deletions receiver/datadoglogreceiver/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package datadoglogreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/datadoglogreceiver"

import (
"testing"

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

func TestCreateDefaultConfig(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
assert.NotNil(t, cfg, "failed to create default config")
}
6 changes: 6 additions & 0 deletions receiver/datadoglogreceiver/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

//go:generate mdatagen metadata.yaml

package datadoglogreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/datadoglogreceiver"
45 changes: 45 additions & 0 deletions receiver/datadoglogreceiver/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package datadoglogreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/datadoglogreceiver"

import (
"context"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/receiver"
"time"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/datadoglogreceiver/internal/metadata"
)

// NewFactory creates a factory for DataDog receiver.
func NewFactory() receiver.Factory {
return receiver.NewFactory(
metadata.Type,
createDefaultConfig,
receiver.WithLogs(createLogsReceiver, metadata.LogsStability))

}

func createDefaultConfig() component.Config {
return &Config{
HTTPServerSettings: confighttp.HTTPServerSettings{
Endpoint: "localhost:8121",
},
ReadTimeout: 60 * time.Second,
}
}

func createLogsReceiver(_ context.Context, params receiver.CreateSettings, cfg component.Config, consumer consumer.Logs) (r receiver.Logs, err error) {
rcfg := cfg.(*Config)
r = receivers.GetOrAdd(cfg, func() component.Component {
dd, _ := newDataDogReceiver(rcfg, consumer, params)
return dd
})
return r, nil
}

var receivers = sharedcomponent.NewSharedComponents()
23 changes: 23 additions & 0 deletions receiver/datadoglogreceiver/factory_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package datadoglogreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/datadoglogreceiver"

import (
"context"
"testing"

"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/receiver/receivertest"
)

func TestCreateReceiver(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
cfg.(*Config).Endpoint = "http://localhost:0"

tReceiver, err := factory.CreateLogsReceiver(context.Background(), receivertest.NewNopCreateSettings(), cfg, consumertest.NewNop())
assert.NoError(t, err)
assert.NotNil(t, tReceiver, "receiver creation failed")
}
75 changes: 75 additions & 0 deletions receiver/datadoglogreceiver/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/datadogreceiver

go 1.20

require (
github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent v0.84.0
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector v0.84.0
go.opentelemetry.io/collector/component v0.84.0
go.opentelemetry.io/collector/config/confighttp v0.84.0
go.opentelemetry.io/collector/consumer v0.84.0
go.opentelemetry.io/collector/pdata v1.0.0-rcv0014
go.opentelemetry.io/collector/receiver v0.84.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/knadh/koanf/v2 v2.0.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/cors v1.9.0 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector/config/configauth v0.84.0 // indirect
go.opentelemetry.io/collector/config/configcompression v0.84.0 // indirect
go.opentelemetry.io/collector/config/configopaque v0.84.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.84.0 // indirect
go.opentelemetry.io/collector/config/configtls v0.84.0 // indirect
go.opentelemetry.io/collector/config/internal v0.84.0 // indirect
go.opentelemetry.io/collector/confmap v0.84.0 // indirect
go.opentelemetry.io/collector/exporter v0.84.0 // indirect
go.opentelemetry.io/collector/extension v0.84.0 // indirect
go.opentelemetry.io/collector/extension/auth v0.84.0 // indirect
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0014 // indirect
go.opentelemetry.io/collector/processor v0.84.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 // indirect
go.opentelemetry.io/otel v1.16.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

// v0.47.x and v0.48.x are incompatible, prefer to use v0.48.x
replace github.com/DataDog/datadog-agent/pkg/proto => github.com/DataDog/datadog-agent/pkg/proto v0.48.0-beta.1

replace github.com/DataDog/datadog-agent/pkg/trace => github.com/DataDog/datadog-agent/pkg/trace v0.48.0-beta.1

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

retract (
v0.76.2
v0.76.1
)
Loading

0 comments on commit a21977d

Please sign in to comment.