-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Quick start Example] Adding RoR quick start example to Tracetest (#2329
) * Adding RoR quick start example to Tracetest * Fixing configuration for this example * Updating image name * Update docker-compose.yaml * Update test-api.yaml
- Loading branch information
1 parent
8c89362
commit 8059e64
Showing
65 changed files
with
1,323 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Quick Start - Ruby on Rails app with OpenTelemetry and Tracetest | ||
|
||
> [Read the detailed recipe for setting up OpenTelemetry Collector with Tractest in our documentation.](https://docs.tracetest.io/examples-tutorials/recipes/running-tracetest-without-a-trace-data-store) | ||
This is a simple quick start on how to configure a Ruby app (with [Rails](https://rubyonrails.org/) framework) to use OpenTelemetry instrumentation with traces, and Tracetest for enhancing your e2e and integration tests with trace-based testing. | ||
|
||
The Ruby on Rails API was created using the [Rails guide for API](https://guides.rubyonrails.org/api_app.html) and the OpenTelemetry instrumentation using the [OpenTelemetry with Ruby guidelines](https://opentelemetry.io/docs/instrumentation/ruby/getting-started/). | ||
|
||
To run it just execute `docker compose up` on this folder. | ||
|
||
Feel free to check out the [docs](https://docs.tracetest.io/), and join our [Discord Community](https://discord.gg/8MtcMrQNbX) for more info! |
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,59 @@ | ||
version: '3' | ||
services: | ||
app: | ||
image: quick-start-ruby-on-rails | ||
build: ./quick_start_api/. | ||
platform: linux/amd64 | ||
extra_hosts: | ||
- "host.docker.internal:host-gateway" | ||
ports: | ||
- "8080:8080" | ||
environment: | ||
- APP_ENV=production | ||
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel-collector:4318/v1/traces | ||
- OTEL_SERVICE_NAME=quick_start_ruby_on_rails | ||
|
||
tracetest: | ||
image: kubeshop/tracetest:latest | ||
platform: linux/amd64 | ||
volumes: | ||
- type: bind | ||
source: ./tracetest/tracetest-config.yaml | ||
target: /app/tracetest.yaml | ||
- type: bind | ||
source: ./tracetest/tracetest-provision.yaml | ||
target: /app/provisioning.yaml | ||
ports: | ||
- 11633:11633 | ||
command: --provisioning-file /app/provisioning.yaml | ||
depends_on: | ||
postgres: | ||
condition: service_healthy | ||
otel-collector: | ||
condition: service_started | ||
healthcheck: | ||
test: ["CMD", "wget", "--spider", "localhost:11633"] | ||
interval: 1s | ||
timeout: 3s | ||
retries: 60 | ||
environment: | ||
TRACETEST_DEV: ${TRACETEST_DEV} | ||
|
||
postgres: | ||
image: postgres:14 | ||
environment: | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_USER: postgres | ||
healthcheck: | ||
test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" | ||
interval: 1s | ||
timeout: 5s | ||
retries: 60 | ||
|
||
otel-collector: | ||
image: otel/opentelemetry-collector-contrib:0.59.0 | ||
command: | ||
- "--config" | ||
- "/otel-local-config.yaml" | ||
volumes: | ||
- ./tracetest/collector.config.yaml:/otel-local-config.yaml |
7 changes: 7 additions & 0 deletions
7
examples/quick-start-ruby-on-rails/quick_start_api/.gitattributes
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,7 @@ | ||
# See https://git-scm.com/docs/gitattributes for more about git attribute files. | ||
|
||
# Mark the database schema as having been generated. | ||
db/schema.rb linguist-generated | ||
|
||
# Mark any vendored files as having been vendored. | ||
vendor/* linguist-vendored |
33 changes: 33 additions & 0 deletions
33
examples/quick-start-ruby-on-rails/quick_start_api/.gitignore
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,33 @@ | ||
# See https://help.github.com/articles/ignoring-files for more about ignoring files. | ||
# | ||
# If you find yourself ignoring temporary files generated by your text editor | ||
# or operating system, you probably want to add a global ignore instead: | ||
# git config --global core.excludesfile '~/.gitignore_global' | ||
|
||
# Ignore bundler config. | ||
/.bundle | ||
|
||
# Ignore the default SQLite database. | ||
/db/*.sqlite3 | ||
/db/*.sqlite3-* | ||
|
||
# Ignore all logfiles and tempfiles. | ||
/log/* | ||
/tmp/* | ||
!/log/.keep | ||
!/tmp/.keep | ||
|
||
# Ignore pidfiles, but keep the directory. | ||
/tmp/pids/* | ||
!/tmp/pids/ | ||
!/tmp/pids/.keep | ||
|
||
# Ignore uploaded files in development. | ||
/storage/* | ||
!/storage/.keep | ||
/tmp/storage/* | ||
!/tmp/storage/ | ||
!/tmp/storage/.keep | ||
|
||
# Ignore master key for decrypting credentials and more. | ||
/config/master.key |
1 change: 1 addition & 0 deletions
1
examples/quick-start-ruby-on-rails/quick_start_api/.ruby-version
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 @@ | ||
ruby-3.1.2 |
12 changes: 12 additions & 0 deletions
12
examples/quick-start-ruby-on-rails/quick_start_api/Dockerfile
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,12 @@ | ||
FROM ruby:3.1.2-alpine | ||
WORKDIR /usr/src/app | ||
|
||
COPY Gemfile Gemfile.lock . | ||
RUN apk update && apk add make gcc musl-dev && bundle install | ||
|
||
COPY . . | ||
RUN chmod 666 ./Gemfile.lock | ||
|
||
EXPOSE 8080 | ||
|
||
CMD [ "bundle", "exec", "rails", "server", "--port", "8080", "--binding", "0.0.0.0" ] |
53 changes: 53 additions & 0 deletions
53
examples/quick-start-ruby-on-rails/quick_start_api/Gemfile
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,53 @@ | ||
source "https://rubygems.org" | ||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
|
||
ruby "3.1.2" | ||
|
||
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" | ||
gem "rails", "~> 7.0.4", ">= 7.0.4.3" | ||
|
||
# Use sqlite3 as the database for Active Record | ||
gem "sqlite3", "~> 1.4" | ||
|
||
# Use the Puma web server [https://github.com/puma/puma] | ||
gem "puma", "~> 5.0" | ||
|
||
# Build JSON APIs with ease [https://github.com/rails/jbuilder] | ||
# gem "jbuilder" | ||
|
||
# Use Redis adapter to run Action Cable in production | ||
# gem "redis", "~> 4.0" | ||
|
||
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] | ||
# gem "kredis" | ||
|
||
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] | ||
# gem "bcrypt", "~> 3.1.7" | ||
|
||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem | ||
gem "tzinfo-data" | ||
|
||
# Adding support for Open Telemetry | ||
gem 'opentelemetry-sdk' | ||
gem 'opentelemetry-exporter-otlp' | ||
gem 'opentelemetry-instrumentation-all' | ||
|
||
# Reduces boot times through caching; required in config/boot.rb | ||
gem "bootsnap", require: false | ||
|
||
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] | ||
# gem "image_processing", "~> 1.2" | ||
|
||
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible | ||
# gem "rack-cors" | ||
|
||
group :development, :test do | ||
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem | ||
gem "debug", platforms: %i[ mri mingw x64_mingw ] | ||
end | ||
|
||
group :development do | ||
# Speed up commands on slow machines / big apps [https://github.com/rails/spring] | ||
# gem "spring" | ||
end | ||
|
Oops, something went wrong.