Skip to content

Commit 8e4da19

Browse files
fix: Regenerate v0.20.0 protos (#1498)
* fix: Regenerate v0.20.0 protos This change does a few things: 1. Adds a guide for maintainers to update protos 2. Updates the rake task to regenerate code from protos using a clean directory. 1. This ensures any changes upstream that _deletes_ protos are applied to this repo 3. Updates the rake task to fast fail when it encounters an error, e.g. protoc is not installed * squash: LINTERS * squash: I swear officer the space was there
1 parent 1159ec0 commit 8e4da19

File tree

6 files changed

+66
-218
lines changed

6 files changed

+66
-218
lines changed

exporter/otlp/README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ Generally, *libraries* that produce telemetry data should avoid depending direct
1616

1717
### Supported protocol version
1818

19-
This gem supports the [v0.4.0 release](https://github.com/open-telemetry/opentelemetry-proto/releases/tag/v0.4.0) of OTLP.
19+
This gem supports the [v0.20.0 release][otel-proto-release] of OTLP.
2020

2121
## How do I get started?
2222

2323
Install the gem using:
2424

25-
```
25+
```console
26+
2627
gem install opentelemetry-sdk
2728
gem install opentelemetry-exporter-otlp
29+
2830
```
2931

3032
Or, if you use [bundler][bundler-home], include `opentelemetry-sdk` in your `Gemfile`.
@@ -93,6 +95,48 @@ The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special int
9395

9496
The `opentelemetry-exporter-otlp` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information.
9597

98+
## Working with Proto Definitions
99+
100+
The OTel community maintains a [repository with protobuf definitions][otel-proto-github] that language and collector implementors use to generate code.
101+
102+
Maintainers are expected to keep up to date with the latest version of protos. This guide will provide you with step-by-step instructions on updating the OTLP Exporter gem with the latest definitions.
103+
104+
### System Requirements
105+
106+
- [`git` 2.41+][git-install]
107+
- [`protoc` 22.5][protoc-install]
108+
- [Ruby 3+][ruby-downloads]
109+
110+
> :warning: `protoc 23.x` *changes the Ruby code generator to emit a serialized proto instead of a DSL.* <https://protobuf.dev/news/2023-04-20/>. Please ensure you use `protoc` version `22.x` in order to ensure we remain compatible with versions of protobuf prior to `google-protobuf` gem `3.18`.
111+
112+
### Upgrade Proto Definitions
113+
114+
**Update the target otel-proto version in the `Rakefile` that matches a release `tag` in the proto repo, e.g.**
115+
116+
```ruby
117+
# Rakefile
118+
119+
# https://github.com/open-telemetry/opentelemetry-proto/tree/v0.20.0
120+
PROTO_VERSION = `v0.20.0`
121+
```
122+
123+
**Generate the Ruby source files using `rake`:**
124+
125+
```console
126+
127+
$> bundle exec rake protobuf:generate
128+
129+
```
130+
131+
**Run tests and fix any errors:**
132+
133+
```console
134+
135+
$> bundle exec rake test
136+
137+
```
138+
139+
**Commit the chnages and open a PR!**
96140

97141
[opentelemetry-collector-home]: https://opentelemetry.io/docs/collector/about/
98142
[opentelemetry-home]: https://opentelemetry.io
@@ -103,3 +147,8 @@ The `opentelemetry-exporter-otlp` gem is distributed under the Apache 2.0 licens
103147
[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
104148
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
105149
[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
150+
[git-install]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
151+
[protoc-install]: https://github.com/protocolbuffers/protobuf/releases/tag/v22.5
152+
[ruby-downloads]: https://www.ruby-lang.org/en/downloads/
153+
[otel-proto-github]: https://github.com/open-telemetry/opentelemetry-proto
154+
[otel-proto-release]: https://github.com/open-telemetry/opentelemetry-proto/releases/tag/v0.20.0

exporter/otlp/Rakefile

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,21 @@ else
2929
task default: %i[test rubocop yard]
3030
end
3131

32+
# https://github.com/open-telemetry/opentelemetry-proto/tree/v0.20.0
3233
PROTO_VERSION = 'v0.20.0'
33-
PROTOBUF_FILES = [
34-
'collector/logs/v1/logs_service.proto',
35-
'collector/metrics/v1/metrics_service.proto',
36-
'collector/trace/v1/trace_service.proto',
37-
'common/v1/common.proto',
38-
'logs/v1/logs.proto',
39-
'metrics/v1/metrics.proto',
40-
'resource/v1/resource.proto',
41-
'trace/v1/trace.proto',
42-
'trace/v1/trace_config.proto'
43-
].freeze
44-
45-
task :update_protobuf do
46-
system("git clone -b #{PROTO_VERSION} https://github.com/open-telemetry/opentelemetry-proto")
47-
PROTOBUF_FILES.each do |file|
48-
system("protoc --ruby_out=lib/ --proto_path=opentelemetry-proto opentelemetry/proto/#{file}")
34+
35+
namespace :protobuf do
36+
task :clean do
37+
FileUtils.rm_rf('lib/opentelemetry/proto')
38+
FileUtils.rm_rf('opentelemetry-proto')
39+
end
40+
41+
desc "Generate Ruby Source files from OTel Proto Version #{PROTO_VERSION}"
42+
task generate: [:clean] do
43+
system("git clone -b #{PROTO_VERSION} https://github.com/open-telemetry/opentelemetry-proto", exception: true)
44+
Dir['opentelemetry-proto/opentelemetry/proto/**/*.proto'].each do |file|
45+
system("protoc --ruby_out=lib/ --proto_path=opentelemetry-proto #{file.gsub('opentelemetry-proto/', '')}", exception: true)
46+
end
47+
FileUtils.rm_rf('opentelemetry-proto')
4948
end
50-
system('rm -rf opentelemetry-proto')
5149
end

exporter/otlp/lib/opentelemetry/proto/collector/logs/v1/logs_service_services_pb.rb

Lines changed: 0 additions & 50 deletions
This file was deleted.

exporter/otlp/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_services_pb.rb

Lines changed: 0 additions & 50 deletions
This file was deleted.

exporter/otlp/lib/opentelemetry/proto/collector/trace/v1/trace_service_services_pb.rb

Lines changed: 0 additions & 50 deletions
This file was deleted.

exporter/otlp/lib/opentelemetry/proto/trace/v1/trace_config_pb.rb

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)