opentelemetry-propagator-xray 0.19.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +17 -0
- data/lib/opentelemetry/propagator/xray.rb +1 -0
- data/lib/opentelemetry/propagator/xray/id_generator.rb +54 -0
- data/lib/opentelemetry/propagator/xray/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca3370fa3f9f9fa94ef28c282efd6d36a1699dff92113dac4b1eb6151ed028f5
|
4
|
+
data.tar.gz: 484eacc6800f0cfdacea45e12e1caaedffea4eb0f2a5d70ad983046e4a051ced
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eec0d22dc44cbea2e243a9d29da5ac2f3899904b5d8ee2da2c3c64785869e342a0ee5a399c4ea5c17bbdf1aaa9695fad750eb9d771a4d16a1ff9b490d9d4966
|
7
|
+
data.tar.gz: 1cd3b9ca47adf31e87174d30d22f751dfab9ab89e729fc0e18caebbf4ffc305fb376005791d11fffa140c15eb9f56a4a58933cc9d080851db8c74ef2f2519377
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -23,6 +23,23 @@ gem install opentelemetry-propagator-xray
|
|
23
23
|
|
24
24
|
Or, if you use [bundler][bundler-home], include `opentelemetry-propagator-xray` in your `Gemfile`.
|
25
25
|
|
26
|
+
In your application:
|
27
|
+
```
|
28
|
+
require 'opentelemetry/propagator/xray'
|
29
|
+
# Optional
|
30
|
+
ENV['OTEL_PROPAGATORS'] ||= 'xray' # Or you can set this as an environment variable outside of the application
|
31
|
+
```
|
32
|
+
|
33
|
+
## To generate AWS XRay compliant IDs use the 'OpenTelemetry::AWSXRayTrace' module:
|
34
|
+
```
|
35
|
+
require 'opentelemetry/propagator/xray'
|
36
|
+
|
37
|
+
OpenTelemetry::SDK.configure do |c|
|
38
|
+
c.id_generator = OpenTelemetry::Propagator::XRay::IDGenerator
|
39
|
+
end
|
40
|
+
```
|
41
|
+
The propagator and ID generation are independent and do not need to be used in conjunction but can be.
|
42
|
+
|
26
43
|
## How can I get involved?
|
27
44
|
|
28
45
|
The `opentelemetry-propagator-xray` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
|
+
#
|
5
|
+
# SPDX-License-Identifier: Apache-2.0
|
6
|
+
|
7
|
+
module OpenTelemetry
|
8
|
+
module Propagator
|
9
|
+
module XRay
|
10
|
+
# This module is intended to only be used as an override for how to generate IDs to be compliant with XRay
|
11
|
+
module IDGenerator
|
12
|
+
extend self
|
13
|
+
|
14
|
+
# Generates a valid trace identifier, a 16-byte string with at least one
|
15
|
+
# non-zero byte.
|
16
|
+
# AWS Docs: https://docs.aws.amazon.com/xray/latest/api/API_PutTraceSegments.html
|
17
|
+
# hi - 4 bytes timestamp, 4 bytes random (Mid)
|
18
|
+
# low - 8 bytes random.
|
19
|
+
# Since we include timestamp, impossible to be invalid.
|
20
|
+
# @return [bytes] a valid trace ID that is compliant with AWS XRay.
|
21
|
+
def generate_trace_id
|
22
|
+
time_hi = generate_time_bytes
|
23
|
+
mid_and_low = RANDOM.bytes(12)
|
24
|
+
time_hi << mid_and_low
|
25
|
+
end
|
26
|
+
|
27
|
+
# Generates a valid span identifier, an 8-byte string with at least one
|
28
|
+
# non-zero byte.
|
29
|
+
#
|
30
|
+
# @return [bytes] a valid span ID.
|
31
|
+
def generate_span_id
|
32
|
+
OpenTelemetry::Trace.generate_span_id
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
# Random number generator for generating IDs. This is an object that can
|
38
|
+
# respond to `#bytes` and uses the system PRNG. The current logic is
|
39
|
+
# compatible with Ruby 2.5 (which does not implement the `Random.bytes`
|
40
|
+
# class method) and with Ruby 3.0+ (which deprecates `Random::DEFAULT`).
|
41
|
+
# When we drop support for Ruby 2.5, this can simply be replaced with
|
42
|
+
# the class `Random`.
|
43
|
+
#
|
44
|
+
# @return [#bytes]
|
45
|
+
RANDOM = Random.respond_to?(:bytes) ? Random : Random::DEFAULT
|
46
|
+
|
47
|
+
# Seconds since epoch converted to 4 bytes in big-endian order.
|
48
|
+
def generate_time_bytes
|
49
|
+
[Time.now.to_i].pack('N')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-propagator-xray
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenTelemetry Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.0.
|
19
|
+
version: 1.0.0.rc3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0.0.
|
26
|
+
version: 1.0.0.rc3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,16 +135,17 @@ files:
|
|
135
135
|
- README.md
|
136
136
|
- lib/opentelemetry-propagator-xray.rb
|
137
137
|
- lib/opentelemetry/propagator/xray.rb
|
138
|
+
- lib/opentelemetry/propagator/xray/id_generator.rb
|
138
139
|
- lib/opentelemetry/propagator/xray/text_map_propagator.rb
|
139
140
|
- lib/opentelemetry/propagator/xray/version.rb
|
140
141
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
141
142
|
licenses:
|
142
143
|
- Apache-2.0
|
143
144
|
metadata:
|
144
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-propagator-xray/v0.
|
145
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-propagator-xray/v0.20.0/file.CHANGELOG.html
|
145
146
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/propagator/xray
|
146
147
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
147
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-propagator-xray/v0.
|
148
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-propagator-xray/v0.20.0
|
148
149
|
post_install_message:
|
149
150
|
rdoc_options: []
|
150
151
|
require_paths:
|