DataDog / datadog-lambda-go

The Datadog AWS Lambda package for Go
Apache License 2.0
59 stars 40 forks source link

Add support for tracing #44

Closed nhinsch closed 4 years ago

nhinsch commented 4 years ago

What does this PR do?

Adds support for tracing.

Motivation

Customers want to instrument Go Lambda functions for use with Datadog APM.

Testing Guidelines

Integration tests and manual testing.

Types of changes

Checklist

codecov-io commented 4 years ago

Codecov Report

Merging #44 into master will decrease coverage by 1.92%. The diff coverage is 24.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #44      +/-   ##
==========================================
- Coverage   84.44%   82.52%   -1.93%     
==========================================
  Files          12       12              
  Lines         540      555      +15     
==========================================
+ Hits          456      458       +2     
- Misses         63       81      +18     
+ Partials       21       16       -5     
Impacted Files Coverage Δ
internal/trace/listener.go 0.00% <0.00%> (ø)
ddlambda.go 80.00% <100.00%> (+3.72%) :arrow_up:
internal/trace/context.go 87.15% <100.00%> (+0.24%) :arrow_up:
internal/metrics/processor.go 93.75% <0.00%> (-3.13%) :arrow_down:
internal/metrics/listener.go 96.29% <0.00%> (+23.79%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e683acf...4ce82c5. Read the comment docs.

xrn commented 3 years ago

Hi @nhinsch @DarcyRaynerDD

I would like to ask, are you sure that this is working? From tests, I see that it is generating trace_id as hex

{
    "traces": [
        [
            {
                "trace_id": "6fb744bf13869d00",
                "span_id": "1e8538262a43c188",
                "parent_id": "1e5df70157538a8e",
                "name": "aws.lambda",

And traces are not connecting with logs - https://docs.datadoghq.com/tracing/connect_logs_and_traces/ - because Datadog is making query like @lambda.request_id:(fe757c85-ef6f-4c09-8e24-ca5a16edbdae) OR trace_id:8049978446405082368 (converted hex to uint64 is giving correct value). Also reading documentation https://docs.datadoghq.com/api/v1/tracing/#send-traces looks like DataDog is expecting trace_id as uint64

Even in this PR we can find

fmt.Println("Current trace ID: " + strconv.FormatUint(currentSpanContext.TraceID(), 10))

Bottom line: In current Hex format traces are not connected to Logs - it should be fixed and send as uint64

What do you think? Or maybe I am doing something wrong