Skip to content

Commit

Permalink
[extension/ackextension] Create Ack extension interface (open-telemet…
Browse files Browse the repository at this point in the history
…ry#31225)

**Description:**
Adding interface and other related files to serve as placeholder for the
Ack extension proposed in
open-telemetry#26376.
Implementation will be added after this PR gets merged.

**Link to tracking Issue:**

open-telemetry#26376
  • Loading branch information
zpzhuSplunk authored Feb 22, 2024
1 parent 7c5999f commit 449b6a4
Show file tree
Hide file tree
Showing 20 changed files with 370 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .chloggen/ack_extension_interface.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# 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: 'ackextension'

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Adding an interface for Acknowledgement extension"

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [26376]

# (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:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ exporter/syslogexporter/ @open-telemetry/collect
exporter/tencentcloudlogserviceexporter/ @open-telemetry/collector-contrib-approvers @wgliang @yiyang5055
exporter/zipkinexporter/ @open-telemetry/collector-contrib-approvers @MovieStoreGuy @astencel-sumo @crobert-1

extension/ackextension/ @open-telemetry/collector-contrib-approvers @zpzhuSplunk @splunkericl @atoulme
extension/asapauthextension/ @open-telemetry/collector-contrib-approvers @jamesmoessis @MovieStoreGuy
extension/awsproxy/ @open-telemetry/collector-contrib-approvers @Aneurysm9 @mxiamxia
extension/basicauthextension/ @open-telemetry/collector-contrib-approvers @jpkrohling @frzifus
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 @@ -82,6 +82,7 @@ body:
- exporter/syslog
- exporter/tencentcloudlogservice
- exporter/zipkin
- extension/ack
- extension/asapauth
- extension/awsproxy
- extension/basicauth
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 @@ -76,6 +76,7 @@ body:
- exporter/syslog
- exporter/tencentcloudlogservice
- exporter/zipkin
- extension/ack
- extension/asapauth
- extension/awsproxy
- extension/basicauth
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 @@ -76,6 +76,7 @@ body:
- exporter/syslog
- exporter/tencentcloudlogservice
- exporter/zipkin
- extension/ack
- extension/asapauth
- extension/awsproxy
- extension/basicauth
Expand Down
1 change: 1 addition & 0 deletions extension/ackextension/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
34 changes: 34 additions & 0 deletions extension/ackextension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Ack Extension
<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [development] |
| Distributions | [contrib], [splunk] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aextension%2Fack%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aextension%2Fack) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aextension%2Fack%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aextension%2Fack) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@zpzhuSplunk](https://www.github.com/zpzhuSplunk), [@splunkericl](https://www.github.com/splunkericl) |

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

This extension allows acking of data upon successful processing. The upstream agent can choose to send event again
if ack fails.
## Configuration

```yaml
extensions:
ack:
storage:

receivers:
splunk_hec:
ack_extension: ack


service:
extensions: [ack]
pipelines:
logs:
receivers: [splunk_hec]
```
18 changes: 18 additions & 0 deletions extension/ackextension/ackextension.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package ackextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/ackextension"

// AckExtension is an extension that can be used by other otel components to support acking of data and can be queried against
// to check the status of given ack ids.
type AckExtension interface {
// ProcessEvent marks the beginning of processing an event. It generates an ack ID for the associated partition ID.
// ACK IDs are only unique within a partition. Two partitions can have the same ACK IDs but they are generated for different events.
ProcessEvent(partitionID string) (ackID uint64)

// Ack acknowledges an event has been processed.
Ack(partitionID string, ackID uint64)

// QueryAcks checks the statuses of given ackIDs for a partition.
QueryAcks(partitionID string, ackIDs []uint64) map[uint64]bool
}
13 changes: 13 additions & 0 deletions extension/ackextension/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package ackextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/ackextension"
import (
"go.opentelemetry.io/collector/component"
)

// Config defines configuration for ack extension
type Config struct {
// StorageID defines the storage type of the extension. In-memory type is set by default (if not provided). Future consideration is disk type.
StorageID *component.ID `mapstructure:"storage"`
}
6 changes: 6 additions & 0 deletions extension/ackextension/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 ackextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/ackextension"
35 changes: 35 additions & 0 deletions extension/ackextension/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package ackextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/ackextension"

import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/ackextension/internal/metadata"
)

var defaultStorageType = (*component.ID)(nil)

// NewFactory creates a factory for ack extension.
func NewFactory() extension.Factory {
return extension.NewFactory(
metadata.Type,
createDefaultConfig,
createExtension,
metadata.ExtensionStability,
)
}

func createDefaultConfig() component.Config {
return &Config{
StorageID: defaultStorageType,
}
}

func createExtension(_ context.Context, _ extension.CreateSettings, _ component.Config) (extension.Extension, error) {
return nil, nil
}
20 changes: 20 additions & 0 deletions extension/ackextension/factory_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package ackextension

import (
"testing"

"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
)

func TestFactory(t *testing.T) {
f := NewFactory()
expectType := component.MustNewType("ack")
require.Equal(t, expectType, f.Type())

cfg := f.CreateDefaultConfig().(*Config)
require.Equal(t, defaultStorageType, cfg.StorageID)
}
38 changes: 38 additions & 0 deletions extension/ackextension/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module github.com/open-telemetry/opentelemetry-collector-contrib/extension/ackextension

go 1.21

require (
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector/component v0.95.0
go.opentelemetry.io/collector/extension v0.95.0
go.opentelemetry.io/otel/metric v1.23.1
go.opentelemetry.io/otel/trace v1.23.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
github.com/knadh/koanf/v2 v2.1.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.95.0 // indirect
go.opentelemetry.io/collector/confmap v0.95.0 // indirect
go.opentelemetry.io/collector/pdata v1.2.0 // indirect
go.opentelemetry.io/otel v1.23.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/grpc v1.61.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 449b6a4

Please sign in to comment.