Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

feat: Create base config for observability PoC #80

Closed
wants to merge 3 commits into from

Conversation

foo0x29a
Copy link
Contributor

@foo0x29a foo0x29a commented Nov 30, 2022

TL;DR: Add base config for TCE Observability, including:

  • Traces
  • Metrics
  • Logs

Before

Observability is a broad topic that essentially covers at least 3 areas:

  • Traces
  • Metrics
  • Logs

The design of our current Observability stack is as follows:

TCE __ Observability

After

There are evidences that OpenTelemetry has been gaining some traction in the Observability space. We have recently started the discussion of possibly adopting the OpenTelemetry collection of tools as follows:
TCE __ Observability - OpenTelemetry (2) (1)

In this new design, we add one more layer - OpenTelemetry Collector, to allow standardized and vendor-agnostic telemetry data.

ATTENTION: THIS IS EXPERIMENTAL. WE ARE OPEN FOR CHANGES.

OpenTelemetry

Configuration

The otel-collector-config.yaml file was inspired by this official demo. The complete reference can be found here.

As receivers we define:

  • OTLP

And as exporters:

Instrumentation

The instrumentation is done using the opentelemetry-otlp crate.

How to run

From the root directory of TCE, run:

# Start 
$ docker compose  -f tools/docker-compose.yml up

Jaeger UI will be available at http://localhost:16686/ :

Screenshot 2022-11-30 at 5 42 42 PM

And Prometheus at http://localhost:9090/:
Screenshot 2022-11-30 at 5 43 14 PM

After work is finished:

# Stop 
$ docker compose  -f tools/docker-compose.yml down

Caveats:

  • This requires Docker to be installed
  • Assumes that the environment variable $GITHUB_TOKEN is defined and contains a GitHub personal token with appropriate access to build the project

@codecov
Copy link

codecov bot commented Nov 30, 2022

Codecov Report

Base: 43.18% // Head: 43.56% // Increases project coverage by +0.38% 🎉

Coverage data is based on head (8896762) compared to base (55524d4).
Patch has no changes to coverable lines.

❗ Current head 8896762 differs from pull request most recent head 451c094. Consider uploading reports for the commit 451c094 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #80      +/-   ##
==========================================
+ Coverage   43.18%   43.56%   +0.38%     
==========================================
  Files          45       44       -1     
  Lines        1936     1919      -17     
==========================================
  Hits          836      836              
+ Misses       1100     1083      -17     
Impacted Files Coverage Δ
crates/topos-tce-telemetry/src/lib.rs

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@foo0x29a foo0x29a marked this pull request as ready for review November 30, 2022 21:03
@foo0x29a foo0x29a requested a review from a team as a code owner November 30, 2022 21:03
@foo0x29a foo0x29a requested review from Freyskeyd, atanmarko and sebastiendan and removed request for a team and atanmarko November 30, 2022 21:03
.with_exporter(
opentelemetry_otlp::new_exporter()
.tonic()
.with_endpoint("http://otel-collector:4317"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would need to keep using a cli arg or an env variable (similarly to jaeger_agent).

@@ -47,6 +54,25 @@ async fn main() {
.install_batch(opentelemetry::runtime::Tokio)
.unwrap();

let export_config = ExportConfig {
endpoint: "http://otel-collector:4317".to_string(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would need to keep using a cli arg or an env variable (similarly to jaeger_agent).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes definitely. Specially for the cases where users would like to opt-out and do not send any telemetry data.

I don't have confidence in Rust, so kept the code minimal.

let tracer = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(
opentelemetry_otlp::new_exporter()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're using the same exporter builder, maybe we can mutualise the code here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Freyskeyd, thanks for reviewing this PR!

Do you mind taking over the instrumentation bit? It would be great if you pushed some changes to this branch fixing the already existing minimal setup!

I'm probably not the most appropriate person to touch the code base. I made some changes on the main.rs and Cargo.toml files, but am not entirely sure if that's the optimal solution.

volumes:
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
ports:
- "1888:1888" # pprof extension
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most ports don't need host bindings, no? Actually this is a thought I've had for a while: With docker-compose, having links created automatically between all containers on a common network, we don't event need to specify any port (neither host nor container), no?

Copy link
Contributor Author

@foo0x29a foo0x29a Dec 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastiendan ,

Most ports don't need host bindings, no?

Yes you're correct. Will leave only the necessary for the PoC, thanks for spotting this!

With docker-compose, having links created automatically between all containers on a common network, we don't event need to specify any port (neither host nor container), no?

That's correct. The difference, however, is if we define the ports field but omit the ${HOST} value, docker compose will assign a random host port:

$ docker compose ps
NAME                     COMMAND                  SERVICE             STATUS              PORTS
boot                     "/bin/sh -c ./topos-…"   boot                running             0.0.0.0:57131->9090/tcp
jaeger                   "/go/bin/all-in-one-…"   jaeger              running             5775/udp, 5778/tcp, 0.0.0.0:14250->14250/tcp, 6831-6832/udp, 14268/tcp, 0.0.0.0:16685-16686->16685-16686/tcp
prometheus               "/bin/prometheus --c…"   prometheus          running             0.0.0.0:9090->9090/tcp
spam                     "./cert-spammer"         cert-spammer        running             
tools-otel-collector-1   "/otelcontribcol --c…"   otel-collector      running             0.0.0.0:1888->1888/tcp, 0.0.0.0:4317->4317/tcp, 0.0.0.0:8888-8889->8888-8889/tcp, 0.0.0.0:13133->13133/tcp, 0.0.0.0:55679->55679/tcp, 55680/tcp
tools-peer-1             "/bin/sh -c ./topos-…"   peer                running             0.0.0.0:57140->1340/tcp, 0.0.0.0:57141->9090/tcp
tools-peer-2             "/bin/sh -c ./topos-…"   peer                running             0.0.0.0:57132->1340/tcp, 0.0.0.0:57133->9090/tcp
tools-peer-3             "/bin/sh -c ./topos-…"   peer                running             0.0.0.0:57136->1340/tcp, 0.0.0.0:57137->9090/tcp
tools-peer-4             "/bin/sh -c ./topos-…"   peer                running             0.0.0.0:57138->1340/tcp, 0.0.0.0:57139->9090/tcp
tools-peer-5             "/bin/sh -c ./topos-…"   peer                running             0.0.0.0:57134->1340/tcp, 0.0.0.0:57135->9090/tcp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference, however, is if we define the ports field but omit the ${HOST} value, docker compose will assign a random host port

Yep, but what I meant is that I think we tend to use random port assignation "by default" because we think that ports should be specified. Let me describe an example:

version: '3.5'

services:
  one:
    image: ...
    ports:
      - 3000
  two:
    image: ...
    env:
      - "endpoint=http://one:3000"

Here often we would want to specify the 3000 port on one because we want two to access it, but I believe this isn't needed. (this was my comment above)

@foo0x29a foo0x29a marked this pull request as draft December 22, 2022 15:09
@foo0x29a foo0x29a self-assigned this Dec 22, 2022
@foo0x29a foo0x29a closed this Jan 18, 2023
@foo0x29a
Copy link
Contributor Author

Closing as #109 was merged.

@foo0x29a foo0x29a deleted the feat/observability-poc branch January 18, 2023 19:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants