Sha256: 501ae2e5974e12c807affa879f6a9bbdda395c460ca728815782a639d9a5da23
Contents?: true
Size: 1.43 KB
Versions: 14
Compression:
Stored size: 1.43 KB
Contents
# (c) Copyright IBM Corp. 2021 # (c) Copyright Instana Inc. 2021 require 'base64' module Instana module Instrumentation class Lambda < Seahorse::Client::Plugin class Handler < Seahorse::Client::Handler def call(context) return @handler.call(context) unless [:invoke_async, :invoke].include?(context.operation_name) if context.params[:client_context].nil? && ::Instana.tracer.tracing? && context.operation_name == :invoke span_context = ::Instana.tracer.context payload = { 'X-INSTANA-T' => span_context.trace_id, 'X-INSTANA-S' => span_context.span_id, 'X-INSTANA-L' => span_context.level.to_s } context.params[:client_context] = Base64.strict_encode64(JSON.dump(payload)) end tags = { function: context.params[:function_name], type: context.params[:invocation_type] }.reject { |_, v| v.nil? } ::Instana.tracer.start_or_continue_trace(:"aws.lambda.invoke", {aws: {lambda: {invoke: tags}}}) do response = @handler.call(context) if response.respond_to? :status_code ::Instana.tracer.log_info(:http => {:status => response.status_code }) end response end end end def add_handlers(handlers, _config) handlers.add(Handler, step: :initialize) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems