-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[connector/count] Add outline and documentation #18037
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8811b83
[connector/count] Add outline and documentation
djaglowski c1c2eac
Add module to .github, versions.yaml
djaglowski cb08bc6
Use local Config in factory
djaglowski f207230
Split readme into generic and specific.
djaglowski 22befc5
fix multimod
djaglowski d36b751
Remove connectors readme, reference core
djaglowski 7af133f
Update connector/countconnector/README.md
djaglowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../../Makefile.Common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
# Count Connector | ||
|
||
| Status | | | ||
|------------------------- |---------------------------------------------------------- | | ||
| Stability | [in development] | | ||
| Supported pipeline types | See [Supported Pipeline Types](#supported-pipeline-types) | | ||
djaglowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Distributions | [] | | ||
|
||
The `countconnector` can be used to count spans, data points, or log records. | ||
djaglowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Supported Pipeline Types | ||
|
||
Connectors are used as _both_ an exporter and as a receiver, in separate pipelines. | ||
The pipeline in which a connector is used as an exporter is referred to below | ||
as the "Exporter pipeline". Likewise, the pipeline in which the connector is | ||
used as a receiver is referred to below as the "Receiver pipeline". | ||
|
||
| Exporter pipeline | Receiver pipeline | Description | Default Metric Name | | ||
| ----------------- | ----------------- | ---------------------------------- | ------------------------- | | ||
| traces | metrics | Counts the number of spans. | `trace.span.count` | | ||
| metrics | metrics | Counts the number of log records. | `metric.data_point.count` | | ||
| logs | metrics | Counts the number of data points. | `log.record.count` | | ||
|
||
## Configuration | ||
|
||
Connectors are defined within a dedicated `connectors` section at the top level of the collector config. | ||
|
||
The count connector may be used with default settings. | ||
|
||
```yaml | ||
receivers: | ||
foo: | ||
exporters: | ||
bar: | ||
connectors: | ||
count: | ||
``` | ||
|
||
Optionally, the names of the metrics emitted by the connector may be customized. | ||
|
||
```yaml | ||
receivers: | ||
foo: | ||
exporters: | ||
bar: | ||
connectors: | ||
count: | ||
traces: | ||
metric_name: my.span.count | ||
metrics: | ||
metric_name: my.data_point.count | ||
logs: | ||
metric_name: my.log_record.count | ||
``` | ||
|
||
### Use the connector in pipelines | ||
|
||
A connector _is_ an exporter _and_ a receiver. It must be used as both, in separate pipelines. | ||
|
||
```yaml | ||
receivers: | ||
foo: | ||
exporters: | ||
bar: | ||
connectors: | ||
count: | ||
service: | ||
pipelines: | ||
traces: | ||
receivers: [foo] | ||
exporters: [count] | ||
metrics: | ||
receivers: [count] | ||
exporters: [bar] | ||
``` | ||
|
||
Connectors can be used alongside other exporters. | ||
|
||
```yaml | ||
receivers: | ||
foo: | ||
exporters: | ||
bar/traces_backend: | ||
bar/metrics_backend: | ||
connectors: | ||
count: | ||
service: | ||
pipelines: | ||
traces: | ||
receivers: [foo] | ||
exporters: [bar/traces_backend, count] | ||
metrics: | ||
receivers: [count] | ||
exporters: [bar/metrics_backend] | ||
``` | ||
|
||
Connectors can be used alongside other receivers. | ||
|
||
```yaml | ||
receivers: | ||
foo/traces: | ||
foo/metrics: | ||
exporters: | ||
bar: | ||
connectors: | ||
count: | ||
service: | ||
pipelines: | ||
traces: | ||
receivers: [foo/traces] | ||
exporters: [count] | ||
metrics: | ||
receivers: [foo/metrics, count] | ||
exporters: [bar] | ||
``` | ||
|
||
A connector can be an exporter from multiple pipelines. | ||
|
||
```yaml | ||
receivers: | ||
foo/traces: | ||
foo/metrics: | ||
foo/logs: | ||
exporters: | ||
bar/traces_backend: | ||
bar/metrics_backend: | ||
bar/logs_backend: | ||
connectors: | ||
count: | ||
service: | ||
pipelines: | ||
traces: | ||
receivers: [foo/traces] | ||
exporters: [bar/traces_backend, count] | ||
metrics: | ||
receivers: [foo/metrics] | ||
exporters: [bar/metrics_backend, count] | ||
logs: | ||
receivers: [foo/logs] | ||
exporters: [bar/logs_backend, count] | ||
metrics/counts: | ||
receivers: [count] | ||
exporters: [bar/metrics_backend] | ||
``` | ||
|
||
A connector can be a receiver in multiple pipelines. | ||
|
||
```yaml | ||
receivers: | ||
foo/traces: | ||
foo/metrics: | ||
exporters: | ||
bar/traces_backend: | ||
bar/metrics_backend: | ||
bar/metrics_backend/2: | ||
connectors: | ||
count: | ||
service: | ||
pipelines: | ||
traces: | ||
receivers: [foo/traces] | ||
exporters: [bar/traces_backend, count] | ||
metrics: | ||
receivers: [count] | ||
exporters: [bar/metrics_backend] | ||
metrics/2: | ||
receivers: [count] | ||
exporters: [bar/metrics_backend/2] | ||
``` | ||
|
||
Multiple connectors can be used in sequence. | ||
|
||
```yaml | ||
receivers: | ||
foo: | ||
exporters: | ||
bar: | ||
connectors: | ||
count: | ||
count/the_counts: | ||
service: | ||
pipelines: | ||
traces: | ||
receivers: [foo] | ||
exporters: [count] | ||
metrics: | ||
receivers: [count] | ||
exporters: [bar/metrics_backend, count/the_counts] | ||
metrics/count_the_counts: | ||
receivers: [count/the_counts] | ||
exporters: [bar] | ||
``` | ||
|
||
A connector can only be used in a pair of pipelines when it supports the combination of _exporter type_ and _receiver type_. | ||
|
||
```yaml | ||
receivers: | ||
foo: | ||
exporters: | ||
bar: | ||
connectors: | ||
count: | ||
service: | ||
pipelines: | ||
traces: | ||
receivers: [foo] | ||
exporters: [count] | ||
logs: | ||
receivers: [count] # Invalid. The count connector can only be used as a receiver in metrics pipelines. | ||
exporters: [bar] | ||
``` | ||
|
||
[in development]:https://github.com/open-telemetry/opentelemetry-collector#in-development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 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 countconnector // import "github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector" | ||
|
||
type Config struct { | ||
// TODO | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 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 countconnector // import "github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// 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 countconnector // import "github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector" | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/connector" | ||
"go.opentelemetry.io/collector/consumer" | ||
) | ||
|
||
const ( | ||
typeStr = "count" | ||
stability = component.StabilityLevelDevelopment | ||
scopeName = "otelcol/countconnector" | ||
) | ||
|
||
// NewFactory returns a ConnectorFactory. | ||
func NewFactory() connector.Factory { | ||
return connector.NewFactory( | ||
typeStr, | ||
createDefaultConfig, | ||
connector.WithTracesToMetrics(createTracesToMetrics, component.StabilityLevelDevelopment), | ||
connector.WithMetricsToMetrics(createMetricsToMetrics, component.StabilityLevelDevelopment), | ||
connector.WithLogsToMetrics(createLogsToMetrics, component.StabilityLevelDevelopment), | ||
) | ||
} | ||
|
||
// createDefaultConfig creates the default configuration. | ||
func createDefaultConfig() component.Config { | ||
return &Config{} | ||
} | ||
|
||
// createTracesToMetrics creates a traces to metrics connector based on provided config. | ||
func createTracesToMetrics( | ||
_ context.Context, | ||
set connector.CreateSettings, | ||
cfg component.Config, | ||
nextConsumer consumer.Metrics, | ||
) (connector.Traces, error) { | ||
return nil, nil | ||
} | ||
|
||
// createMetricsToMetrics creates a metrics connector based on provided config. | ||
func createMetricsToMetrics( | ||
_ context.Context, | ||
set connector.CreateSettings, | ||
cfg component.Config, | ||
nextConsumer consumer.Metrics, | ||
) (connector.Metrics, error) { | ||
return nil, nil | ||
} | ||
|
||
// createLogsToMetrics creates a logs to metrics connector based on provided config. | ||
func createLogsToMetrics( | ||
_ context.Context, | ||
set connector.CreateSettings, | ||
cfg component.Config, | ||
nextConsumer consumer.Metrics, | ||
) (connector.Logs, error) { | ||
return nil, nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how this readme is written, mostly demonstrating how connectors work. At the same time, I wonder if this wouldn't be confusing to users of this connector specifically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'm reworking this into a general connectors readme and a dedicated count connector readme.