0.3.0 • Published 3 years ago

epsagon-cdk v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Epsagon Tracing for CDKs

This package provides distributed tracing for Infrastructure as Code applications using Epsagon.

Contents

Installation

Epsagon CDK is available under a variety of languages.

TypeScript & JavaScript

$ npm i epsagon-cdk

Python

$ pip install epsagon-cdk

Usage

Configuration options available at Configurations

@aws-cdk

Initialize the Tracer right inside your function declaration.

Typescript

Replace @aws-cdk-lambda.Function with epsagon-cdk.LambdaFunction and add your Epsagon configuration directly to your function options.

import { LambdaFunction, LambdaSingletonFunction } from 'epsagon-cdk'

new LambdaFunction(this, '<FUNC-ID>', {

    /*  function options  */
    functionName: '<FUNC-NAME>',
    runtime: lambda.Runtime.<RUNTIME>,
    code: lambda.Code.fromAsset(path.join(__dirname, '/PATH/TO/FUNC/DIR')),
    handler: '<HANDLER>',

    /*  epsagon tracing config  */
    token: '<EPSAGON-TOKEN>',
    appName: '<EPSAGON-APP-NAME-STAGE>',
    metadataOnly: <BOOL>,
    debug: <BOOL>,
    disable: <BOOL>,
}); 

LambdaFunction adds Epsagon as a dependency during bundle-time, increasing package size by no more than 1MB.

lambda.Runtimes supported:

  • Runtime.PYTHON
  • Runtime.NODEJS

lambda.Codes supported:

  • Code.InlineCode
  • Code.AssetCode

Terraform

Note: No NPM/PIP install is requred.

Replace

aws_lambda_function 

with epsagon's function module at

github.com/epsagon/epsagon-cdk/lib/contrib/terraform

(hint: you can copy and paste)

verify your archive file

data "archive_file" "<DEPLOYMENT>" {
  type        = "zip"
  output_path = "${path.module}/PATH/TO/DEPLOYMENT.zip"
  source_dir  = "${path.module}/PATH/TO/DEPLOYMENT_DIR"
}

and simply add your Epsagon configuration directly to your function options.

module "epsagon_function" {

    /*  EPSAGON MODULE SOURCE  */
    source = "github.com/epsagon/epsagon-cdk/lib/contrib/terraform"
  
    /*  FUNC CONFIG  */
    function_name = "<FUNC-NAME>"
    handler       = "<HANDLER>"
    runtime       = "RUNTIME"
    role          = aws_iam_role.<ROLE>.arn
    timeout       = TIMEOUT

    /*  ARCHIVE CONFIG  */
    /* add the source_dir of the archive */
    source_dir       = data.archive_file.lambda_zip.source_dir
    filename         = data.archive_file.DEPLOYMENT.output_path
    source_code_hash = data.archive_file.DEPLOYMENT.output_base64sha256
  

    /*  EPSAGON CONFIG  */
    token         = "<EPSAGON-TOKEN>"
    app_name      = "<APP-NAME-STAGE>"
    debug         = <BOOL>
    metadata_only = <BOOL>
}

Integrations

The following Cloud Development Kits are supported by Epsagon.

IaCSupported Version
@aws-cdkall
Terraformall

Configuration

Advanced options can be configured when declaring Epsagon resources.

ParameterTypeDefaultDescription
tokenstring-The User's Epsagon Account Token
appNamestringEpsagon ApplicationApplication the function belongs to.
metadataOnlybooleantrueWhether to capture Only Metadata. Set to false to capture entire payloads.
debugbooleanfalseWhether to print debug logs. Set to true to output logs, and false to not.
disablebooleanfalseWether to disable Epsagon tracing. Set to true to disable, and false to enable.
collectorURLstringtcYou should know what you are doing.