Skip to content

Commit

Permalink
Merge branch 'main' into issues-1707
Browse files Browse the repository at this point in the history
  • Loading branch information
kaylareopelle authored Jan 8, 2025
2 parents 420bd49 + 1c6004d commit 05f588f
Show file tree
Hide file tree
Showing 35 changed files with 350 additions and 35 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/ci-markdown-link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ name: Markdown Link Check

on:
pull_request:
paths:
- '**/*.md'

jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: "Markdown Link Check"
uses: gaurav-nelson/github-action-markdown-link-check@v1
# equivalent cli: linkspector check
- name: Run linkspector
uses: umbrelladocs/action-linkspector@v1
with:
config-file: '.markdown-link-check.json'
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
fail_on_error: true
10 changes: 0 additions & 10 deletions .markdown-link-check.json

This file was deleted.

14 changes: 14 additions & 0 deletions .toys/.data/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ gems:
directory: exporter/otlp
version_constant: [OpenTelemetry, Exporter, OTLP, VERSION]

- name: opentelemetry-exporter-otlp-logs
directory: exporter/otlp-logs
version_constant: [OpenTelemetry, Exporter, OTLP, Logs, VERSION]

- name: opentelemetry-exporter-otlp-metrics
directory: exporter/otlp-metrics
version_constant: [OpenTelemetry, Exporter, OTLP, Metrics, VERSION]
Expand Down Expand Up @@ -98,3 +102,13 @@ gems:
directory: metrics_sdk
version_rb_path: lib/opentelemetry/sdk/metrics/version.rb
version_constant: [OpenTelemetry, SDK, Metrics, VERSION]

- name: opentelemetry-logs-api
directory: logs_api
version_rb_path: lib/opentelemetry/logs/version.rb
version_constant: [OpenTelemetry, Logs, VERSION]

- name: opentelemetry-logs-sdk
directory: logs_sdk
version_rb_path: lib/opentelemetry/sdk/logs/version.rb
version_constant: [OpenTelemetry, SDK, Logs, VERSION]
5 changes: 3 additions & 2 deletions examples/http/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

source "https://rubygems.org"

gem "faraday", "~> 0.16.1"
gem "faraday", "~> 2.0"
gem "opentelemetry-api"
gem "opentelemetry-common"
gem "opentelemetry-sdk"
gem "sinatra", "~> 2.0"
gem "sinatra", "~> 4.1"
gem "puma"
gem "rackup"
31 changes: 31 additions & 0 deletions examples/logs_sdk/logs_console.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

require 'bundler/inline'

gemfile(true) do
source 'https://rubygems.org'

gem 'opentelemetry-logs-api', path: '../../logs_api'
gem 'opentelemetry-logs-sdk', path: '../../logs_sdk'
end

require 'opentelemetry-logs-sdk'

# Create a LoggerProvider
logger_provider = OpenTelemetry::SDK::Logs::LoggerProvider.new
# Create a batching processor configured to export to the OTLP exporter
processor = OpenTelemetry::SDK::Logs::Export::SimpleLogRecordProcessor.new(OpenTelemetry::SDK::Logs::Export::ConsoleLogRecordExporter.new)
# Add the processor to the LoggerProvider
logger_provider.add_log_record_processor(processor)
# Access a Logger for your library from your LoggerProvider
logger = logger_provider.logger(name: 'my_app_or_gem', version: '0.1.0')

# Use your Logger to emit a log record
logger.on_emit(
timestamp: Time.now,
severity_text: 'INFO',
body: 'Thuja plicata',
attributes: { 'cedar' => true },
)

logger_provider.shutdown
31 changes: 31 additions & 0 deletions examples/logs_sdk/logs_console_with_sdk.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

require 'bundler/inline'

gemfile(true) do
source 'https://rubygems.org'

gem 'opentelemetry-sdk', path: '../../sdk'
gem 'opentelemetry-logs-api', path: '../../logs_api'
gem 'opentelemetry-logs-sdk', path: '../../logs_sdk'
end

require 'opentelemetry-sdk'
require 'opentelemetry-logs-sdk'

# Export logs to the console
ENV['OTEL_LOGS_EXPORTER'] = 'console'

# Configure SDK with defaults, this will apply the OTEL_LOGS_EXPORTER env var
OpenTelemetry::SDK.configure

# Access a Logger for your library from the LoggerProvider configured by the OpenTelemetry API
logger = OpenTelemetry.logger_provider.logger(name: 'my_app_or_gem', version: '0.1.0')

# Use your Logger to emit a log record
logger.on_emit(
timestamp: Time.now,
severity_text: 'INFO',
body: 'Thuja plicata',
attributes: { 'cedar' => true },
)
33 changes: 33 additions & 0 deletions examples/logs_sdk/logs_otlp.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require 'bundler/inline'

gemfile(true) do
source 'https://rubygems.org'

gem 'opentelemetry-logs-api', path: '../../logs_api'
gem 'opentelemetry-logs-sdk', path: '../../logs_sdk'
gem 'opentelemetry-exporter-otlp-logs', path: '../../exporter/otlp-logs'
end

require 'opentelemetry-logs-sdk'
require 'opentelemetry/exporter/otlp_logs'

# Create a LoggerProvider
logger_provider = OpenTelemetry::SDK::Logs::LoggerProvider.new
# Create a batching processor configured to export to the OTLP exporter
processor = OpenTelemetry::SDK::Logs::Export::BatchLogRecordProcessor.new(OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new)
# Add the processor to the LoggerProvider
logger_provider.add_log_record_processor(processor)
# Access a Logger for your library from your LoggerProvider
logger = logger_provider.logger(name: 'my_app_or_gem', version: '0.1.0')

# Use your Logger to emit a log record
logger.on_emit(
timestamp: Time.now,
severity_text: 'INFO',
body: 'Thuja plicata',
attributes: { 'cedar' => true },
)

logger_provider.shutdown
4 changes: 4 additions & 0 deletions exporter/otlp-logs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Release History: opentelemetry-exporter-otlp-logs

### v0.1.0 / 2024-12-04

Initial release.
2 changes: 1 addition & 1 deletion exporter/otlp-logs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Install the gem using:
```console

gem install opentelemetry-logs-sdk
gem install opentelemetry-exporter-otlp
gem install opentelemetry-exporter-otlp-logs

```

Expand Down
6 changes: 5 additions & 1 deletion exporter/otlp-metrics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Release History: opentelemetry-exporter-otlp-metrics

### v0.2.0 / 2024-11-19
### v0.2.1 / 2024-12-04

* FIXED: Handle float value in NumberDataPoint

### v0.2.0 / 2024-11-20

* ADDED: Add basic metrics view
* FIXED: Remove Metrics OTLP exporter `Util#measure_request_duration` and duplicate files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,17 @@ def encode(metrics_data)
end

# metrics_pb has following type of data: :gauge, :sum, :histogram, :exponential_histogram, :summary
# current metric sdk only implements instrument: :counter -> :sum, :histogram -> :histogram
# current metric sdk only implements instrument: :counter -> :sum, :histogram -> :histogram, :gauge -> :gauge
#
# metrics [MetricData]
def as_otlp_metrics(metrics)
case metrics.instrument_kind
when :observable_gauge
when :observable_gauge, :gauge
Opentelemetry::Proto::Metrics::V1::Metric.new(
name: metrics.name,
description: metrics.description,
unit: metrics.unit,
gauge: Opentelemetry::Proto::Metrics::V1::Gauge.new(
aggregation_temporality: as_otlp_aggregation_temporality(metrics.aggregation_temporality),
data_points: metrics.data_points.map do |ndp|
number_data_point(ndp)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Exporter
module OTLP
module Metrics
## Current OpenTelemetry OTLP exporter version
VERSION = '0.2.0'
VERSION = '0.2.1'
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,16 @@
stub_request(:post, 'http://localhost:4318/v1/metrics').to_return(status: 200)
meter_provider.add_metric_reader(exporter)
meter = meter_provider.meter('test')

counter = meter.create_counter('test_counter', unit: 'smidgen', description: 'a small amount of something')
counter.add(5, attributes: { 'foo' => 'bar' })

histogram = meter.create_histogram('test_histogram', unit: 'smidgen', description: 'a small amount of something')
histogram.record(10, attributes: { 'oof' => 'rab' })

gauge = meter.create_gauge('test_gauge', unit: 'smidgen', description: 'a small amount of something')
gauge.record(15, attributes: { 'baz' => 'qux' })

exporter.pull
meter_provider.shutdown

Expand Down Expand Up @@ -644,6 +649,24 @@
],
aggregation_temporality: Opentelemetry::Proto::Metrics::V1::AggregationTemporality::AGGREGATION_TEMPORALITY_DELTA
)
),
Opentelemetry::Proto::Metrics::V1::Metric.new(
name: 'test_gauge',
description: 'a small amount of something',
unit: 'smidgen',
gauge: Opentelemetry::Proto::Metrics::V1::Gauge.new(
data_points: [
Opentelemetry::Proto::Metrics::V1::NumberDataPoint.new(
attributes: [
Opentelemetry::Proto::Common::V1::KeyValue.new(key: 'baz', value: Opentelemetry::Proto::Common::V1::AnyValue.new(string_value: 'qux'))
],
as_int: 15,
start_time_unix_nano: 1_699_593_427_329_946_585,
time_unix_nano: 1_699_593_427_329_946_586,
exemplars: nil
)
]
)
)
]
)
Expand Down
1 change: 1 addition & 0 deletions exporter/otlp-metrics/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def collect(start_time, end_time, data_points)

