forked from open-telemetry/opentelemetry-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite emailservice in ruby (open-telemetry#109)
* feat: rewrite emailservice in ruby Rather than use GRPC, we reimplement the emailservice as a simple HTTP application, using Sinatra and OpenTelemetry auto-instrumentation. We can do this because our use of GRPC in this instance is not very complicated - we can just serialize the protobuf request to JSON and send it over HTTP instead, and it's pretty straightforward. Probably the most interesting part here is that we're rendering the email text right into the logfile, which might be noisy. We can revisit that decision if needed. * feat: call emailservice via HTTP POST This commit causes the checkoutservice to call emailservice via HTTP POST. We leverage the golang net/http autoinstrumentation to create the spans and propagate context correctly for us. * feat: modify setup to work with otel/ruby Because we rewrote the emailservice as an HTTP service, we need to modify the `EMAIL_SERVICE_ADDR` to reflect the actual scheme (`http`). We could just do some more string concatenation in the app, I guess. We pin to a specific collector version - I was getting weird segfaults with whatever version of the collector was already on my machine, and they were resolved with 0.52.0. However, that also required a minor config change to the jaeger exporter. Yay, M1 macs! We can't specify the otlp/grpc port for the ruby libraries, it won't work. So for email service we pass the correct OTLP/HTTP URL in the env var. * docs: note that emailservice is now ruby * fixup: remove `loglevel: debug` from otel-col config Whoops, this was accidentally left in from my testing. * fixup: appease markdownlint
- Loading branch information
1 parent
fc730cc
commit 916e195
Showing
21 changed files
with
197 additions
and
3,041 deletions.
There are no files selected for viewing
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
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 @@ | ||
3.1.2 |
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,10 @@ | ||
source "https://rubygems.org" | ||
|
||
gem "net-smtp", "~> 0.3" | ||
gem "pony", "~> 1.13" | ||
gem "puma", "~> 5.6" | ||
gem "sinatra", "~> 2.2" | ||
|
||
gem "opentelemetry-sdk", "~> 1.1" | ||
gem "opentelemetry-exporter-otlp", "~> 0.21" | ||
gem "opentelemetry-instrumentation-sinatra", "~> 0.19" |
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,74 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
digest (3.1.0) | ||
google-protobuf (3.21.1) | ||
googleapis-common-protos-types (1.3.1) | ||
google-protobuf (~> 3.14) | ||
mail (2.7.1) | ||
mini_mime (>= 0.1.1) | ||
mini_mime (1.1.2) | ||
mustermann (1.1.1) | ||
ruby2_keywords (~> 0.0.1) | ||
net-protocol (0.1.3) | ||
timeout | ||
net-smtp (0.3.1) | ||
digest | ||
net-protocol | ||
timeout | ||
nio4r (2.5.8) | ||
opentelemetry-api (1.0.2) | ||
opentelemetry-common (0.19.6) | ||
opentelemetry-api (~> 1.0) | ||
opentelemetry-exporter-otlp (0.21.3) | ||
google-protobuf (~> 3.19) | ||
googleapis-common-protos-types (~> 1.3) | ||
opentelemetry-api (~> 1.0) | ||
opentelemetry-common (~> 0.19.3) | ||
opentelemetry-sdk (~> 1.0) | ||
opentelemetry-semantic_conventions | ||
opentelemetry-instrumentation-base (0.20.0) | ||
opentelemetry-api (~> 1.0) | ||
opentelemetry-instrumentation-sinatra (0.19.4) | ||
opentelemetry-api (~> 1.0) | ||
opentelemetry-common (~> 0.19.3) | ||
opentelemetry-instrumentation-base (~> 0.20.0) | ||
opentelemetry-registry (0.1.0) | ||
opentelemetry-api (~> 1.0.1) | ||
opentelemetry-sdk (1.1.0) | ||
opentelemetry-api (~> 1.0) | ||
opentelemetry-common (~> 0.19.3) | ||
opentelemetry-registry (~> 0.1) | ||
opentelemetry-semantic_conventions | ||
opentelemetry-semantic_conventions (1.8.0) | ||
opentelemetry-api (~> 1.0) | ||
pony (1.13.1) | ||
mail (>= 2.0) | ||
puma (5.6.4) | ||
nio4r (~> 2.0) | ||
rack (2.2.3.1) | ||
rack-protection (2.2.0) | ||
rack | ||
ruby2_keywords (0.0.5) | ||
sinatra (2.2.0) | ||
mustermann (~> 1.0) | ||
rack (~> 2.2) | ||
rack-protection (= 2.2.0) | ||
tilt (~> 2.0) | ||
tilt (2.0.10) | ||
timeout (0.3.0) | ||
|
||
PLATFORMS | ||
arm64-darwin-21 | ||
|
||
DEPENDENCIES | ||
net-smtp (~> 0.3) | ||
opentelemetry-exporter-otlp (~> 0.21) | ||
opentelemetry-instrumentation-sinatra (~> 0.19) | ||
opentelemetry-sdk (~> 1.1) | ||
pony (~> 1.13) | ||
puma (~> 5.6) | ||
sinatra (~> 2.2) | ||
|
||
BUNDLED WITH | ||
2.3.7 |
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 |
---|---|---|
@@ -1,3 +1,23 @@ | ||
# Read Me | ||
# Email Service | ||
|
||
This is a placeholder | ||
The Email service "sends" an email to the customer with their order details by | ||
rendering it as a log message. It expects a JSON payload like: | ||
|
||
```json | ||
{ | ||
"email": "[email protected]", | ||
"order": "<serialized order protobuf>" | ||
} | ||
``` | ||
|
||
## Building locally | ||
|
||
We use `bundler` to manage dependencies. To get started, simply `bundle install`. | ||
|
||
## Running locally | ||
|
||
You may run this service locally with `bundle exec ruby email_server.rb`. | ||
|
||
## Building docker image | ||
|
||
From `src/emailservice`, run `docker build .` |
Oops, something went wrong.