Skip to content

Commit 7ce2803

Browse files
committed
add constant
1 parent 7f97621 commit 7ce2803

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

lib/fluent/plugin/in_otlp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def valid_content_encoding?(content_encoding)
9595
end
9696

9797
def response(code, content_type, body)
98-
[code, { "Content-Type" => content_type }, body]
98+
[code, { Otlp::CONTENT_TYPE => content_type }, body]
9999
end
100100

101101
def response_unsupported_media_type

lib/fluent/plugin/otlp/constant.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
require "openssl"
55

66
module Fluent::Plugin::Otlp
7+
CONTENT_TYPE = "Content-Type"
78
CONTENT_TYPE_PAIN = "text/plain"
89
CONTENT_TYPE_PROTOBUF = "application/x-protobuf"
910
CONTENT_TYPE_JSON = "application/json"
1011

12+
CONTENT_ENCODING = "Content-Encoding"
1113
CONTENT_ENCODING_GZIP = "gzip"
1214

1315
RECORD_TYPE_LOGS = "otlp_logs"

lib/fluent/plugin/out_otlp.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ def create_connection(chunk)
107107
raise ::Fluent::UnrecoverableError, e.message
108108
end
109109

110-
headers = { "Content-Type" => Otlp::CONTENT_TYPE_PROTOBUF }
110+
headers = { Otlp::CONTENT_TYPE => Otlp::CONTENT_TYPE_PROTOBUF }
111111
if @compress == :gzip
112-
headers["Content-Encoding"] = Otlp::CONTENT_ENCODING_GZIP
112+
headers[Otlp::CONTENT_ENCODING] = Otlp::CONTENT_ENCODING_GZIP
113113
gz = Zlib::GzipWriter.new(StringIO.new)
114114
gz << body
115115
body = gz.close.string

0 commit comments

Comments
 (0)