Skip to content

Spans covering calls to DynamoDB fail because Name isn't set #1088

@knechtionscoding

Description

@knechtionscoding

Describe the bug: ...
When making calls to DynamoDB using Boto3 in a flask app the spans don't have a destination name set resulting in an error when posting to the APM server.

To Reproduce

  1. Create a basic flask app
  2. Make a call to dynamoDB
  3. Error from APM when shipping spans over

Environment (please complete the following information)

  • OS: Linux
  • Python version: 3.8.5
  • Framework and version [e.g. Django 2.1]: Flask 1.1.2
  • APM Server version: 7.10.0
  • Agent version: >6.0.0

Additional context

Add any other context about the problem here.

  • Agent config options

    Click to expand
    No specific configuration other than server URL, and token.
    
  • requirements.txt:

    Click to expand
    # Flask
    marshmallow==3.7.1
    flask-marshmallow==0.13.0
    flask==1.1.2
    gunicorn==20.0.4
    blinker==1.4
    requests==2.24.0
    
    # Integrations
    bugsnag>=3.7.1
    prometheus_client>=0.8.0
    elastic-apm[flask]>=6.0.0
    boto3==1.14.32
    
    # Utils
    isodate==0.6.0
    pytz==2020.4
    stringcase==1.2.0
    
    
  • Example response:

    {
      "message": "validation error: span: context: destination: service: 'name' required",
      "document": {
        "span": {
          "id": "<id>",
          "transaction_id": "<transaction_id>",
          "trace_id": "<trace_id>",
          "parent_id": "<parent_id>",
          "name": "DynamoDB DescribeTable <table_name>",
          "type": "db",
          "subtype": "dynamodb",
          "action": "query",
          "timestamp": 1617326270249910,
          "duration": 32.70153599999048,
          "outcome": "success",
          "sample_rate": 1.0,
          "context": {
            "destination": {
              "address": "localhost",
              "port": 8000,
              "cloud": {
                "region": "true"
              },
              "name": "dynamodb",
              "resource": "<resource_name>",
              "service": {
                "type": "db"
              }
            },
            "db": {
              "type": "dynamodb",
              "instance": "true"
            }
          },
          "stacktrace": [
          ]
        }
      }
    }
    
  • example log from the apm server side:

{"log.level":"error","@timestamp":"2021-04-07T13:18:19.935Z","log.logger":"request","log.origin":{"file.name":"middleware/log_middleware.go","file.line":60},"message":"data validation error","url.original":"/intake/v2/events","http.request.method":"POST","user_agent.original":"elasticapm-python/6.1.0","source.address":"34.86.85.118","http.request.body.bytes":3851,"http.request.id":"408d9e15-02d1-4aa9-ab26-4d99cb0f8d96","event.duration":1093327,"http.response.status_code":400,"error.message":"validation error: span: context: destination: service: 'name' required, validation error: span: context: destination: service: 'name' required","ecs.version":"1.6.0"}

Relevant lines from the apm package: https://github.com/elastic/apm-agent-python/blob/master/elasticapm/instrumentation/packages/botocore.py#L122

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions