Skip to content

Commit fd270b7

Browse files
committed
fix style
1 parent ba3aa9f commit fd270b7

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

lib/fluent/plugin/in_otlp.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ def start
9292
handler = HttpHandler.new
9393
http_server_create_http_server(:in_otel_http_server_helper, addr: @http_config.bind, port: @http_config.port, logger: log) do |serv|
9494
serv.post("/v1/logs") do |req|
95-
handler.logs(req) { |record| router.emit(@tag, Fluent::EventTime.now, { type: "otlp_logs", message: record }) }
95+
handler.logs(req) { |record| router.emit(@tag, Fluent::EventTime.now, { type: Otlp::RECORD_TYPE_LOGS, message: record }) }
9696
end
9797
serv.post("/v1/metrics") do |req|
98-
handler.metrics(req) { |record| router.emit(@tag, Fluent::EventTime.now, { type: "otlp_metrics", message: record }) }
98+
handler.metrics(req) { |record| router.emit(@tag, Fluent::EventTime.now, { type: Otlp::RECORD_TYPE_METRICS, message: record }) }
9999
end
100100
serv.post("/v1/traces") do |req|
101-
handler.traces(req) { |record| router.emit(@tag, Fluent::EventTime.now, { type: "otlp_traces", message: record }) }
101+
handler.traces(req) { |record| router.emit(@tag, Fluent::EventTime.now, { type: Otlp::RECORD_TYPE_TRACES, message: record }) }
102102
end
103103
end
104104
end

lib/fluent/plugin/otlp/constant.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ module Fluent::Plugin::Otlp
66
CONTENT_TYPE_JSON = "application/json"
77

88
CONTENT_ENCODING_GZIP = "gzip"
9+
10+
RECORD_TYPE_LOGS = "otlp_logs"
11+
RECORD_TYPE_METRICS = "otlp_metrics"
12+
RECORD_TYPE_TRACES = "otlp_traces"
913
end

lib/fluent/plugin/out_otlp.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def format(tag, time, record)
4343
end
4444

4545
def write(chunk)
46-
uri, req = create_request(chunk)
46+
uri, req = create_uri_request(chunk)
4747

4848
Net::HTTP.start(uri.host, uri.port) do |http|
4949
http.request(req)
@@ -52,18 +52,18 @@ def write(chunk)
5252

5353
private
5454

55-
def create_request(chunk)
55+
def create_uri_request(chunk)
5656
record = JSON.parse(chunk.read)
5757
msg = record["message"]
5858

5959
case record["type"]
60-
when "otlp_logs"
60+
when Otlp::RECORD_TYPE_LOGS
6161
uri = HTTP_LOGS_ENDPOINT
6262
body = Otlp::Request::Logs.new(msg).encode
63-
when "otlp_metrics"
63+
when Otlp::RECORD_TYPE_METRICS
6464
uri = HTTP_METRICS_ENDPOINT
6565
body = Otlp::Request::Metrics.new(msg).encode
66-
when "otlp_traces"
66+
when Otlp::RECORD_TYPE_TRACES
6767
uri = HTTP_TRACES_ENDPOINT
6868
body = Otlp::Request::Traces.new(msg).encode
6969
end

0 commit comments

Comments
 (0)