@@ -32,6 +32,11 @@ def close
3232class Fluent ::Plugin ::Opentelemetry ::HttpInputHandler
3333 using Fluent ::PluginHelper ::HttpServer ::Extension
3434
35+ def initialize ( http_config , logger )
36+ @http_config = http_config
37+ @logger = logger
38+ end
39+
3540 def logs ( req , &block )
3641 common ( req , Fluent ::Plugin ::Opentelemetry ::Request ::Logs , Fluent ::Plugin ::Opentelemetry ::Response ::Logs , &block )
3742 end
@@ -53,12 +58,20 @@ def common(req, request_class, response_class)
5358 return response_unsupported_media_type unless valid_content_type? ( content_type )
5459 return response_bad_request ( content_type ) unless valid_content_encoding? ( content_encoding )
5560
56- body = Zlib ::GzipReader . new ( StringIO . new ( body ) ) . read if content_encoding == Fluent ::Plugin ::Opentelemetry ::CONTENT_ENCODING_GZIP
61+ if content_encoding == Fluent ::Plugin ::Opentelemetry ::CONTENT_ENCODING_GZIP
62+ begin
63+ body = Zlib ::GzipReader . new ( StringIO . new ( body ) ) . read
64+ rescue Zlib ::Error => e
65+ @logger . warn { "Failed to decompress gzip payload: #{ e . message } " }
66+ return response_bad_request ( content_type )
67+ end
68+ end
5769
5870 begin
5971 record = request_class . new ( body ) . record
60- rescue Google ::Protobuf ::ParseError
72+ rescue Google ::Protobuf ::ParseError => e
6173 # The format in request body does not comply with the OpenTelemetry protocol.
74+ @logger . warn { "Failed to parse OpenTelemetry payload: #{ e . message } " }
6275 return response_bad_request ( content_type )
6376 end
6477
0 commit comments