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

Prototype: OpenTelemetry components for Flow #1843

Closed
wants to merge 6 commits into from

Conversation

rfratto
Copy link
Member

@rfratto rfratto commented Jul 1, 2022

This (large) draft PR demonstrates how OpenTelemetry components can be added as Flow components.

This is just a draft to demonstrate the capability, and needs a lot of attention before it's mergeable.

The implementation of these components completely bypasses the OpenTelemetry Collector pipeline system, instead relying on the Flow controller to bind OTel components together, passing around consumers as interfaces.

Each component which can receive telemetry data is bundled as a generic TelemetryConsumer, which accepts metrics, logs, and traces. It is a combination of the three consumer interfaces from OpenTelemetry Collector. If the underlying consumer does not support one of the telemetry types, the request will fail. In the future, this should probably be changed to be validated at load time instead of failing at runtime.

The following example components are included:

  • otel.reciever_jaeger: The upstream Jaeger receiver
  • otel.exporter_otlp: The upstream OTLP exporter
  • otel.receiver_otlp: The upstream OTLP receiver
  • otel.receiver_zipkin: The upstream Zipkin receiver.
  • otel.exporter_logging: A custom component which uses go-kit's logger for logging about received traces.

There is generic code for constructing and running the various OpenTelmetry Collector components. The remainder of the code involves recreating config structs for unmarshaling and converting it to the upstream types on-demand. While this is more repetitive than the pkg/traces approach of unmarshaling into a map[string]interface{}, I personally find it preferable since it is more discoverable when examining the code and more likely to fail fast at compile time if upstream changes the type definition unexpectedly.

Example config:

otel "exporter_logging" "default" {
  // Exported fields: 
  // input: <TelemetryConsumer>
}

otel "exporter_otlp" "default" {
  client {
    endpoint = "localhost:4317" // Tempo
  }

  // Exported fields: 
  // input: <TelemetryConsumer>
}

otel "receiver_zipkin" "default" {
  http {}

  output {
    traces = [otel.exporter_logging.default.input, otel.exporter_otlp.default.input]
  }
}

After running, follow Tempo's guide to push Zipkin traces using cURL to see Spans appear in Tempo.

Note that running these components will break the /-/config endpoint, since rfratto/gohcl isn't able to properly serialize a list of capsule values. The fix for that doesn't seem straightforward, and a long-term fix may need to wait for #1839.

@rfratto
Copy link
Member Author

rfratto commented Jul 20, 2022

Closing as this was just a prototype to demonstrate the capability of having OpenTelemetry components. A new PR with the intent of being merged can be opened in the future if we decide to add this functionality into Flow.

@rfratto rfratto closed this Jul 20, 2022
rfratto added a commit to rfratto/agent that referenced this pull request Sep 27, 2022
This commit introduces the component/otelcol package, which will
eventually hold a collection of `otelcol.*` components.

Initial prototyping work for Flow OpenTelemetry Collector components was
done in grafana#1843, which demonstrated that the full set of code needed to
implement OpenTelemetry Components is quite large. I will be splitting
up the needed code across a few changes; this is the first.

This initial commit starts setting up the framework for running
OpenTelemetry Collector components inside of Flow with a
`componentScheduler` struct.

Related to grafana#2213.
rfratto added a commit that referenced this pull request Sep 27, 2022
…onents (#2224)

* component/otelcol: initial commit

This commit introduces the component/otelcol package, which will
eventually hold a collection of `otelcol.*` components.

Initial prototyping work for Flow OpenTelemetry Collector components was
done in #1843, which demonstrated that the full set of code needed to
implement OpenTelemetry Components is quite large. I will be splitting
up the needed code across a few changes; this is the first.

This initial commit starts setting up the framework for running
OpenTelemetry Collector components inside of Flow with a
`componentScheduler` struct.

Related to #2213.

* move scheduler to an internal/scheduler package.

The otelcol component scheduler code will need to be exposed to multiple
packages, but it doesn't make sense to make it part of the public API.

* fix linting errors
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Mar 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant