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

file bytes uploading error in jaeger: span too large to send #2628

Closed
LiuShuKu opened this issue May 7, 2023 · 35 comments
Closed

file bytes uploading error in jaeger: span too large to send #2628

LiuShuKu opened this issue May 7, 2023 · 35 comments
Labels
done This issue is done, which may be release in next version. enhancement

Comments

@LiuShuKu
Copy link

LiuShuKu commented May 7, 2023

1. What version of Go and system type/arch are you using?

go 1.19

2. What version of GoFrame are you using?

2.4.1

问题描述:

外部接口返回了一个 []byte。将[]byte 转换为 formData 文件、然后上传、就会出现 **2023/05/07 17:59:33 multiple errors during transform: span too large to send: ** 这个错误;

流程:

调用BytesToFormData() 后执行 g.Client().ContentType(contentType).PostVar(gctx.New(), requestURL, data) 大概过1-3秒左右就会报错
但是文件能正常的上传、只是jaeger报错。

ps: 上传接口就是个简单的上传;

以下是byte数组转FormData 函数

func (f *file) BytesToFormData(data []byte, fieldName string, fileNames ...string) (err error, formDataContentType string, formData *bytes.Buffer) {

	var (
		fileName string
		formFile io.Writer
		writer   *multipart.Writer
	)
	// 文件名
	{
		if len(fileNames) > 0 {
			fileName = fileNames[0]
		} else {
			fileName = "file.jpg"
		}
	}
	// 初始化 FormFile
	{
		formData = new(bytes.Buffer)
		writer = multipart.NewWriter(formData)
		formFile, err = writer.CreateFormFile(fieldName, fileName)
		if err != nil {
			err = gerror.Wrap(err, "初始化文件失败")
			return
		}
	}
	// 拷贝文件
	{
		_, err = io.Copy(formFile, bytes.NewReader(data))
		if err != nil {
			err = gerror.Wrap(err, "拷贝文件失败")
			return
		}
	}
	// 类型
	{
		formDataContentType = writer.FormDataContentType()
		err = writer.Close()
		if err != nil {
			err = gerror.Wrap(err, "关闭输出对象失败")
			return
		}
	}
	return
}

解决办法尝试过:

1 .尝试过将当前链路上所有的ctx都变成 gctx.New() --> 不管用

  1. 尝试过 defer tp.shutdown(ctx) 不管用;
@houseme
Copy link
Member

houseme commented May 7, 2023

上传的文件大小是多少M?

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


What is the size of the uploaded file in M?

@LiuShuKu
Copy link
Author

LiuShuKu commented May 7, 2023

不到1M

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Less than 1M

@zcyc
Copy link
Contributor

zcyc commented May 11, 2023

试试在配置文件的 server 节点下添加如下配置
clientMaxBodySize = "200MB"

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Try adding the following configuration under the server node of the configuration file
clientMaxBodySize = "200MB"

@LiuShuKu
Copy link
Author

不是这个问题追踪到里面去,发现span标签的大小超过Jaeger的限制

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It’s not that this problem was traced inside, and it was found that the size of the span tag exceeded the limit of Jaeger

@houseme
Copy link
Member

houseme commented May 11, 2023

不是这个问题追踪到里面去,发现span标签的大小超过Jaeger的限制

把整体错误日志内容贴一下,以及控制器方法代码也贴一下

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It is not this problem that was traced to it and found that the size of the span tag exceeds the limit of Jaeger

Post the content of the overall error log, and the code of the controller method

@LiuShuKu
Copy link
Author

目前已经改为标准库的http了,现在没有问题了;
使用g.Client的方法进行请求。data为[]byte 就会出现问题,您可以简单的测试一下

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


At present, it has been changed to http in the standard library, and there is no problem now;
Use the method of g.Client to make a request. There will be problems if the data is []byte, you can simply test it

@houseme
Copy link
Member

houseme commented May 11, 2023

目前已经改为标准库的http了,现在没有问题了; 使用g.Client的方法进行请求。data为[]byte 就会出现问题,您可以简单的测试一下

大概指导原因了,要不提 pr 修复一下,查一下 otel 的限制值就可以了

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


At present, it has been changed to http of the standard library, and there is no problem now; use the method of g.Client to make the request. There will be problems if the data is []byte, you can simply test it

Probably the reason for the guidance, if you don’t mention pr to fix it, just check the limit value of otel

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


https://github.com/jaegertracing/jaeger-client-go/blob/master/transport_udp.go#L37
https://github.com/open-telemetry/opentelemetry-go/blob/7dea2225a218872e86d2f580e82c089b321617b0/exporters/jaeger/agent.go#L145

What's the limit here?

@LiuShuKu
Copy link
Author

我当时断点看到了这个限制了;但是WithMaxPacketSize 这里配置多少都不起作用
image

@houseme
Copy link
Member

houseme commented May 11, 2023

最终不能超过这个

// udpPacketMaxLength is the max size of UDP packet we want to send, synced with jaeger-agent.
udpPacketMaxLength = 65000
if params.MaxPacketSize <= 0 || params.MaxPacketSize > udpPacketMaxLength {
	params.MaxPacketSize = udpPacketMaxLength
}

详细细节 https://github.com/open-telemetry/opentelemetry-go/blob/7dea2225a218872e86d2f580e82c089b321617b0/exporters/jaeger/agent.go#L123

open-telemetry/opentelemetry-go#2715

jaegertracing/jaeger-client-node#242

https://www.jaegertracing.io/docs/1.18/client-libraries/

#1958

@LiuShuKu
Copy link
Author

那小于65000 不太现实;可否在g.Client 去除对大[]byte的jaeger的上报吗

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It is unrealistic if it is less than 65000; can you remove the report of the big []byte jaeger in g.Client

@houseme
Copy link
Member

houseme commented May 11, 2023

可以在启动命令里添加 :gf.gtrace.max.content.log.size 给参数赋值,限制大小 @LiuShuKu @Rebellioncry

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


You can add in the startup command: gf.gtrace.max.content.log.size to assign a value to the parameter and limit the size

@LiuShuKu
Copy link
Author

LiuShuKu commented May 11, 2023

可以优雅一点吗

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


be more elegant

@houseme
Copy link
Member

houseme commented May 11, 2023

可以优雅一点吗

你来提一个 pr 吧,目前框架支持传入命令参数处理!

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


can you be more elegant

Come and mention a pr, the current framework supports the processing of incoming command parameters!

@houseme
Copy link
Member

houseme commented May 12, 2023

可以使用 otlp 的方式上报 #2641

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


You can use otlp to report #2641

@LiuShuKu
Copy link
Author

可以给个示例吗

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


can you give an example

@houseme
Copy link
Member

houseme commented May 12, 2023

可以给个示例吗

example/trace/otlp

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


can you give an example

example/trace/otlp

@LiuShuKu
Copy link
Author

未在主库看到

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


not seen in main library

@gqcn gqcn changed the title byte[] 文件上传使用jaeger链路追踪报span too large to send file bytes uploading error in jaeger: span too large to send Jul 4, 2023
@gqcn
Copy link
Member

gqcn commented Aug 21, 2023

@gqcn gqcn closed this as completed Aug 21, 2023
@gqcn gqcn added enhancement done This issue is done, which may be release in next version. labels Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done This issue is done, which may be release in next version. enhancement
Projects
None yet
Development

No branches or pull requests

5 participants