Skip to content

Commit 8ca0af5

Browse files
DrewProebstelDrew Proebstel
andauthored
Fyst 2088 log client activity (#137)
* wip * give it a shot * linter * test * test * fix log * wip * define propagator as xray * linter * try new initializer * linter * update requirements in intializers --------- Co-authored-by: Drew Proebstel <[email protected]>
1 parent 6b20106 commit 8ca0af5

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,4 @@ gem "standard", ">= 1.35.1"
8181
gem "opentelemetry-sdk", "~> 1.8"
8282
gem "opentelemetry-exporter-otlp", "~> 0.30.0"
8383
gem "opentelemetry-instrumentation-all", "~> 0.80.0"
84+
gem "opentelemetry-propagator-xray"

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ GEM
505505
opentelemetry-helpers-sql-obfuscation
506506
opentelemetry-instrumentation-base (~> 0.23.0)
507507
opentelemetry-semantic_conventions (>= 1.8.0)
508+
opentelemetry-propagator-xray (0.24.0)
509+
opentelemetry-api (~> 1.0)
508510
opentelemetry-registry (0.4.0)
509511
opentelemetry-api (~> 1.1)
510512
opentelemetry-sdk (1.8.1)
@@ -795,6 +797,7 @@ DEPENDENCIES
795797
mailgun-ruby
796798
opentelemetry-exporter-otlp (~> 0.30.0)
797799
opentelemetry-instrumentation-all (~> 0.80.0)
800+
opentelemetry-propagator-xray
798801
opentelemetry-sdk (~> 1.8)
799802
pg
800803
phony
Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
1+
# Basic packages for your application
12
require "opentelemetry/sdk"
23
require "opentelemetry/instrumentation/all"
4+
5+
# Add imports for OTel components into the application
6+
require "opentelemetry-api"
7+
require "opentelemetry-exporter-otlp"
8+
require "opentelemetry-sdk"
9+
10+
# Import the gem containing the AWS X-Ray for OTel Ruby ID Generator and propagator
11+
require "opentelemetry-propagator-xray"
12+
13+
# Configure OpenTelmetry Ruby SDK
314
OpenTelemetry::SDK.configure do |c|
15+
# Set the service name to identify your application in the X-Ray backend service map
416
c.service_name = "pya"
5-
c.use_all
17+
18+
c.span_processors = [
19+
# Use the BatchSpanProcessor to send traces in groups instead of one at a time
20+
Trace::Export::BatchSpanProcessor.new(
21+
# Use the default OLTP Exporter to send traces to the ADOT Collector
22+
OpenTelemetry::Exporter::OTLP::Exporter.new(
23+
# The ADOT Collector is running as a sidecar and listening on port 4318
24+
"http://localhost:4318"
25+
)
26+
)
27+
]
28+
29+
# The X-Ray ID Generator generates spans with X-Ray backend compliant IDs
30+
c.id_generator = OpenTelemetry::Propagator::XRay::IDGenerator
31+
32+
# The X-Ray Propagator injects the X-Ray Tracing Header into downstream calls
33+
c.propagators = [OpenTelemetry::Propagator::XRay::TextMapPropagator.new]
634
end

0 commit comments

Comments
 (0)