Skip to content

fix(skywalking-logger, error-log-logger): skywalking service_instance_name $hostname is supported#7252

Merged
spacewander merged 6 commits into
apache:release/2.13from
dickens7:fix-7251
Jun 21, 2022
Merged

fix(skywalking-logger, error-log-logger): skywalking service_instance_name $hostname is supported#7252
spacewander merged 6 commits into
apache:release/2.13from
dickens7:fix-7251

Conversation

@dickens7

Copy link
Copy Markdown
Contributor

Description

Fixes #7251

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@spacewander spacewander left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's submit the PR to master, and backport it after it's merged

Comment thread apisix/plugins/error-log-logger.lua Outdated
@tokers

tokers commented Jun 15, 2022

Copy link
Copy Markdown
Contributor

Can we add some test cases to cover the changes?

@dickens7

Copy link
Copy Markdown
Contributor Author

Can we add some test cases to cover the changes?

I don't know how this test case can be written to cover this scenario.

Shall we query the data received by skywaling?

@soulbird

Copy link
Copy Markdown
Contributor

Can we add some test cases to cover the changes?

I don't know how this test case can be written to cover this scenario.

Shall we query the data received by skywaling?

Just for reference: https://github.com/apache/apisix/blob/master/t/plugin/skywalking-logger.t#L124-L196.
However, in the instance of executing the github action, the hostname may not be determined

@tzssangglass

tzssangglass commented Jun 20, 2022

Copy link
Copy Markdown
Member

we can verify hostname like:

qr/^{"boot_time":\d+,"etcd_version":"[\d\.]+","hostname":"[a-zA-Z\-0-9\.]+","id":[a-zA-Z\-0-9]+,"version":"[\d\.]+"}$/

@dickens7

Copy link
Copy Markdown
Contributor Author

we can verify hostname like:

qr/^{"boot_time":\d+,"etcd_version":"[\d\.]+","hostname":"[a-zA-Z\-0-9\.]+","id":[a-zA-Z\-0-9]+,"version":"[\d\.]+"}$/

This won't work, because $hostname can also be matched but we expect the value to be something other than $hostname

@tzssangglass

Copy link
Copy Markdown
Member

how about ^[a-zA-Z\-0-9\.]+

@dickens7

Copy link
Copy Markdown
Contributor Author

how about ^[a-zA-Z\-0-9\.]+

service_instance_name is user-defined and can be set to any value such as #xxx.
This is just for testing, it should work.

But I think my current use case should be ok, we just need to judge that service_instance_name is not equal to the string $hostname and not equal to the empty string.

--- no_error_log eval
qr/\\\"serviceInstance\\\":\\\"\$hostname\\\"/
qr/\\\"serviceInstance\\\":\\\"\\\"/

@tzssangglass

Copy link
Copy Markdown
Member

I reruned the failed CI and if CI passed, we can merge it.

Comment thread apisix/plugins/error-log-logger.lua Outdated
@dickens7

Copy link
Copy Markdown
Contributor Author

please rerun ci

@spacewander
spacewander requested a review from starsz June 21, 2022 05:20

@leslie-tsang leslie-tsang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. 👍

Comment on lines +183 to +186
local service_instance_name = config.skywalking.service_instance_name
if service_instance_name == "$hostname" then
service_instance_name = core.utils.gethostname()
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hello there, we need a test case to ensure it work as expected. :)

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