fluent-plugin-opentelemetry 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/README.md +27 -0
- data/lib/fluent/plugin/in_opentelemetry.rb +22 -6
- data/lib/fluent/plugin/opentelemetry/constant.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e88abfcc25a1079994f2801f2b32665bb39bb32408cff6efb91125ef9b60149
|
4
|
+
data.tar.gz: 2b64e708b7ea494e4c35e4218c4f33e2ca15f04ac55672d95dc9d7456435303c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26fde29bef629246d797440d306b863ed6ed8cd57d0871f6c66b52b0c3109b453e6d836cb5b99d5b545d778cbb9f4893fdc37166499baf61e92de5bf478f60c5
|
7
|
+
data.tar.gz: 1510198977d2f3b71a58a7a85e9a948b40716bf036c84968b8bb5c1507d63553fd1a06dbc70633d788d110dbc510ef898710eaaf2727d76adfd8baba9b5c9e81
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
plugins:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-fluentd
|
4
|
+
|
1
5
|
AllCops:
|
2
6
|
Exclude:
|
3
7
|
- 'lib/opentelemetry/**/*'
|
@@ -6,6 +10,15 @@ AllCops:
|
|
6
10
|
SuggestExtensions: false
|
7
11
|
TargetRubyVersion: 3.2
|
8
12
|
|
13
|
+
# rubocop-fluentd
|
14
|
+
Lint/FluentdPluginLogScope:
|
15
|
+
Enabled: true
|
16
|
+
Lint/FluentdPluginConfigParamDefaultTime:
|
17
|
+
Enabled: true
|
18
|
+
Performance/FluentdPluginLogStringInterpolation:
|
19
|
+
Enabled: true
|
20
|
+
|
21
|
+
# rubocop
|
9
22
|
Gemspec/DevelopmentDependencies:
|
10
23
|
Enabled: false
|
11
24
|
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -34,6 +34,33 @@ To receive data, this plugin requires `<http>` or `<grpc>` section, or both.
|
|
34
34
|
|-----------|--------|----------------------|----------|
|
35
35
|
| tag | string | The tag of the event | required |
|
36
36
|
|
37
|
+
`tag` parameter supports `${type}` placeholder and it will be expanded with data type.
|
38
|
+
|
39
|
+
* log data
|
40
|
+
* `${type}` will be replaced to `logs`
|
41
|
+
* metric data
|
42
|
+
* `${type}` will be replaced to `metrics`
|
43
|
+
* trace data
|
44
|
+
* `${type}` will be replaced to `traces`
|
45
|
+
|
46
|
+
This can be used to change the output destination for each message type.
|
47
|
+
|
48
|
+
Example:
|
49
|
+
|
50
|
+
```
|
51
|
+
<source>
|
52
|
+
@type opentelemetry
|
53
|
+
|
54
|
+
# Expand to opentelemetry.logs, opentelemetry.metrics, opentelemetry.traces according to received data.
|
55
|
+
tag opentelemetry.${type}
|
56
|
+
|
57
|
+
<http>
|
58
|
+
bind 127.0.0.1
|
59
|
+
port 4318
|
60
|
+
</http>
|
61
|
+
</source>
|
62
|
+
```
|
63
|
+
|
37
64
|
#### `<http>` section
|
38
65
|
|
39
66
|
This requires to receive data via HTTP/HTTPS.
|
@@ -43,6 +43,8 @@ module Fluent::Plugin
|
|
43
43
|
def configure(conf)
|
44
44
|
super
|
45
45
|
|
46
|
+
expand_tag_placeholders(@tag)
|
47
|
+
|
46
48
|
if @grpc_config && !defined?(GRPC)
|
47
49
|
raise Fluent::ConfigError, "To use gRPC feature, please install grpc gem such as 'fluent-gem install grpc'."
|
48
50
|
end
|
@@ -59,13 +61,13 @@ module Fluent::Plugin
|
|
59
61
|
http_handler = Opentelemetry::HttpInputHandler.new
|
60
62
|
http_server_create_http_server(:in_opentelemetry_http_server, addr: @http_config.bind, port: @http_config.port, logger: log) do |serv|
|
61
63
|
serv.post("/v1/logs") do |req|
|
62
|
-
http_handler.logs(req) { |record| router.emit(
|
64
|
+
http_handler.logs(req) { |record| router.emit(tag_for(Opentelemetry::RECORD_TYPE_LOGS), Fluent::EventTime.now, { "type" => Opentelemetry::RECORD_TYPE_LOGS, "message" => record }) }
|
63
65
|
end
|
64
66
|
serv.post("/v1/metrics") do |req|
|
65
|
-
http_handler.metrics(req) { |record| router.emit(
|
67
|
+
http_handler.metrics(req) { |record| router.emit(tag_for(Opentelemetry::RECORD_TYPE_METRICS), Fluent::EventTime.now, { "type" => Opentelemetry::RECORD_TYPE_METRICS, "message" => record }) }
|
66
68
|
end
|
67
69
|
serv.post("/v1/traces") do |req|
|
68
|
-
http_handler.traces(req) { |record| router.emit(
|
70
|
+
http_handler.traces(req) { |record| router.emit(tag_for(Opentelemetry::RECORD_TYPE_TRACES), Fluent::EventTime.now, { "type" => Opentelemetry::RECORD_TYPE_TRACES, "message" => record }) }
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
@@ -75,17 +77,31 @@ module Fluent::Plugin
|
|
75
77
|
grpc_handler = Opentelemetry::GrpcInputHandler.new(@grpc_config, log)
|
76
78
|
grpc_handler.run(
|
77
79
|
logs: lambda { |record|
|
78
|
-
router.emit(
|
80
|
+
router.emit(tag_for(Opentelemetry::RECORD_TYPE_LOGS), Fluent::EventTime.now, { "type" => Opentelemetry::RECORD_TYPE_LOGS, "message" => record })
|
79
81
|
},
|
80
82
|
metrics: lambda { |record|
|
81
|
-
router.emit(
|
83
|
+
router.emit(tag_for(Opentelemetry::RECORD_TYPE_METRICS), Fluent::EventTime.now, { "type" => Opentelemetry::RECORD_TYPE_METRICS, "message" => record })
|
82
84
|
},
|
83
85
|
traces: lambda { |record|
|
84
|
-
router.emit(
|
86
|
+
router.emit(tag_for(Opentelemetry::RECORD_TYPE_TRACES), Fluent::EventTime.now, { "type" => Opentelemetry::RECORD_TYPE_TRACES, "message" => record })
|
85
87
|
}
|
86
88
|
)
|
87
89
|
end
|
88
90
|
end
|
89
91
|
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def expand_tag_placeholders(tag)
|
96
|
+
@expand_tag_placeholders ||= {
|
97
|
+
Opentelemetry::RECORD_TYPE_LOGS => tag.gsub(Opentelemetry::PLACEHOLDER_TYPE, Opentelemetry::PLACEHOLDER_TYPE_LOGS),
|
98
|
+
Opentelemetry::RECORD_TYPE_METRICS => tag.gsub(Opentelemetry::PLACEHOLDER_TYPE, Opentelemetry::PLACEHOLDER_TYPE_METRICS),
|
99
|
+
Opentelemetry::RECORD_TYPE_TRACES => tag.gsub(Opentelemetry::PLACEHOLDER_TYPE, Opentelemetry::PLACEHOLDER_TYPE_TRACES)
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
def tag_for(type)
|
104
|
+
@expand_tag_placeholders[type]
|
105
|
+
end
|
90
106
|
end
|
91
107
|
end
|
@@ -16,6 +16,11 @@ module Fluent::Plugin::Opentelemetry
|
|
16
16
|
RECORD_TYPE_METRICS = "opentelemetry_metrics"
|
17
17
|
RECORD_TYPE_TRACES = "opentelemetry_traces"
|
18
18
|
|
19
|
+
PLACEHOLDER_TYPE = "${type}"
|
20
|
+
PLACEHOLDER_TYPE_LOGS = "logs"
|
21
|
+
PLACEHOLDER_TYPE_METRICS = "metrics"
|
22
|
+
PLACEHOLDER_TYPE_TRACES = "traces"
|
23
|
+
|
19
24
|
TLS_VERSIONS_MAP =
|
20
25
|
begin
|
21
26
|
map = {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-opentelemetry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shizuo Fujita
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
|
-
rubygems_version: 3.
|
125
|
+
rubygems_version: 3.7.0
|
126
126
|
specification_version: 4
|
127
127
|
summary: Fluentd input/output plugin to forward OpenTelemetry Protocol data.
|
128
128
|
test_files: []
|