|
1 | 1 | # OpenTelemetry |
2 | 2 |
|
3 | | -**Supported tracing frameworks**: |
| 3 | +**Supported OpenTelemetry features**: |
4 | 4 |
|
5 | 5 | | Type | Documentation | datadog version | Gem version support | |
6 | 6 | | ------------- | ---------------------------------------------------- | --------------- | ------------------- | |
7 | | -| OpenTelemetry | https://github.com/open-telemetry/opentelemetry-ruby | 1.9.0+ | >= 1.1.0 | |
| 7 | +| Tracing | https://github.com/open-telemetry/opentelemetry-ruby | 1.9.0+ | >= 1.1.0 | |
| 8 | +| Metrics | https://github.com/open-telemetry/opentelemetry-ruby | 1.9.0+ | SDK >= 0.8, Exporter >= 0.4 | |
8 | 9 |
|
9 | | -## Configuring OpenTelemetry |
| 10 | +## Configuring OpenTelemetry Tracing |
10 | 11 |
|
11 | 12 | 1. Add the `datadog` gem to your Gemfile: |
12 | 13 |
|
|
44 | 45 |
|
45 | 46 | [Integration instrumentations](#integration-instrumentation) and OpenTelemetry [Automatic instrumentations](https://opentelemetry.io/docs/instrumentation/ruby/automatic/) are also supported. |
46 | 47 |
|
| 48 | +## Configuring OpenTelemetry Metrics |
| 49 | + |
| 50 | +1. Add required gems to your Gemfile: |
| 51 | + |
| 52 | + ```ruby |
| 53 | + gem 'datadog' |
| 54 | + gem 'opentelemetry-metrics-sdk', '>= 0.8' |
| 55 | + gem 'opentelemetry-exporter-otlp-metrics', '>= 0.4' |
| 56 | + ``` |
| 57 | + |
| 58 | +1. Install gems with `bundle install` |
| 59 | + |
| 60 | +1. Enable metrics export: |
| 61 | + |
| 62 | + ```ruby |
| 63 | + require 'opentelemetry/sdk' |
| 64 | + require 'opentelemetry-metrics-sdk' |
| 65 | + require 'opentelemetry/exporter/otlp_metrics' |
| 66 | + require 'datadog/opentelemetry/metrics' |
| 67 | +
|
| 68 | + # Set environment variable or configure via Datadog |
| 69 | + ENV['DD_METRICS_OTEL_ENABLED'] = 'true' |
| 70 | +
|
| 71 | + Datadog.configure do |c| |
| 72 | + c.service = 'my-service' |
| 73 | + c.version = '1.0.0' |
| 74 | + c.env = 'production' |
| 75 | + end |
| 76 | + ``` |
| 77 | + |
| 78 | +1. Use the OpenTelemetry Metrics API: |
| 79 | + |
| 80 | + ```ruby |
| 81 | + require 'opentelemetry/metrics' |
| 82 | +
|
| 83 | + provider = OpenTelemetry.meter_provider |
| 84 | + meter = provider.meter('my-app') |
| 85 | + counter = meter.create_counter('requests') |
| 86 | + counter.add(1) |
| 87 | + ``` |
| 88 | + |
| 89 | +**Configuration Options:** |
| 90 | + |
| 91 | +- `DD_METRICS_OTEL_ENABLED` - Enable metrics export (default: false) |
| 92 | +- `OTEL_EXPORTER_OTLP_METRICS_PROTOCOL` - Protocol: `grpc` (default) or `http/protobuf` |
| 93 | +- `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` - Custom endpoint (defaults to agent hostname + protocol port) |
| 94 | +- `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` - `delta` (default) or `cumulative` |
| 95 | +- `OTEL_METRIC_EXPORT_INTERVAL` - Export interval in milliseconds (default: 60000) |
| 96 | + |
| 97 | +General OTLP settings (`OTEL_EXPORTER_OTLP_*`) serve as defaults if metrics-specific settings are not provided. |
| 98 | + |
| 99 | +**Note:** Minimum `opentelemetry-metrics-sdk` is v0.8.0 (contains critical bug fixes). Use the latest version for best support. Exporter minimum depends on the metrics SDK. If OpenTelemetry API breaking changes affect ddtrace, [open a GitHub issue](https://github.com/DataDog/dd-trace-rb/issues). |
| 100 | + |
47 | 101 | ## Limitations |
48 | 102 |
|
49 | 103 | There are a few limitations to OpenTelemetry Tracing when the APM integration is activated: |
|
0 commit comments