File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ # Unless explicitly stated otherwise all files in this repository are licensed
2+ # under the Apache License Version 2.0.
3+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
4+ # Copyright 2020 Datadog, Inc.
5+
6+ from __future__ import absolute_import
7+ from importlib import import_module
8+
9+ import os
10+ from datadog_lambda .wrapper import datadog_lambda_wrapper
11+
12+
13+ class HandlerError (Exception ):
14+ pass
15+
16+
17+ path = os .environ .get ("DD_LAMBDA_HANDLER" , None )
18+ if path is None :
19+ raise HandlerError (
20+ "DD_LAMBDA_HANDLER is not defined. Can't use prebuilt datadog handler"
21+ )
22+ parts = path .rsplit ("." , 1 )
23+ if len (parts ) != 2 :
24+ raise HandlerError ("Value %s for DD_LAMBDA_HANDLER has invalid format." % path )
25+
26+ (mod_name , handler_name ) = parts
27+ handler_module = import_module (mod_name )
28+ handler = datadog_lambda_wrapper (getattr (handler_module , handler_name ))
You can’t perform that action at this time.
0 commit comments