go-datadog-apm

module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2025 License: MIT

README

Golang Datadog APM package with traces and a connected logger

Go Report Card workflow ci

Description

This package makes it possible to add Datadog spans to your code and connect logs to your traces inside datadog based on the following parts:

  • Datadog tracer
  • Zap logger

Usage

go get github.com/YourSurpriseCom/go-datadog-apm

import(
    github.com/YourSurpriseCom/go-datadog-apm/apm
)

apm := apm.NewApm()
currentContext := context.Background()

//Start a span
span, spanContext := apm.StartSpanFromContext(currentContext, "GetSignedUrl")
defer span.Finish()

//Create debug log message
apm.Logger.Debug(spanContext, "This log message will be linked to the span based on the spanContext")

Configuration

The log level can be configure by setting the environment variable LOG_LEVEL with the following values:

  • debug
  • info
  • warning
  • fatal

When not set, it will fall back to the value info

Serverless Config

To use the Serverless Datadog agent, build the application based on the following Dockerfile.

FROM    alpine:3.20
ARG     ARG_VERSION=dev
    
ENV     DD_VERSION=${ARG_VERSION}
ENV     DD_SITE=datadoghq.eu
    
COPY --from=datadog/serverless-init:1.2.8-alpine /datadog-init /datadog/datadog-init
COPY --from=builder /go/bin/main /go/bin/main

ENTRYPOINT ["/datadog/datadog-init"]

CMD ["/go/bin/main"]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL