Odigos will automatically instrument your services and record semantic spans from popular modules. Many users find the automatic instrumentation data sufficient for their needs.However, if there is anything specific to your application that you want to record, you can enrich the data by adding custom spans to your code.This is sometimes referred to as manual instrumentation.
# If in a Rails app, this lives in config/initializers/opentelemetry.rbrequire "opentelemetry/sdk"OpenTelemetry::SDK.configure do |c| c.service_name = '<YOUR_SERVICE_NAME>'end# 'MyAppTracer' can be used throughout your code nowMyAppTracer = OpenTelemetry.tracer_provider.tracer('<YOUR_TRACER_NAME>')
To create a new span:
Copy
Ask AI
require "opentelemetry/sdk"def do_work MyAppTracer.in_span("do_work") do |span| # do some work that the 'do_work' span tracks! endend