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

Support spl #251

Merged
merged 16 commits into from
Jan 29, 2024
Merged

Support spl #251

merged 16 commits into from
Jan 29, 2024

Conversation

AVloger
Copy link
Collaborator

@AVloger AVloger commented Jan 24, 2024

No description provided.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ crimson-gao
❌ 泓逸


泓逸 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

consumer.lastFetchGroupCount = GetLogGroupCount(consumer.lastFetchLogGroupList)
if consumer.client.option.Query != "" {
consumer.lastFetchRawSize = rawDataSize
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个改法,变量语义上不太清晰,按照java sdk的方法来作

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有差异,Java和Python的这个结构是对外暴露的,go sdk这个变量是私有变量,按照JAVA SDK的方式就是又需要在结构体里面塞两个变量,然后又加一个赋值的判断,这样就代码就变冗余了

example/consumer/query_demo/simple_demo_with_query.go Outdated Show resolved Hide resolved
client_store.go Outdated
@@ -217,6 +217,11 @@ func (c *Client) PullLogsV2(plr *PullLogRequest) (gl *LogGroupList, nextCursor s
return ls.PullLogsV2(plr)
}

func (c *Client) PullLogsInner(plr *PullLogRequest) (gl *LogGroupList, nextCursor string, dataSize, rawDataSize, rawDataCount int, err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要再加函数了,PullLogsV2是上次为了spl加的,扩展它,把一些多的meta参数(nextCursor string, dataSize, rawDataSize, rawDataCount int)合并到一个 PullLogMeta 结构里去

log_store.go Outdated
return
}

func (s *LogStore) GetLogsBytesInner(plr *PullLogRequest) (out []byte, nextCursor string, dataSize, rawDataSize, rawDataCount int, err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在 GetLogsBytesV2 上改

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所有V2接口都修改成了PullLogMeta的返回值,增加函数convert**V1做V1返回值的转化

log_store.go Show resolved Hide resolved
log_store.go Outdated
}

out = make([]byte, bodyRawSize)
if bodyRawSize != 0 {
out = make([]byte, pullLogMeta.DataSize)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L520/L521换一下顺序

log_store.go Outdated
}
}
// If it is not in scan mode, exit early
if plr.PullMode != "scan_on_stream" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最好这样改:
if plr.PullMode == "scan_on_stream" {
xxx
}

