Skip to content

Implement OpenTelemetry tracing #194

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

Merged
merged 2 commits into from
Oct 7, 2022
Merged

Implement OpenTelemetry tracing #194

merged 2 commits into from
Oct 7, 2022

Conversation

ryanmelt
Copy link
Member

@ryanmelt ryanmelt commented Oct 5, 2022

closes #171

To test add to compose.yaml:

openc3-jaeger:
  image: "${OPENC3_REGISTRY}/jaegertracing/all-in-one:1.38"
  command: ["--memory.max-traces=1000000"]
  ports:
    - "127.0.0.1:16686:16686"
  restart: on-failure
  environment:
    - "COLLECTOR_OTLP_ENABLED=true"
  env_file:
    - ".env"

Add to .env:

OTEL_EXPORTER_OTLP_ENDPOINT=http://openc3-jaeger:4318
OPENC3_OTEL=CMD__TLM__API

@ryanmelt ryanmelt self-assigned this Oct 5, 2022
@codecov
Copy link

codecov bot commented Oct 5, 2022

Codecov Report

Base: 74.01% // Head: 73.98% // Decreases project coverage by -0.03% ⚠️

Coverage data is based on head (3180376) compared to base (a856125).
Patch coverage: 58.95% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #194      +/-   ##
==========================================
- Coverage   74.01%   73.98%   -0.04%     
==========================================
  Files         413      414       +1     
  Lines       25564    25619      +55     
  Branches      560      560              
==========================================
+ Hits        18920    18953      +33     
- Misses       6558     6581      +23     
+ Partials       86       85       -1     
Flag Coverage Δ
frontend 75.84% <ø> (+0.16%) ⬆️
ruby-api 43.90% <3.70%> (-0.02%) ⬇️
ruby-backend 78.41% <69.17%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...enc3-cmd-tlm-api/app/controllers/api_controller.rb 9.30% <3.70%> (+1.80%) ⬆️
openc3/lib/openc3/utilities/open_telemetry.rb 29.54% <29.54%> (ø)
...lib/openc3/microservices/interface_microservice.rb 84.02% <80.28%> (+0.05%) ⬆️
...nc3/lib/openc3/microservices/decom_microservice.rb 89.39% <100.00%> (+0.33%) ⬆️
openc3/lib/openc3/microservices/microservice.rb 67.79% <100.00%> (+0.55%) ⬆️
openc3/lib/openc3/topics/command_topic.rb 100.00% <100.00%> (ø)
openc3/lib/openc3/topics/telemetry_decom_topic.rb 92.30% <100.00%> (+1.39%) ⬆️
...3/lib/openc3/microservices/reducer_microservice.rb 90.72% <0.00%> (-0.07%) ⬇️
...enc3-tool-calendar/src/tools/Calendar/Calendar.vue 71.03% <0.00%> (+5.51%) ⬆️
openc3/lib/openc3/utilities/metric.rb 96.07% <0.00%> (+5.88%) ⬆️

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.

Copy link
Member

@jmthomas jmthomas left a comment

Choose a reason for hiding this comment

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

I look forward to trying it out!

def self.with_context(hash)
if @otel_enabled
extracted_context = OpenTelemetry.propagation.extract(hash)
OpenTelemetry::Context.with_current(extracted_context) do
Copy link
Member

Choose a reason for hiding this comment

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

So you inject_context and then use with_context to link together the tracing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep

db_statement: :include,
}
c.use 'OpenTelemetry::Instrumentation::HttpClient'
c.use 'OpenTelemetry::Instrumentation::AwsSdk'
Copy link
Member

Choose a reason for hiding this comment

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

All these use statements are how OpenTelemetry can instrument and interpret various nested calls within Ruby?

Copy link
Member Author

Choose a reason for hiding this comment

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

The use statements enable built in instrumentors provided by OpenTelemetry. So they automatically inject spans for calls to the associated libraries.

@ryanmelt ryanmelt merged commit 1aa66ae into master Oct 7, 2022
@ryanmelt ryanmelt deleted the opentelemetry branch October 7, 2022 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorporate OpenTelemetry for Tracing
2 participants