Skip to content
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

[Bug] go agent http plugin response 500 status but not set span error #12882

Open
2 of 3 tasks
alexwn opened this issue Dec 20, 2024 · 30 comments
Open
2 of 3 tasks

[Bug] go agent http plugin response 500 status but not set span error #12882

alexwn opened this issue Dec 20, 2024 · 30 comments
Assignees
Labels
agent Language agent related. bug Something isn't working and you are sure it's a bug! go Go agent
Milestone

Comments

@alexwn
Copy link

alexwn commented Dec 20, 2024

Search before asking

  • I had searched in the issues and found no similar issues.

Apache SkyWalking Component

Go Agent (apache/skywalking-go)

What happened

The HTTP request returns a status code of 4xx or 5xx, but the span is not marked as an error in the Skywalking UI

What you expected to happen

  1. When the HTTP request returns a status code of 4xx or 5xx, span is marked as an error
  2. The Skywalking Go toolkit provides a method to manually set whether the span is incorrect, for example: trace.Error(err)

How to reproduce

Use the native HTTP server of Go to process requests. When the HTTP status returned by the request is 4xx or 5xx, span will not be marked as an error

Anything else

No response

Are you willing to submit a pull request to fix on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

@alexwn alexwn added the bug Something isn't working and you are sure it's a bug! label Dec 20, 2024
@wu-sheng
Copy link
Member

@alexwn Are you going to submit a pull request to add this?

I can see the status code tag is set, but no status is set.
https://github.com/apache/skywalking-go/blob/988702ef41b9d9075ff060b5bba54d97a94fab9c/plugins/http/server_intercepter.go#L61

@wu-sheng wu-sheng added agent Language agent related. go Go agent labels Dec 20, 2024
@wu-sheng wu-sheng added this to the Go - 0.6.0 milestone Dec 20, 2024
@mrproliu
Copy link
Contributor

When the HTTP request returns a status code of 4xx or 5xx, span is marked as an error.

For now, the Go agent only sets the response status code into the span as a tag. Can you check if the tag is in the error span? Then I think we can set the error when the response status code is bigger or equals 400.

The Skywalking Go toolkit provides a method to manually set whether the span is incorrect, for example: trace.Error(err)

It can be added.

@alexwn
Copy link
Author

alexwn commented Dec 20, 2024

1、I'm not sure I can fix it
2、http status code is set, but span error flag is false, see the attach file
skywalking-go-error

@alexwn
Copy link
Author

alexwn commented Dec 20, 2024

maybe like this:
image

@wu-sheng
Copy link
Member

Yes, the plugin codes should be like this. The toolkit needs more changes, but still be easy. Add a method in the toolkit and add a new interceptor for that.

@mrproliu
Copy link
Contributor

There is an Error method in the span. You can use this directly. But if the parameters are empty, it may cause an error (the Error method will invoke Log to add the log from the parameter). You could add a check in the Log method.

@wu-sheng
Copy link
Member

I think we should expose a new error for that.

@mrproliu
Copy link
Contributor

mrproliu commented Dec 20, 2024

Sure. @alexwn would you like to fix this issue?

@alexwn
Copy link
Author

alexwn commented Dec 20, 2024

ok, I'd like to try to fix it, I haven't done this before, if I have any questions, hope you can help me. -_-
this bugfix at 0.5.0 Tag?

@mrproliu
Copy link
Contributor

this bugfix at 0.6.0 tag. If you have any questions, you can leave a message here.

@wu-sheng
Copy link
Member

Your codes will go straight into main branch and included in the 0.6 release after merged.

@alexwn
Copy link
Author

alexwn commented Dec 20, 2024

get it

@alexwn
Copy link
Author

alexwn commented Dec 20, 2024

image
I want to add a func to toolkit like trace.Error(...string), this method invoke current active span's Error(...string) method, to set span error. But in toolkit/trace/api.go all method is empty. My question is how should I add the trace.Error(...string) method implementation.

@mrproliu
Copy link
Contributor

mrproliu commented Dec 20, 2024

You can add a new method interceptor following this documentation. And the toolkit-related plugin is under this directory: https://github.com/apache/skywalking-go/tree/main/plugins/toolkit-activation/trace.

@alexwn
Copy link
Author

alexwn commented Dec 20, 2024

image
image
Is that OK like this? How should I test this?

@mrproliu
Copy link
Contributor

@wu-sheng
Copy link
Member

Toolkit should have test scenarios included, you could follow the docs, and add new tests for your new methods.

@alexwn
Copy link
Author

alexwn commented Dec 21, 2024

image
execute runs.sh http, throw some error, I don't know what should I do

@CodePrometheus
Copy link
Contributor

image execute runs.sh http, throw some error, I don't know what should I do

Please use v4.x version of yq https://github.com/mikefarah/yq/releases.

@alexwn
Copy link
Author

alexwn commented Dec 21, 2024

image execute runs.sh http, throw some error, I don't know what should I do

Please use v4.x version of yq https://github.com/mikefarah/yq/releases.

ok, resolved

@alexwn
Copy link
Author

alexwn commented Dec 21, 2024

image
pending here long time, is there any problem?

@wu-sheng
Copy link
Member

This is pulling docker image from github image repo(ghcr.io). Please check whether you need some proxy?

@alexwn
Copy link
Author

alexwn commented Dec 21, 2024

image
image
I set the docker registry mirrors, but still access "https://registry-1.docker.io/v2/", what should I do?

@wu-sheng
Copy link
Member

Sorry, I don't know that. I don't need docker proxy. And docker.io is different from ghcr.io repo. ghcr.io is hosted by GitHub.

https://github.com/apache/skywalking-agent-test-tool/pkgs/container/skywalking-agent-test-tool%2Fmock-collector

@alexwn
Copy link
Author

alexwn commented Dec 21, 2024

I can access ghcr.io, although it's a little slow. I have pulled this image.
image
but next step "building service" to access "https://registry-1.docker.io/v2/", this is a big problem, I can't access this site at my home and my office.
image

@alexwn
Copy link
Author

alexwn commented Dec 22, 2024

图片
I have executed command "test/plugins/run.sh http" success two times, and I modify this expected.yml, and execute run.sh again, throw this error
图片
What should I do?

@mrproliu
Copy link
Contributor

If you have updated the interceptor code, I think the iserror should be updated to true in the span?
iserror field means the span contains an error or not. When you invoke span.Error(), the agent would mark this field(iserror) as true.

@alexwn
Copy link
Author

alexwn commented Dec 22, 2024

If you have updated the interceptor code, I think the iserror should be updated to true in the span? iserror field means the span contains an error or not. When you invoke span.Error(), the agent would mark this field(iserror) as true.
I already set this isError by span.Error() method, and I already excute "./run.sh http" command success two times, but execute the third times and more, always fail.
I think it's script's or env or something error, I don't know, the error message is "/bin/sh -c go mod tidy" failed
图片

@mrproliu
Copy link
Contributor

If the go mod tidy triggers the error, I think it's related to the network issue. You can create a PR for the skywalking-go project, the CI will check all the plugins.

@wu-sheng
Copy link
Member

Relative PR apache/skywalking-go#212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent Language agent related. bug Something isn't working and you are sure it's a bug! go Go agent
Projects
None yet
Development

No branches or pull requests

4 participants