v = r.Header["X-Log-Rawdatasize"]
if len(v) > 0 {
pullLogMeta.RawDataSize, err = strconv.Atoi(v[0])
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

header非法或取不到,需要返回用户更容易理解的信息

可以参考以前的:

v, ok = r.Header["X-Log-Bodyrawsize"]
if !ok || len(v) == 0 {
	err = fmt.Errorf("can't find 'x-log-bodyrawsize' header")
	return
}

log_store.go Outdated Show resolved Hide resolved
@@ -271,7 +271,9 @@ type ClientInterface interface {
// @note if you want to pull logs continuous, set endCursor = ""
PullLogs(project, logstore string, shardID int, cursor, endCursor string,
logGroupMaxCount int) (gl *LogGroupList, nextCursor string, err error)
// Deprecated: Use NewFunction instead.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use PullLogsWithQuery instead

@@ -448,10 +448,15 @@ func (s *LogStore) GetLogsBytes(shardID int, cursor, endCursor string,
return s.GetLogsBytesV2(plr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

调用好几次,浪费了

直接 GetLogsBytesWithQuery

log_store.go Outdated Show resolved Hide resolved
model.go Outdated Show resolved Hide resolved
model.go Outdated Show resolved Hide resolved
@@ -836,7 +836,7 @@ func (c *TokenAutoUpdateClient) PullLogs(project, logstore string, shardID int,
EndCursor: endCursor,
LogGroupMaxCount: logGroupMaxCount,
}
return c.PullLogsV2(plr)
return c.logClient.PullLogsV2(plr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成 PullLogsWithQuery,用最少的跳数来实现

token_auto_update_client.go Show resolved Hide resolved
@@ -271,7 +271,9 @@ type ClientInterface interface {
// @note if you want to pull logs continuous, set endCursor = ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetLogsBytesV2 也是要废弃的吧?注解

README.md Outdated
@@ -38,6 +38,14 @@ go get -u github.com/aliyun/aliyun-log-go-sdk
Client = sls.CreateNormalInterfaceV2(Endpoint, credentialsProvider)
```

为了防止出现配置错误,您可以在创建 Client 之后,测试一下 Client 是否能成功调用 SLS API
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一下 去掉

return
}
}
// If query is not nil, extract more headers
if plr.Query != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

重复的代码有点多,可以单独提取一个函数出来,放到util里面,X-Log-Bodyrawsize 也可以复用

此外,Query存在的情况下,要求必须存在X-Log-Rawdatasize等两个字段的吧,如果不存在是否要报错,否则语义就出现问题了

@@ -145,14 +147,21 @@ func (consumer *ShardConsumerWorker) updateStatus(success bool) {
}

func (consumer *ShardConsumerWorker) shouldFetch() bool {
if consumer.lastFetchGroupCount >= consumer.client.option.MaxFetchLogGroupCount || consumer.lastFetchRawSize >= 4*1024*1024 {
lastFetchRawSize := consumer.lastFetchRawSize
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是否可以只使用 lastFetchGroupCount lastFetchRawSize

只需要在Query模式下,把lastFetchRawSizeBeforeQuery 赋值给 lastFetchRawSize

model.go Outdated
return urlVal
}

type PullLogMeta struct {
NextCursor string
RawSize, RawSizeBeforeQuery, RawDataCountBeforeQuery int
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

单行,不美观

@shabicheng shabicheng merged commit 4da4cf6 into aliyun:master Jan 29, 2024
1 check was pending
mx-psi referenced this pull request in open-telemetry/opentelemetry-collector-contrib Jan 31, 2024
…69 (#30849)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/aliyun/aliyun-log-go-sdk](https://togithub.com/aliyun/aliyun-log-go-sdk)
| `v0.1.68` -> `v0.1.69` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2faliyun%2faliyun-log-go-sdk/v0.1.69?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2faliyun%2faliyun-log-go-sdk/v0.1.69?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2faliyun%2faliyun-log-go-sdk/v0.1.68/v0.1.69?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2faliyun%2faliyun-log-go-sdk/v0.1.68/v0.1.69?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>aliyun/aliyun-log-go-sdk
(github.com/aliyun/aliyun-log-go-sdk)</summary>

###
[`v0.1.69`](https://togithub.com/aliyun/aliyun-log-go-sdk/releases/tag/v0.1.69)

[Compare
Source](https://togithub.com/aliyun/aliyun-log-go-sdk/compare/v0.1.68...v0.1.69)

#### What's Changed

- add vpcid for kafka ingestion by
[@&#8203;fanzhonghao](https://togithub.com/fanzhonghao) in
[https://github.com/aliyun/aliyun-log-go-sdk/pull/248](https://togithub.com/aliyun/aliyun-log-go-sdk/pull/248)
- Feature/add s3 example by
[@&#8203;fanzhonghao](https://togithub.com/fanzhonghao) in
[https://github.com/aliyun/aliyun-log-go-sdk/pull/252](https://togithub.com/aliyun/aliyun-log-go-sdk/pull/252)
- Support spl by [@&#8203;AVloger](https://togithub.com/AVloger) in
[https://github.com/aliyun/aliyun-log-go-sdk/pull/251](https://togithub.com/aliyun/aliyun-log-go-sdk/pull/251)

#### New Contributors

- [@&#8203;AVloger](https://togithub.com/AVloger) made their first
contribution in
[https://github.com/aliyun/aliyun-log-go-sdk/pull/251](https://togithub.com/aliyun/aliyun-log-go-sdk/pull/251)

**Full Changelog**:
aliyun/aliyun-log-go-sdk@v0.1.68...v0.1.69

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any
time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector-contrib).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNTMuMiIsInVwZGF0ZWRJblZlciI6IjM3LjE1My4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@users.noreply.github.com>
Co-authored-by: Yang Song <songy23@users.noreply.github.com>
cparkins referenced this pull request in AmadeusITGroup/opentelemetry-collector-contrib Feb 1, 2024
…69 (open-telemetry#30849)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/aliyun/aliyun-log-go-sdk](https://togithub.com/aliyun/aliyun-log-go-sdk)
| `v0.1.68` -> `v0.1.69` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2faliyun%2faliyun-log-go-sdk/v0.1.69?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2faliyun%2faliyun-log-go-sdk/v0.1.69?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2faliyun%2faliyun-log-go-sdk/v0.1.68/v0.1.69?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2faliyun%2faliyun-log-go-sdk/v0.1.68/v0.1.69?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>aliyun/aliyun-log-go-sdk
(github.com/aliyun/aliyun-log-go-sdk)</summary>

###
[`v0.1.69`](https://togithub.com/aliyun/aliyun-log-go-sdk/releases/tag/v0.1.69)

[Compare
Source](https://togithub.com/aliyun/aliyun-log-go-sdk/compare/v0.1.68...v0.1.69)

#### What's Changed

- add vpcid for kafka ingestion by
[@&open-telemetry#8203;fanzhonghao](https://togithub.com/fanzhonghao) in
[https://github.com/aliyun/aliyun-log-go-sdk/pull/248](https://togithub.com/aliyun/aliyun-log-go-sdk/pull/248)
- Feature/add s3 example by
[@&open-telemetry#8203;fanzhonghao](https://togithub.com/fanzhonghao) in
[https://github.com/aliyun/aliyun-log-go-sdk/pull/252](https://togithub.com/aliyun/aliyun-log-go-sdk/pull/252)
- Support spl by [@&open-telemetry#8203;AVloger](https://togithub.com/AVloger) in
[https://github.com/aliyun/aliyun-log-go-sdk/pull/251](https://togithub.com/aliyun/aliyun-log-go-sdk/pull/251)

#### New Contributors

- [@&open-telemetry#8203;AVloger](https://togithub.com/AVloger) made their first
contribution in
[https://github.com/aliyun/aliyun-log-go-sdk/pull/251](https://togithub.com/aliyun/aliyun-log-go-sdk/pull/251)

**Full Changelog**:
aliyun/aliyun-log-go-sdk@v0.1.68...v0.1.69

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any
time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector-contrib).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNTMuMiIsInVwZGF0ZWRJblZlciI6IjM3LjE1My4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@users.noreply.github.com>
Co-authored-by: Yang Song <songy23@users.noreply.github.com>
@myftcode
Copy link

现在这个https://github.com/aliyun/aliyun-log-go-sdk/blob/master/example/consumer/query_demo/simple_demo_with_query.go文件运行报错 level=warn time=2024-02-21T09:26:17.609466Z caller=consumer_client.go:158 msg="unknown error when pull log" shardId=1 cursor="MTcwODQ4MDc0MzkzNjAxNjkzMg==" error="can't find 'x-log-rawdatasize' header" tryTimes=3

@AVloger
Copy link
Collaborator Author

AVloger commented Feb 21, 2024

现在这个https://github.com/aliyun/aliyun-log-go-sdk/blob/master/example/consumer/query_demo/simple_demo_with_query.go文件运行报错 level=warn time=2024-02-21T09:26:17.609466Z caller=consumer_client.go:158 msg="unknown error when pull log" shardId=1 cursor="MTcwODQ4MDc0MzkzNjAxNjkzMg==" error="can't find 'x-log-rawdatasize' header" tryTimes=3

请问是哪个地域

@myftcode
Copy link

现在这个https://github.com/aliyun/aliyun-log-go-sdk/blob/master/example/consumer/query_demo/simple_demo_with_query.go文件运行报错 level=warn time=2024-02-21T09:26:17.609466Z caller=consumer_client.go:158 msg="unknown error when pull log" shardId=1 cursor="MTcwODQ4MDc0MzkzNjAxNjkzMg==" error="can't find 'x-log-rawdatasize' header" tryTimes=3

请问是哪个地域

杭州 , Endpoint: "cn-hangzhou.log.aliyuncs.com",

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

Successfully merging this pull request may close these issues.

7 participants