Skip to content

Commit

Permalink
Add otelcol
Browse files Browse the repository at this point in the history
  • Loading branch information
thampiotr committed Nov 28, 2023
1 parent 3c27101 commit 511ca26
Show file tree
Hide file tree
Showing 30 changed files with 380 additions and 4 deletions.
31 changes: 27 additions & 4 deletions component/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package metadata

import (
"fmt"
"github.com/grafana/agent/component/otelcol"
"github.com/grafana/agent/component/pyroscope"
"github.com/prometheus/prometheus/storage"
"reflect"
Expand Down Expand Up @@ -67,16 +68,23 @@ var (
},
}

//TODO(thampiotr): add more types
//DataTypeOTELTelemetry = Type("OTEL Telemetry")
//DataTypePromMetrics = Type("Prometheus Metrics")
//DataTypePyroscopeProfiles = Type("Pyroscope Profiles")
TypeOTELReceiver = Type{
Name: "OpenTelemetry `otelcol.Consumer`",
ExistsInArgsFn: func(args component.Arguments) bool {
return hasFieldOfType(args, reflect.TypeOf([]otelcol.Consumer{}))
},
ExistsInExportsFn: func(exports component.Exports) bool {
var a *otelcol.Consumer = nil
return hasFieldOfType(exports, reflect.TypeOf(a).Elem())
},
}

AllTypes = []Type{
TypeTargets,
TypeLokiLogs,
TypePromMetricsReceiver,
TypePyroProfilesReceiver,
TypeOTELReceiver,
}
)

Expand Down Expand Up @@ -115,7 +123,10 @@ func (m Metadata) ExportsType(t Type) bool {
return false
}

var currentComponent = ""

func ForComponent(name string) (Metadata, error) {
currentComponent = name
reg, ok := component.Get(name)
if !ok {
return Metadata{}, fmt.Errorf("could not find component %q", name)
Expand All @@ -139,6 +150,10 @@ func inferMetadata(args component.Arguments, exports component.Exports) Metadata
func hasFieldOfType(obj interface{}, fieldType reflect.Type) bool {
objValue := reflect.ValueOf(obj)

if fieldType.String() == "[]otelcol.Consumer" && currentComponent == "otelcol.receiver.loki" {
fmt.Println("gotcha")
}

// If the object is a pointer, dereference it
for objValue.Kind() == reflect.Ptr {
objValue = objValue.Elem()
Expand Down Expand Up @@ -168,6 +183,14 @@ func hasFieldOfType(obj interface{}, fieldType reflect.Type) bool {
return true
}
}

// If the field is a pointer, create a new instance of the pointer type and recursively check its fields
if fv.Kind() == reflect.Ptr {
if hasFieldOfType(reflect.New(ft.Elem()).Interface(), fieldType) {
return true
}
}

}

return false
Expand Down
79 changes: 79 additions & 0 deletions docs/sources/flow/reference/compatibility/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,85 @@ on the namespace to expand and see more detail.
<!-- END GENERATED SECTION: CONSUMERS OF Loki `LogsReceiver` -->


## OpenTelemetry `otelcol.Consumer`

The OpenTelemetry data is sent between components using `otelcol.Consumer`s.
`otelcol.Consumer`s are [capsules]({{< relref "../../config-language/expressions/types_and_values/#capsules" >}})
that are exported by components that can receive OpenTelemetry data. Components that
can consume OpenTelemetry data can be passed the `otelcol.Consumer` as an argument. Note that some components
that use `otelcol.Consumer` only support a subset of telemetry signals, e.g. only traces. Check the component
reference pages for more details on what is supported. Use the following components to build your OpenTelemetry pipeline:

<!-- NOTE: this title is used as an anchor in links. Do not change. -->
### OpenTelemetry `otelcol.Consumer` Exporters
Below are components that _export_ OpenTelemetry `otelcol.Consumer`, grouped by namespace. Click
on the namespace to expand and see more detail.

<!-- START GENERATED SECTION: EXPORTERS OF OpenTelemetry `otelcol.Consumer` -->

{{< collapse title="otelcol" >}}
- [otelcol.connector.servicegraph]({{< relref "../components/otelcol.connector.servicegraph.md" >}})
- [otelcol.connector.spanlogs]({{< relref "../components/otelcol.connector.spanlogs.md" >}})
- [otelcol.connector.spanmetrics]({{< relref "../components/otelcol.connector.spanmetrics.md" >}})
- [otelcol.exporter.loadbalancing]({{< relref "../components/otelcol.exporter.loadbalancing.md" >}})
- [otelcol.exporter.logging]({{< relref "../components/otelcol.exporter.logging.md" >}})
- [otelcol.exporter.loki]({{< relref "../components/otelcol.exporter.loki.md" >}})
- [otelcol.exporter.otlp]({{< relref "../components/otelcol.exporter.otlp.md" >}})
- [otelcol.exporter.otlphttp]({{< relref "../components/otelcol.exporter.otlphttp.md" >}})
- [otelcol.exporter.prometheus]({{< relref "../components/otelcol.exporter.prometheus.md" >}})
- [otelcol.processor.attributes]({{< relref "../components/otelcol.processor.attributes.md" >}})
- [otelcol.processor.batch]({{< relref "../components/otelcol.processor.batch.md" >}})
- [otelcol.processor.discovery]({{< relref "../components/otelcol.processor.discovery.md" >}})
- [otelcol.processor.filter]({{< relref "../components/otelcol.processor.filter.md" >}})
- [otelcol.processor.k8sattributes]({{< relref "../components/otelcol.processor.k8sattributes.md" >}})
- [otelcol.processor.memory_limiter]({{< relref "../components/otelcol.processor.memory_limiter.md" >}})
- [otelcol.processor.probabilistic_sampler]({{< relref "../components/otelcol.processor.probabilistic_sampler.md" >}})
- [otelcol.processor.span]({{< relref "../components/otelcol.processor.span.md" >}})
- [otelcol.processor.tail_sampling]({{< relref "../components/otelcol.processor.tail_sampling.md" >}})
- [otelcol.processor.transform]({{< relref "../components/otelcol.processor.transform.md" >}})
{{< /collapse >}}

<!-- END GENERATED SECTION: EXPORTERS OF OpenTelemetry `otelcol.Consumer` -->

<!-- NOTE: this title is used as an anchor in links. Do not change. -->
### OpenTelemetry `otelcol.Consumer` Consumers
Below are components that _consume_ OpenTelemetry `otelcol.Consumer`, grouped by namespace. Click
on the namespace to expand and see more detail.

<!-- START GENERATED SECTION: CONSUMERS OF OpenTelemetry `otelcol.Consumer` -->

{{< collapse title="faro" >}}
- [faro.receiver]({{< relref "../components/faro.receiver.md" >}})
{{< /collapse >}}

{{< collapse title="otelcol" >}}
- [otelcol.connector.servicegraph]({{< relref "../components/otelcol.connector.servicegraph.md" >}})
- [otelcol.connector.spanlogs]({{< relref "../components/otelcol.connector.spanlogs.md" >}})
- [otelcol.connector.spanmetrics]({{< relref "../components/otelcol.connector.spanmetrics.md" >}})
- [otelcol.processor.attributes]({{< relref "../components/otelcol.processor.attributes.md" >}})
- [otelcol.processor.batch]({{< relref "../components/otelcol.processor.batch.md" >}})
- [otelcol.processor.discovery]({{< relref "../components/otelcol.processor.discovery.md" >}})
- [otelcol.processor.filter]({{< relref "../components/otelcol.processor.filter.md" >}})
- [otelcol.processor.k8sattributes]({{< relref "../components/otelcol.processor.k8sattributes.md" >}})
- [otelcol.processor.memory_limiter]({{< relref "../components/otelcol.processor.memory_limiter.md" >}})
- [otelcol.processor.probabilistic_sampler]({{< relref "../components/otelcol.processor.probabilistic_sampler.md" >}})
- [otelcol.processor.span]({{< relref "../components/otelcol.processor.span.md" >}})
- [otelcol.processor.tail_sampling]({{< relref "../components/otelcol.processor.tail_sampling.md" >}})
- [otelcol.processor.transform]({{< relref "../components/otelcol.processor.transform.md" >}})
- [otelcol.receiver.jaeger]({{< relref "../components/otelcol.receiver.jaeger.md" >}})
- [otelcol.receiver.kafka]({{< relref "../components/otelcol.receiver.kafka.md" >}})
- [otelcol.receiver.loki]({{< relref "../components/otelcol.receiver.loki.md" >}})
- [otelcol.receiver.opencensus]({{< relref "../components/otelcol.receiver.opencensus.md" >}})
- [otelcol.receiver.otlp]({{< relref "../components/otelcol.receiver.otlp.md" >}})
- [otelcol.receiver.prometheus]({{< relref "../components/otelcol.receiver.prometheus.md" >}})
- [otelcol.receiver.vcenter]({{< relref "../components/otelcol.receiver.vcenter.md" >}})
- [otelcol.receiver.zipkin]({{< relref "../components/otelcol.receiver.zipkin.md" >}})
{{< /collapse >}}

<!-- END GENERATED SECTION: CONSUMERS OF OpenTelemetry `otelcol.Consumer` -->



## Pyroscope `ProfilesReceiver`

The Pyroscope profiles are sent between components using `ProfilesReceiver`s.
Expand Down
1 change: 1 addition & 0 deletions docs/sources/flow/reference/components/faro.receiver.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ Replace the following:
`faro.receiver` can accept arguments from the following components:

- Components that export [Loki `LogsReceiver`]({{< relref "../compatibility/#loki-logsreceiver-exporters" >}})
- Components that export [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-exporters" >}})


Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,17 @@ traces_service_graph_request_total{client="shop-backend",failed="false",server="
traces_service_graph_request_failed_total{client="shop-backend",client_http_method="POST",failed="false",server="auth-service",server_http_method="POST"}
```<!-- START GENERATED COMPATIBLE COMPONENTS -->
## Compatible components
`otelcol.connector.servicegraph` can accept arguments from the following components:
- Components that export [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-exporters" >}})
`otelcol.connector.servicegraph` has exports that can be consumed by the following components:
- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})
Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.
<!-- END GENERATED COMPATIBLE COMPONENTS -->
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,17 @@ For an input trace like this...
```
<!-- START GENERATED COMPATIBLE COMPONENTS -->

## Compatible components

`otelcol.connector.spanlogs` can accept arguments from the following components:

- Components that export [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-exporters" >}})

`otelcol.connector.spanlogs` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})

Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.


<!-- END GENERATED COMPATIBLE COMPONENTS -->
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,17 @@ prometheus.remote_write "mimir" {
```
<!-- START GENERATED COMPATIBLE COMPONENTS -->

## Compatible components

`otelcol.connector.spanmetrics` can accept arguments from the following components:

- Components that export [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-exporters" >}})

`otelcol.connector.spanmetrics` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})

Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.


<!-- END GENERATED COMPATIBLE COMPONENTS -->
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,13 @@ otelcol.exporter.loadbalancing "default" {
```
<!-- START GENERATED COMPATIBLE COMPONENTS -->

## Compatible components

`otelcol.exporter.loadbalancing` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})

Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.


<!-- END GENERATED COMPATIBLE COMPONENTS -->
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,13 @@ otelcol.exporter.logging "default" {
```
<!-- START GENERATED COMPATIBLE COMPONENTS -->

## Compatible components

`otelcol.exporter.logging` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})

Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.


<!-- END GENERATED COMPATIBLE COMPONENTS -->
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ loki.write "local" {

- Components that export [Loki `LogsReceiver`]({{< relref "../compatibility/#loki-logsreceiver-exporters" >}})

`otelcol.exporter.loki` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})

Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,13 @@ otelcol.auth.basic "grafana_cloud_tempo" {
```
<!-- START GENERATED COMPATIBLE COMPONENTS -->

## Compatible components

`otelcol.exporter.otlp` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})

Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.


<!-- END GENERATED COMPATIBLE COMPONENTS -->
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,13 @@ otelcol.exporter.otlphttp "tempo" {
```
<!-- START GENERATED COMPATIBLE COMPONENTS -->

## Compatible components

`otelcol.exporter.otlphttp` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})

Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.


<!-- END GENERATED COMPATIBLE COMPONENTS -->
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ prometheus.remote_write "mimir" {

- Components that export [Prometheus `MetricsReceiver`]({{< relref "../compatibility/#prometheus-metricsreceiver-exporters" >}})

`otelcol.exporter.prometheus` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})

Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,4 +636,17 @@ otelcol.processor.attributes "default" {
```
<!-- START GENERATED COMPATIBLE COMPONENTS -->

## Compatible components

`otelcol.processor.attributes` can accept arguments from the following components:

- Components that export [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-exporters" >}})

`otelcol.processor.attributes` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})

Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.


<!-- END GENERATED COMPATIBLE COMPONENTS -->
13 changes: 13 additions & 0 deletions docs/sources/flow/reference/components/otelcol.processor.batch.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,17 @@ otelcol.exporter.otlp "production" {
[otelcol.exporter.otlp]: {{< relref "./otelcol.exporter.otlp.md" >}}
<!-- START GENERATED COMPATIBLE COMPONENTS -->

## Compatible components

`otelcol.processor.batch` can accept arguments from the following components:

- Components that export [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-exporters" >}})

`otelcol.processor.batch` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})

Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.


<!-- END GENERATED COMPATIBLE COMPONENTS -->
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ otelcol.processor.discovery "default" {
`otelcol.processor.discovery` can accept arguments from the following components:

- Components that export [Targets]({{< relref "../compatibility/#targets-exporters" >}})
- Components that export [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-exporters" >}})

`otelcol.processor.discovery` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})

Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.

Expand Down
13 changes: 13 additions & 0 deletions docs/sources/flow/reference/components/otelcol.processor.filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,17 @@ Some values in the River strings are [escaped][river-strings]:
[OTTL math expressions]: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/v0.85.0/pkg/ottl#math-expressions
<!-- START GENERATED COMPATIBLE COMPONENTS -->

## Compatible components

`otelcol.processor.filter` can accept arguments from the following components:

- Components that export [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-exporters" >}})

`otelcol.processor.filter` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})

Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.


<!-- END GENERATED COMPATIBLE COMPONENTS -->
Original file line number Diff line number Diff line change
Expand Up @@ -412,4 +412,17 @@ prometheus.remote_write "mimir" {
```
<!-- START GENERATED COMPATIBLE COMPONENTS -->

## Compatible components

`otelcol.processor.k8sattributes` can accept arguments from the following components:

- Components that export [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-exporters" >}})

`otelcol.processor.k8sattributes` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-consumers" >}})

Note that connecting some components may not be feasible or components may require further configuration to make the connection work correctly. Please refer to the linked documentation for more details.


<!-- END GENERATED COMPATIBLE COMPONENTS -->
Loading

0 comments on commit 511ca26

Please sign in to comment.