Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporter/datasetexporter]: Initial Commit #20733

Merged
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
015ca51
DataSetExporter: Initial Commit
martin-majlis-s1 Apr 6, 2023
0368966
Cleanup go.mod
martin-majlis-s1 Apr 6, 2023
35fa0a3
Reverse changes in elasticsearchexporter/config.go
martin-majlis-s1 Apr 10, 2023
7e59db9
Run mentioned commands
martin-majlis-s1 Apr 10, 2023
4d5ae44
Run make goporto
martin-majlis-s1 Apr 10, 2023
0d69b04
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 Apr 11, 2023
3d67349
Add replace line manually.
martin-majlis-s1 Apr 11, 2023
5b2277e
Add dummy comment to trigger EasyCLA check
martin-majlis-s1 Apr 11, 2023
565dd48
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 Apr 12, 2023
1f1cc43
I have executed - `make for-all CMD="make tidy"`
martin-majlis-s1 Apr 13, 2023
6a98d37
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 Apr 17, 2023
f921444
Incorporate changes from CR
martin-majlis-s1 Apr 17, 2023
beab130
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 Apr 17, 2023
29ef8c0
Add dataset exporter into tests for otelcontribcol
martin-majlis-s1 Apr 17, 2023
13de79f
Fix check - `make -j2 golint GROUP=other`
martin-majlis-s1 Apr 18, 2023
704ad5b
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 Apr 18, 2023
e89b708
Remove support for metrics and mention support for traces.
martin-majlis-s1 Apr 19, 2023
79758fa
Run make generate to update metadata table
martin-majlis-s1 Apr 19, 2023
bb772ac
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 Apr 21, 2023
bd4bd48
Remove unused function
martin-majlis-s1 Apr 21, 2023
7481264
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 Apr 25, 2023
550a25f
Update exporter/datasetexporter/factory_test.go
martin-majlis-s1 Apr 25, 2023
cd0cd8c
Update exporter/datasetexporter/config_test.go
martin-majlis-s1 Apr 25, 2023
214f405
Update exporter/datasetexporter/config_test.go
martin-majlis-s1 Apr 25, 2023
4ff64f7
Update exporter/datasetexporter/datasetexporter.go
martin-majlis-s1 Apr 25, 2023
5ac1476
Swap order of parameters in Equal function
martin-majlis-s1 Apr 25, 2023
1d9a927
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 Apr 26, 2023
38041df
Update dependencies
martin-majlis-s1 Apr 26, 2023
9564d18
Adjust code after running all those tools
martin-majlis-s1 Apr 26, 2023
9bcd3ad
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 Apr 27, 2023
81c55cc
Resolve the conflicts in versions
martin-majlis-s1 Apr 27, 2023
a2080bc
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 May 2, 2023
1026170
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 May 2, 2023
660c63a
Rerun command that has failed
martin-majlis-s1 May 2, 2023
0d9a1ea
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 May 3, 2023
2639b3a
Restore go.mod from main
martin-majlis-s1 May 3, 2023
098d558
Fix license check
martin-majlis-s1 May 3, 2023
ef97bae
Fix version check
martin-majlis-s1 May 3, 2023
81db459
Fix check-collector-module-versionr
martin-majlis-s1 May 3, 2023
ae758ff
Rerun all the remaining commands
martin-majlis-s1 May 3, 2023
892cdf2
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 May 4, 2023
c5bad0e
Merge branch 'main' into issue-20660-datasetexporter-initial-commit
martin-majlis-s1 May 5, 2023
f1268c2
Rename MaxDelayMs to maxDelayMs
martin-majlis-s1 May 5, 2023
24b9aa2
Modify metadata.yaml => `make generate` => adjust code
martin-majlis-s1 May 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/add-datasetexporter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: new_component

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: datasetexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add new DataSet exporter.

# One or more tracking issues related to the change
issues: [20660]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ exporter/clickhouseexporter/ @open-telemetry/collect
exporter/cassandraexporter/ @open-telemetry/collector-contrib-approvers @atoulme @emreyalvac
exporter/coralogixexporter/ @open-telemetry/collector-contrib-approvers @oded-dd @povilasv @matej-g
exporter/datadogexporter/ @open-telemetry/collector-contrib-approvers @mx-psi @gbbr @dineshg13 @liustanley @songy23
exporter/datasetexporter/ @open-telemetry/collector-contrib-approvers @atoulme @martin-majlis-s1
martin-majlis-s1 marked this conversation as resolved.
Show resolved Hide resolved
exporter/dynatraceexporter/ @open-telemetry/collector-contrib-approvers @dyladan @arminru @evan-bradley
exporter/elasticsearchexporter/ @open-telemetry/collector-contrib-approvers @JaredTan95
exporter/f5cloudexporter/ @open-telemetry/collector-contrib-approvers @gramidt
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ body:
- exporter/clickhouse
- exporter/coralogix
- exporter/datadog
- exporter/dataset
- exporter/dynatrace
- exporter/elasticsearch
- exporter/f5cloud
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ body:
- exporter/clickhouse
- exporter/coralogix
- exporter/datadog
- exporter/dataset
- exporter/dynatrace
- exporter/elasticsearch
- exporter/f5cloud
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ body:
- exporter/clickhouse
- exporter/coralogix
- exporter/datadog
- exporter/dataset
- exporter/dynatrace
- exporter/elasticsearch
- exporter/f5cloud
Expand Down
10 changes: 5 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ updates:
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/exporter/datasetexporter"
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/exporter/dynatraceexporter"
schedule:
Expand Down Expand Up @@ -1097,8 +1102,3 @@ updates:
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/receiver/zipkinreceiver"
schedule:
interval: "weekly"
day: "wednesday"
2 changes: 2 additions & 0 deletions cmd/otelcontribcol/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ exporters:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/cassandraexporter v0.76.3
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/coralogixexporter v0.76.3
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter v0.76.3
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datasetexporter v0.76.3
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/dynatraceexporter v0.76.3
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter v0.76.3
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/f5cloudexporter v0.76.3
Expand Down Expand Up @@ -321,6 +322,7 @@ replaces:
- github.com/open-telemetry/opentelemetry-collector-contrib/processor/routingprocessor => ../../processor/routingprocessor
- github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatorateprocessor => ../../processor/deltatorateprocessor
- github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter => ../../exporter/datadogexporter
- github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datasetexporter => ../../exporter/datasetexporter
- github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight => ../../internal/aws/containerinsight
- github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil => ../../internal/aws/awsutil
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zookeeperreceiver => ../../receiver/zookeeperreceiver
Expand Down
2 changes: 2 additions & 0 deletions cmd/otelcontribcol/components.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions cmd/otelcontribcol/exporters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/clickhouseexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/coralogixexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datasetexporter"
dtconf "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/dynatraceexporter/config"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/f5cloudexporter"
Expand Down Expand Up @@ -335,6 +336,15 @@ func TestDefaultExporters(t *testing.T) {
return cfg
},
},
{
exporter: "dataset",
getConfigFn: func() component.Config {
cfg := expFactories["dataset"].CreateDefaultConfig().(*datasetexporter.Config)
cfg.DatasetURL = "https://" + endpoint
cfg.APIKey = "secret-key"
return cfg
},
},
{
exporter: "dynatrace",
getConfigFn: func() component.Config {
Expand Down
3 changes: 3 additions & 0 deletions cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/clickhouseexporter v0.76.3
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/coralogixexporter v0.76.3
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter v0.76.3
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datasetexporter v0.76.3
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/dynatraceexporter v0.76.3
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter v0.76.3
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/f5cloudexporter v0.76.3
Expand Down Expand Up @@ -926,6 +927,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/delt

replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter => ../../exporter/datadogexporter

replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datasetexporter => ../../exporter/datasetexporter

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

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil => ../../internal/aws/awsutil
Expand Down
1 change: 1 addition & 0 deletions exporter/datasetexporter/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
62 changes: 62 additions & 0 deletions exporter/datasetexporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# DataSet Exporter

<!-- status autogenerated section -->
| Status | |
| ------------------------ |-----------|
| Stability | [development] |
| Supported pipeline types | logs, traces |
| Distributions | [contrib] |
mx-psi marked this conversation as resolved.
Show resolved Hide resolved

[development]: https://github.com/open-telemetry/opentelemetry-collector#development
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
<!-- end autogenerated section -->

This exporter sends logs to [DataSet](https://www.dataset.com/).

See the [Getting Started](https://app.scalyr.com/help/getting-started) guide.

## Configuration

### Required Settings
evan-bradley marked this conversation as resolved.
Show resolved Hide resolved

- `dataset_url` (no default): The URL of the DataSet API that ingests the data. Most likely https://app.scalyr.com. If not specified env variable `DATASET_URL` is used.
- `api_key` (no default): The "Log Write" API Key required to use API. Instructions how to get [API key](https://app.scalyr.com/help/api-keys). If not specified env variable `DATASET_API_KEY` is used.

### Optional Settings

- `max_delay_ms` (default = "15000"): The maximum delay between sending batches from the same source.
- `group_by` (default = []): The list of attributes based on which events should be grouped.
- `retry_on_failure`: See [retry_on_failure](https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/exporterhelper/README.md)
- `sending_queue`: See [sending_queue](https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/exporterhelper/README.md)
- `timeout`: See [timeout](https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/exporterhelper/README.md)


### Example

```yaml

exporters:
dataset:
# DataSet API URL
dataset_url: https://app.scalyr.com
# API Key
api_key: your_api_key
# Send batch to the API at least every 15s
max_delay_ms: 15000
# Group data based on these attributes
group_by:
- attributes.container_id
- attributes.log.file.path
- body.map.kubernetes.container_hash
- body.map.kubernetes.pod_id
- body.map.kubernetes.docker_id
- body.map.stream

service:
pipelines:
logs:
receivers: [otlp]
processors: [batch]
# add dataset among your exporters
exporters: [dataset]
```
91 changes: 91 additions & 0 deletions exporter/datasetexporter/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package datasetexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datasetexporter"

import (
"fmt"
"os"
"strconv"

"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/exporter/exporterhelper"
)

const MaxDelayMs = "15000"
mx-psi marked this conversation as resolved.
Show resolved Hide resolved

type Config struct {
DatasetURL string `mapstructure:"dataset_url"`
APIKey string `mapstructure:"api_key"`
MaxDelayMs string `mapstructure:"max_delay_ms"`
GroupBy []string `mapstructure:"group_by"`
exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
exporterhelper.TimeoutSettings `mapstructure:"timeout"`
}

func (c *Config) Unmarshal(conf *confmap.Conf) error {
if err := conf.Unmarshal(c, confmap.WithErrorUnused()); err != nil {
return fmt.Errorf("cannot unmarshal config: %w", err)
}

if len(c.DatasetURL) == 0 {
c.DatasetURL = os.Getenv("DATASET_URL")
}
if len(c.APIKey) == 0 {
c.APIKey = os.Getenv("DATASET_API_KEY")
}

if len(c.MaxDelayMs) == 0 {
c.MaxDelayMs = MaxDelayMs
}

return nil
}

// Validate checks if all required fields in Config are set and have valid values.
// If any of the required fields are missing or have invalid values, it returns an error.
func (c *Config) Validate() error {
if c.APIKey == "" {
return fmt.Errorf("api_key is required")
}
if c.DatasetURL == "" {
return fmt.Errorf("dataset_url is required")
}

_, err := strconv.Atoi(c.MaxDelayMs)
if err != nil {
return fmt.Errorf(
"max_delay_ms must be integer, but %s was used: %w",
c.MaxDelayMs,
err,
)
}

return nil
}

// String returns a string representation of the Config object.
// It includes all the fields and their values in the format "field_name: field_value".
func (c *Config) String() string {
s := ""
s += fmt.Sprintf("%s: %s; ", "DatasetURL", c.DatasetURL)
s += fmt.Sprintf("%s: %s; ", "MaxDelayMs", c.MaxDelayMs)
s += fmt.Sprintf("%s: %s; ", "GroupBy", c.GroupBy)
s += fmt.Sprintf("%s: %+v; ", "RetrySettings", c.RetrySettings)
s += fmt.Sprintf("%s: %+v; ", "QueueSettings", c.QueueSettings)
s += fmt.Sprintf("%s: %+v", "TimeoutSettings", c.TimeoutSettings)

return s
}
Loading