Skip to content

Subsegment name serialization causing MissingName error #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Jacob-Doetsch opened this issue Jul 28, 2019 · 5 comments
Closed

Subsegment name serialization causing MissingName error #168

Jacob-Doetsch opened this issue Jul 28, 2019 · 5 comments

Comments

@Jacob-Doetsch
Copy link

Jacob-Doetsch commented Jul 28, 2019

XRay Daemon reports the following error:

xray-daemon_1  | 2019-07-28T17:35:30Z [Info] Successfully sent batch of 1 segments (0.481 seconds)
xray-daemon_1  | 2019-07-28T17:35:30Z [Error] Unprocessed segment: {
xray-daemon_1  |   ErrorCode: "MissingName",
xray-daemon_1  |   Id: "3bdcccc4799c57fa",
xray-daemon_1  |   Message: "Invalid subsegment. ErrorCode: MissingName, Cause: null"
xray-daemon_1  | }
xray-daemon_1  | 2019-07-28T17:35:30Z [Warn] Batch that contains unprocessed segments

Simple setup. Django app, using middleware. setup includes:

XRAY_RECORDER = {
    'AWS_XRAY_DAEMON_ADDRESS': 'xray-daemon:2000',
    'AWS_XRAY_TRACING_NAME': 'TheNextBigThing',
    'AWS_XRAY_CONTEXT_MISSING': 'LOG_ERROR'
}

INSTALLED_APPS = [
    ...
    'aws_xray_sdk.ext.django',
]

MIDDLEWARE = [
    'aws_xray_sdk.ext.django.middleware.XRayMiddleware',
    ...
]

I think subsegments' subsegments' names are not being serialized correctly. Below is a snippet from the XRay Daemon payload.Notice the "name": {"py/newargs": ["core/snippets/ga.html"]} name of the subsegment, which should instead be a string according to the segment JSON schema.

    ...
    "subsegments": [
        {
            ...
            "in_progress": false,
            "name": "account/login.html",
            "namespace": "local",
            "parent_id": "c572ac3f20a195dc",
            "subsegments": [
                {
                    "id": "69ef19799fec25ba",
                    "in_progress": false,
                    "name": {
                        "py/newargs": [
                            "core/snippets/ga.html"
                        ]
                    },
                    "namespace": "local",
                    "parent_id": "5ecd89473a50fa17",
                    "type": "subsegment"
                },
                ...
            ]
            ...
        }        

All SDK versions between 2.0.1 and 2.4.2 were tested and have the same issue. Same issue on Python 3.6 and 3.7 as well. Django version is 2.2.3.

@chanchiem
Copy link
Contributor

Hey,

What framework are you instrumenting that's generating the subsegments? The Django Middleware is instrumented to generate Segments only. It seems like whatever's generating the subsegment is where the issue is. Is there a code snippet you can provide that pinpoints what method call within your application is causing this?

Additionally, what environment are you running this in?

@carlosequiz
Copy link

Hi there, we're facing this same issue with the following environment:

  • Python 3.6
  • Django 2.2.4
  • AWS X-Ray SDK for Python 2.4.2
2019-08-26T17:00:13-05:00 [Info] Starting proxy http server on 127.0.0.1:2000
2019-08-26T17:00:48-05:00 [Info] Successfully sent batch of 1 segments (0.959 seconds)
2019-08-26T17:00:48-05:00 [Error] Unprocessed segment: {
  ErrorCode: "MissingName",
  Id: "21af4546239e7f04",
  Message: "Invalid subsegment. ErrorCode: MissingName, Cause: null"
}
2019-08-26T17:00:48-05:00 [Warn] Batch that contains unprocessed segments
...
 "subsegments": [
                    {
                        "end_time": 1566856846.909555,
                        "id": "0b885a8b68313afb",
                        "in_progress": false,
                        "name": {
                            "py/newargs": [
                                "django/forms/widgets/input.html"
                            ]
                        },
                        "namespace": "local",
                        "parent_id": "e2237ca35baf93a3",
                        "start_time": 1566856846.9052658,
                        "subsegments": [
                            {
                                "end_time": 1566856846.909373,
                                "id": "9c2682f6748e665f",
                                "in_progress": false,
                                "name": {
                                    "py/newargs": [
                                        "django/forms/widgets/attrs.html"
                                    ]
                                },
                                "namespace": "local",
                                "parent_id": "0b885a8b68313afb",
                                "start_time": 1566856846.908428,
                                "trace_id": "1-5d64568e-e49d15dd35b08a1b4ba7ade6",
                                "type": "subsegment"
                            }
                        ],
                        "trace_id": "1-5d64568e-e49d15dd35b08a1b4ba7ade6",
                        "type": "subsegment"
                    }
                ],
...

@chanchiem
Copy link
Contributor

Hmmm interesting, it looks like the issue you're having is exactly the same. @crustafari, can you provide your minimal X-Ray configuration information? I can't seem to reproduce this issue on my end.

Also, what environment are you running this in? Is this in Lambda? If this is in a regular desktop environment, this confuses me because Django should be generating segments, not subsegments. It only generates subsegments if you're using a Serverless architecture (API Gateway -> Lambda).

@Jacob-Doetsch
Copy link
Author

My environment is a Django 2.2.3 app in a Docker container running locally, with the xray daemon running in a separate container.

@chanchiem
Copy link
Contributor

We don't currently support versions of Django > 2 yet. It's in our backlog to add support for it as it has been a customer ask #10. Which probably makes sense why we're seeing these errors. There has probably been some major changes to Django that has caused it to not work with our current Django patcher. A PR is always welcome and we could provide guidance. In the mean time please stay tuned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants