Thundra

Thundra: Serverless Observability for AWS Lambda

The black box nature of AWS Lambda and other serverless environments means that identifying and fixing performance issues is difficult and time-consuming. Built for straightforward debugging, monitoring, and observability, Thundra provides deep insight into your entire serverless environment. Thundra collects and correlates all your metrics, logs, and traces, allowing you to quickly identify problematic invocations and also analyzes external services associated with that function. With Thundra’s zero overhead and automated instrumentation capabilities, your developers are free to write code without worrying about bulking up their Lambdas or wasting time on chasing black box problems.

Get Started    Discussions

Log Support

Thundra provides a logger that you can access through the thundra.Logger. The logs that you will create using this logger will be available in Thundra web console under the corresponding invocation.

thundra.Logger is just a wrapper on the Go's log package. That's why the methods of thundra.Logger is very similar to the log package methods.

Log methods that you can use with thundra.Logger:

  • Trace(v ...interface{})
  • TraceWithSpan(span opentracing.Span, v ...interface{})
  • Debug(v ...interface{})
  • DebugWithSpan(span opentracing.Span, v ...interface{})
  • Info(v ...interface{})
  • InfoWithSpan(span opentracing.Span, v ...interface{})
  • Warn(v ...interface{})
  • WarnWithSpan(span opentracing.Span, v ...interface{})
  • Error(v ...interface{})
  • ErrorWithSpan(span opentracing.Span, v ...interface{})
  • Printf(format string, v ...interface{})
  • Print(v ...interface{})
  • Println(v ...interface{})
  • Panic(v ...interface{})
  • Panicln(v ...interface{})
  • Panicf(format string, v ...interface{})

These log methods work in the same way as Go's log package methods. The only difference is that we have some extra methods with the name pattern "*WithSpan". These methods accept an extra span parameter. If you log using these methods, you will be able to see your log under the corresponding span in Thundra web console. Otherwise, your logs will be available under the Invocation Logs tab and they won't be bound to a specific span but the invocation itself.

The following code snippet shows the usage of thundra.Log.

package main

import (
	"context"
	"time"

	"github.com/aws/aws-lambda-go/lambda"
	opentracing "github.com/opentracing/opentracing-go"
	"github.com/thundra-io/thundra-lambda-agent-go/thundra"
)

// Your main lambda handler
func handler(ctx context.Context) (string, error) {
	// Log without span
	thundra.Logger.Info("This is an info log")
	// Call another function
	firstFunction(ctx)

	return "Hello ƛ!", nil
}

func firstFunction(ctx context.Context) {
	span, _ := opentracing.StartSpanFromContext(ctx, "childSpan")
	defer span.Finish()
	// Log using a span
	thundra.Logger.WarnWithSpan(span, "This a warning log")
	time.Sleep(time.Millisecond * 100)
}

func main() {
	// Wrap your lambda handler with Thundra
	lambda.Start(thundra.Wrap(handler))
}

As we have stated, regardless of which log method you have used, all the logs that you have created using thundra.Logger will be available under the Invocation Log tabs.

Moreover, you can also view the logs that you have created using one of the *WithSpan methods, under the corresponding span's Logs tab.

Configuration

You can configure the log plugin using the following environment variables.

thundra_agent_lambda_log_disable

Set this true if you want to disable the log plugin. By default, log plugin is enabled.

thundra_log_logLevel

Set this to log level you want. By default, all the logs are reported.

See the configuration variables section, for all the configuration variables.