OpenTelemetry::SDK::Metrics::Aggregation::Sum.prepend(MockSum)
OpenTelemetry::SDK::Metrics::Aggregation::ExplicitBucketHistogram.prepend(MockSum)
OpenTelemetry::SDK::Metrics::Aggregation::LastValue.prepend(MockSum)

def create_metrics_data(name: '', description: '', unit: '', instrument_kind: :counter, resource: nil,
instrumentation_scope: OpenTelemetry::SDK::InstrumentationScope.new('', 'v0.0.1'),
Expand Down
4 changes: 4 additions & 0 deletions exporter/otlp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-exporter-otlp

### v0.29.1 / 2024-12-04

* FIXED: Remove WRITE_TIMEOUT_SUPPORTED

### v0.29.0 / 2024-08-27

* ADDED: Add support for mutual TLS.
Expand Down
2 changes: 1 addition & 1 deletion exporter/otlp/lib/opentelemetry/exporter/otlp/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module OpenTelemetry
module Exporter
module OTLP
## Current OpenTelemetry OTLP exporter version
VERSION = '0.29.0'
VERSION = '0.29.1'
end
end
end
4 changes: 4 additions & 0 deletions exporter/zipkin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-exporter-zipkin

### v0.23.2 / 2024-12-04

* FIXED: Remove WRITE_TIMEOUT_SUPPORTED

### v0.23.1 / 2024-02-06

* FIXED: Require csv for ruby-3.4 compatibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module OpenTelemetry
module Exporter
module Zipkin
## Current OpenTelemetry Zipkin exporter version
VERSION = '0.23.1'
VERSION = '0.23.2'
end
end
end
4 changes: 4 additions & 0 deletions logs_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Release History: opentelemetry-logs-api

### v0.1.0 / 2024-12-04

Initial release.
4 changes: 4 additions & 0 deletions logs_sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Release History: opentelemetry-logs-sdk

### v0.1.0 / 2024-12-04

Initial release.
2 changes: 1 addition & 1 deletion metrics_api/lib/opentelemetry/internal/proxy_instrument.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def initialize(kind, name, unit, desc, callable)

def upgrade_with(meter)
@delegate = case @kind
when :counter, :histogram, :up_down_counter
when :counter, :histogram, :up_down_counter, :gauge
meter.send("create_#{@kind}", @name, unit: @unit, description: @desc)
when :observable_counter, :observable_gauge, :observable_up_down_counter
meter.send("create_#{@kind}", @name, unit: @unit, description: @desc, callback: @callback)
Expand Down
1 change: 1 addition & 0 deletions metrics_api/lib/opentelemetry/internal/proxy_meter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def create_instrument(kind, name, unit, description, callback)
case kind
when :counter then @delegate.create_counter(name, unit: unit, description: description)
when :histogram then @delegate.create_histogram(name, unit: unit, description: description)
when :gauge then @delegate.create_gauge(name, unit: unit, description: description)
when :up_down_counter then @delegate.create_up_down_counter(name, unit: unit, description: description)
when :observable_counter then @delegate.create_observable_counter(name, unit: unit, description: description, callback: callback)
when :observable_gauge then @delegate.create_observable_gauge(name, unit: unit, description: description, callback: callback)
Expand Down
1 change: 1 addition & 0 deletions metrics_api/lib/opentelemetry/metrics/instrument.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

require 'opentelemetry/metrics/instrument/counter'
require 'opentelemetry/metrics/instrument/histogram'
require 'opentelemetry/metrics/instrument/gauge'
require 'opentelemetry/metrics/instrument/observable_counter'
require 'opentelemetry/metrics/instrument/observable_gauge'
require 'opentelemetry/metrics/instrument/observable_up_down_counter'
Expand Down
23 changes: 23 additions & 0 deletions metrics_api/lib/opentelemetry/metrics/instrument/gauge.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
module Metrics
module Instrument
# No-op implementation of Gauge.
class Gauge
# Record the current value for the Gauge
#
# @param [Numeric] amount The current absolute value.
# @param [Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}] attributes
# Values must be non-nil and (array of) string, boolean or numeric type.
# Array values must not contain nil elements and all elements must be of
# the same basic type (string, numeric, boolean).
def record(amount, attributes: {}); end
end
end
end
end
Loading

0 comments on commit 05f588f

Please sign in to comment.