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

Fix redis cluster, ring cluster lead err msg. Add Redis Unit Test #86

Closed
wants to merge 17 commits into from

Conversation

JamesSunXX
Copy link

c.AddHook(newRedisHook("")) in cluster client, ring client may lead err msg: "go-redis :skyWalking failed to create exit span, got error: parameter are nil"

@mrproliu
Copy link
Contributor

mrproliu commented Aug 4, 2023

You need to keep one PR, please don't re-create it.

@mrproliu mrproliu self-requested a review August 4, 2023 07:58
@mrproliu mrproliu added the enhancement New feature or request label Aug 4, 2023
@mrproliu mrproliu added this to the 0.3.0 milestone Aug 4, 2023
@mrproliu
Copy link
Contributor

mrproliu commented Aug 4, 2023

The CI failed, please check.

@JamesSunXX
Copy link
Author

This is my first PR.
I check this CI log. I can't find any useful log.
image

@mrproliu
Copy link
Contributor

mrproliu commented Aug 4, 2023

@JamesSunXX
Copy link
Author

I need create redis service containers in workflows.

@mrproliu
Copy link
Contributor

mrproliu commented Aug 6, 2023

Then, I think you should mock the data when check the data in the UT.
If you want to startup a full redis container for checking the updates, you should update the plugin test instead of UT.

http.HandleFunc("/execute", executeHandler)

http.HandleFunc("/health", func(writer http.ResponseWriter, request *http.Request) {
writer.WriteHeader(http.StatusOK)

Choose a reason for hiding this comment

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

Is this needed?I believe if you don't do anything it will also return 200.

Copy link
Author

Choose a reason for hiding this comment

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

I noticed that there is a "/health" route written in each plugin file. This is probably used to check the health status of the service, right?

Copy link

@jcchavezs jcchavezs Aug 9, 2023

Choose a reason for hiding this comment

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

totally, what I am saying is that you don't need to write 200, it will by default.

Copy link
Author

Choose a reason for hiding this comment

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

I understand. If I don't register this "/health" route, it indeed returns a 200 status code.I will delete this route register.

Copy link
Contributor

@mrproliu mrproliu Aug 9, 2023

Choose a reason for hiding this comment

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

@JamesSunXX Please don't delete the /health route, we need to access it to check the application has been set up success. @jcchavezs means you don't need to write writer.WriteHeader(http.StatusOK)(only this line).

- { key: cache.args, value: 'command: map[]' }
- segmentId: not null
spans:
- operationName: redis/cluster slots
Copy link
Contributor

@mrproliu mrproliu Aug 9, 2023

Choose a reason for hiding this comment

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

Please don't add the blank in the operation name, they should separate by '/'. Also, why do there have so many no-entry segments (only exit span)?

Copy link
Author

Choose a reason for hiding this comment

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

redis command cluster slots is a full operationName. I will handle this action.I find this original PR contributor only use CreateExitSpan handle redis hook.

- { key: cache.args, value: not null }
- segmentId: not null
spans:
- operationName: GET:/health
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to verify the 'GET:/health' segment, please delete it.

Copy link
Author

Choose a reason for hiding this comment

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

If I delete GET:/health segment, it will validate actual data failed.

Copy link
Member

Choose a reason for hiding this comment

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

It would not. The tool would only check declared, not the exact match.

componentId: 5014
isError: false
spanType: Exit
peer: not null
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please provide the peer address?

Copy link
Author

Choose a reason for hiding this comment

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

The image bitnami/redis-cluster provides environment variables REDIS_CLUSTER_ANNOUNCE_IP , but after trying many times, I couldn't successfully initialize the cluster redis with the specified IP. Also, the Go service couldn't access redis.

Copy link
Contributor

Choose a reason for hiding this comment

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

My intention is not the IP address, after testing it should be the address filled in the program. Isn't it?

@mrproliu
Copy link
Contributor

mrproliu commented Aug 9, 2023

Looks like the CI failure, please re-check.

@JamesSunXX
Copy link
Author

docker-compose doesn't support boolean data types. In this commit, I fix it.

@wu-sheng
Copy link
Member

We had cost a lot of resources on the CI process. Why didn't you run the tests and make sure it could pass locally?

@JamesSunXX
Copy link
Author

I did run the tests locally and it pass.Should I delete this commit change about the tests?

@wu-sheng
Copy link
Member

You should pass the plugin tests locally, not just test the codes manually.

All steps on CI are runnable locally.

Your failures show your plugin test codes are not verified by yourself.
You made us to run those dozens of times, I don't think it makes sense.

@jcchavezs
Copy link

jcchavezs commented Aug 10, 2023 via email

@mrproliu
Copy link
Contributor

Hi, @jcchavezs . Thanks for your advice.

  • only run tests on the plugin that changed.
  • adds go cache to cache test results

That sounds good. But there maybe have some plugin dependencies another plugin, such as kratos dependency on the native http and grpc frameworks. We cannot make sure all the frameworks/plugins are independent, so we needs to check them all.

  • add ephimeral cache to artifacts that are being downloaded

We don't have so many files that need to be downloaded, so could be ignored.

  • review the usage of always() as it will run steps even if previous failed

We already using the needs config for some job to make sure only run after the dependency job are successful.

  • verify if you have prerequisites in jobs so you don't run something that you know on beforehand it will fail.

We need the person creating PRs to test the CI locally in order to save time.

@mrproliu
Copy link
Contributor

mrproliu commented Aug 10, 2023

I did run the tests locally and it pass.Should I delete this commit change about the tests?

Please follow the GHA file to test locally. For example, the lint errors should still be prompted on your local machine.

@jcchavezs
Copy link

Yeah ideally the person writing the PR should verify everything in local. What I am seeking here is to be defensive in the way we incur in CI costs.

About running tests in local. Would it be a good idea to have a pre-commit hook? This would trigger tests before commit which is handy and automated.

@JamesSunXX
Copy link
Author

(base) ➜ plugins git:(main) ✗ ./run.sh go-redisv9
+++ dirname ./run.sh
++ cd .
++ pwd

  • home=/Users/android/Downloads/skywalking-go/test/plugins

  • scenario_name=

  • debug_mode=off

  • cleanup=off

  • scenarios_home=/Users/android/Downloads/skywalking-go/test/plugins/scenarios

  • num_of_testcases=0
    ++ date +%s

  • start_stamp=1691654837

  • export -f replace

  • parse_commandline go-redisv9

  • test 1 -gt 0

  • _key=go-redisv9

  • case "$_key" in

  • scenario_name=go-redisv9

  • shift

  • test 0 -gt 0

  • [[ off == \o\n ]]

  • test -z go-redisv9

  • scenario_home=/Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9

  • configuration=/Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/plugin.yml

  • [[ ! -f /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/plugin.yml ]]
    ++ yq e .framework /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/plugin.yml

  • framework_name=github.com/redis/go-redis/v9

  • '[' -z github.com/redis/go-redis/v9 ']'
    ++ yq e '.support-version | length' /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/plugin.yml

  • support_version_count=2

  • '[' 2 -eq 0 ']'

  • index=0

  • '[' 0 -lt 2 ']'
    ++ yq e '.support-version[0].go' /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/plugin.yml

  • go_version=1.17
    ++ yq e '.support-version[0].framework | length' /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/plugin.yml

  • framework_count=1

  • '[' -z 1.17 ']'

  • [[ github.com/redis/go-redis/v9 != \g\o ]]

  • '[' 1 -eq 0 ']'

  • index=1

  • '[' 1 -lt 2 ']'
    ++ yq e '.support-version[1].go' /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/plugin.yml

  • go_version=1.18
    ++ yq e '.support-version[1].framework | length' /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/plugin.yml

  • framework_count=2

  • '[' -z 1.18 ']'

  • [[ github.com/redis/go-redis/v9 != \g\o ]]

  • '[' 2 -eq 0 ']'

  • index=2

  • '[' 2 -lt 2 ']'

  • workspace=/Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9

  • [[ -d /Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9 ]]

  • rm -rf /Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9

  • plugin_runner_helper=/Users/android/Downloads/skywalking-go/test/plugins/dist/runner-helper

  • [[ ! -f /Users/android/Downloads/skywalking-go/test/plugins/dist/runner-helper ]]

  • go_agent=/Users/android/Downloads/skywalking-go/test/plugins/dist/skywalking-go-agent

  • [[ ! -f /Users/android/Downloads/skywalking-go/test/plugins/dist/skywalking-go-agent ]]

  • yq e '.support-version[].go' /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/plugin.yml

  • read -r go_version
    ++ yq e '.support-version[] | select(.go == "1.17") | .framework[]' /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/plugin.yml

  • frameworks=v9.0.3

  • [[ github.com/redis/go-redis/v9 == \g\o ]]

  • for framework_version in '$frameworks'

  • echo 'ready to run test case: go-redisv9 with go version: 1.17 and framework version: v9.0.3'
    ready to run test case: go-redisv9 with go version: 1.17 and framework version: v9.0.3

  • case_name=go1.17-v9.0.3

  • case_home=/Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9/go1.17-v9.0.3

  • case_logs=/Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9/go1.17-v9.0.3/logs

  • mkdir -p /Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9/go1.17-v9.0.3

  • mkdir -p /Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9/go1.17-v9.0.3/logs

  • cp -rf /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/bin /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/config /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/go.mod /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/go.sum /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/main.go /Users/android/Downloads/skywalking-go/test/plugins/scenarios/go-redisv9/plugin.yml /Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9/go1.17-v9.0.3

  • cd /Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9/go1.17-v9.0.3
    ++ echo go1.17-v9.0.3
    ++ sed 's////g; s/.//g; s/-/_/g'

  • mod_case_name=go1_17_v9_0_3
    ++ head -n 1 go.mod
    ++ cut -d ' ' -f 2

  • mod_name=test/plugins/scenarios/go-redisv9

  • replace 's/^go [0-9].[0-9]/go 1.17/' go.mod

  • '[' 2 -lt 2 ']'

  • opt=

  • cmd='s/^go [0-9].[0-9]/go 1.17/'

  • file=go.mod

  • '[' 2 -eq 3 ']'
    ++ uname

  • '[' Darwin = Darwin ']'

  • sed -i '' 's/^go [0-9].[0-9]/go 1.17/' go.mod

  • replace 's/^module /module go1_17_v9_0_3//' go.mod

  • '[' 2 -lt 2 ']'

  • opt=

  • cmd='s/^module /module go1_17_v9_0_3//'

  • file=go.mod

  • '[' 2 -eq 3 ']'
    ++ uname

  • '[' Darwin = Darwin ']'

  • sed -i '' 's/^module /module go1_17_v9_0_3//' go.mod

  • find . -name '*.go' -type f -exec bash -c 'replace "s|test/plugins/scenarios/go-redisv9|go1_17_v9_0_3/test/plugins/scenarios/go-redisv9|g" "{}"' ';'

  • replace -E '/^replace/ s#(../)#\1../#' go.mod

  • '[' 3 -lt 2 ']'

  • opt=

  • cmd=-E

  • file='/^replace/ s#(../)#\1../#'

  • '[' 3 -eq 3 ']'

  • opt=-E

  • cmd='/^replace/ s#(../)#\1../#'

  • file=go.mod
    ++ uname

  • '[' Darwin = Darwin ']'

  • sed -i '' -E '/^replace/ s#(../)#\1../#' go.mod

  • [[ v9.0.3 != \n\a\t\i\v\e ]]

  • go get github.com/redis/go-redis/[email protected]
    go: downgraded github.com/redis/go-redis/v9 v9.0.5 => v9.0.3

  • /Users/android/Downloads/skywalking-go/test/plugins/dist/runner-helper -workspace /Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9/go1.17-v9.0.3 -project /Users/android/Downloads/skywalking-go/test/plugins/../../ -go-version 1.17 -scenario go-redisv9 -case go1.17-v9.0.3 -debug off -go-agent /Users/android/Downloads/skywalking-go/test/plugins/dist/skywalking-go-agent
    2023/08/10 16:07:18 helper execute args: [/Users/android/Downloads/skywalking-go/test/plugins/dist/runner-helper -workspace /Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9/go1.17-v9.0.3 -project /Users/android/Downloads/skywalking-go/test/plugins/../../ -go-version 1.17 -scenario go-redisv9 -case go1.17-v9.0.3 -debug off -go-agent /Users/android/Downloads/skywalking-go/test/plugins/dist/skywalking-go-agent]

  • echo 'staring the testcase go-redisv9, go1.17-v9.0.3'
    staring the testcase go-redisv9, go1.17-v9.0.3

  • bash /Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9/go1.17-v9.0.3/scenarios.sh
    ++ docker-compose version --short

  • compose_version=2.20.2-desktop.1

  • [[ 2.20.2-desktop.1 =~ ^(v)?1 ]]

  • [[ 2.20.2-desktop.1 =~ ^(v)?2 ]]

  • separator=-
    ++ echo go-redisv9
    ++ sed -e 's/.//g'
    ++ awk '{print tolower($0)}'

  • project_name=go-redisv9

  • service_container_name=go-redisv9-service-1

  • validator_container_name=go-redisv9-validator-1

  • set +ex
    [+] Running 5/5
    ✔ Container go-redisv9-redis-cluster-server-1 Healthy5.8s
    ✔ Container go-redisv9-oap-1 Healthy5.8s
    ✔ Container go-redisv9-redis-single-server-1 Healthy6.2s
    ✔ Container go-redisv9-service-1 Healthy77.4s
    ✔ Container go-redisv9-validator-1 Started78.3s

  • sleep 3
    ++ docker ps -aqf name=go-redisv9-validator-1

  • validator_container_id=f248b390d191
    ++ docker wait f248b390d191

  • status=1

  • [[ -z f248b390d191 ]]

  • [[ 1 -ne 0 ]]

  • docker logs f248b390d191

  • HTTP_HOST=service

  • HTTP_PORT=8080

  • echo 'Checking the service health status...'

  • healthCheck http://service:8080/health

  • HEALTH_CHECK_URL=http://service:8080/health

  • STATUS=

  • TIMES=60

  • i=1

  • [[ 1 -lt 60 ]]
    Checking the service health status...
    ++ curl --max-time 3 -is http://service:8080/health
    ++ grep -oE 'HTTP/.*\s+200'
    http://service:8080/health: HTTP/1.1 200
    Visiting entry service...

  • STATUS='HTTP/1.1 200'

  • [[ -n HTTP/1.1 200 ]]

  • echo 'http://service:8080/health: HTTP/1.1 200'

  • return 0

  • echo 'Visiting entry service...'
    ++ echo curl -s --max-time 3 http://service:8080/execute

  • curl -s --max-time 3 http://service:8080/execute

  • sleep 5

  • echo 'Receiving actual data...'
    execute redis op successReceiving actual data...

  • curl -s --max-time 3 http://oap:12800/receiveData

  • [[ ! -f /workspace/config/actual.yaml ]]

  • echo 'Validating actual data...'
    Validating actual data...
    ++ curl -X POST --data-binary @/workspace/config/excepted.yml -s -w '\n%{http_code}' http://oap:12800/dataValidate

  • response='
    500'
    ++ echo '
    500'
    ++ tail -n1

  • status_code=500
    ++ echo '
    500'
    ++ head -n -1

  • response_body=

  • '[' 500 -ne 200 ']'

  • exitOnError 'go-redisv9-go1.17-v9.0.3, validate actual data failed! \n'

  • echo -e '\033[31m[ERROR] go-redisv9-go1.17-v9.0.3, validate actual data failed! \n\033[0m'
    [ERROR] go-redisv9-go1.17-v9.0.3, validate actual data failed!

  • exit 1

  • docker logs go-redisv9-service-1
    WORK=/tmp/go-build3848096159
    skywalking-go 2023/08/10 08:18:23 open stream error rpc error: code = Unavailable desc = connection error: desc = "error reading server preface: read tcp 172.31.0.5:37524->172.31.0.4:19876: use of closed network connection"
    skywalking-go 2023/08/10 08:18:23 open stream error rpc error: code = Unavailable desc = connection error: desc = "error reading server preface: read tcp 172.31.0.5:37524->172.31.0.4:19876: use of closed network connection"
    skywalking-go 2023/08/10 08:18:23 open stream error rpc error: code = Unavailable desc = connection error: desc = "error reading server preface: read tcp 172.31.0.5:37524->172.31.0.4:19876: use of closed network connection"
    skywalking-go 2023/08/10 08:18:23 report serviceInstance properties error rpc error: code = Unavailable desc = connection error: desc = "error reading server preface: read tcp 172.31.0.5:37524->172.31.0.4:19876: use of closed network connection"
    skywalking-go 2023/08/10 08:18:23 fetch dynamic configuration error rpc error: code = Unavailable desc = connection error: desc = "error reading server preface: read tcp 172.31.0.5:37524->172.31.0.4:19876: use of closed network connection"
    2023/08/10 08:18:25 excute test case set_and_get_single
    2023/08/10 08:18:25 excute test case pipeline_set_and_get_single
    2023/08/10 08:18:25 excute test case set_and_get_cluster
    2023/08/10 08:18:25 excute test case pipeline_set_and_get_cluster

  • docker-compose -p go-redisv9 -f /Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9/go1.17-v9.0.3/docker-compose.yml kill
    [+] Killing 4/4
    ✔ Container go-redisv9-oap-1 Killed0.6s
    ✔ Container go-redisv9-redis-cluster-server-1 Killed0.4s
    ✔ Container go-redisv9-service-1 Killed0.5s
    ✔ Container go-redisv9-redis-single-server-1 Killed0.6s

  • docker-compose -p go-redisv9 -f /Users/android/Downloads/skywalking-go/test/plugins/workspace/go-redisv9/go1.17-v9.0.3/docker-compose.yml rm -f
    [+] Removing 5/5
    ✔ Container go-redisv9-oap-1 Removed0.1s
    ✔ Container go-redisv9-validator-1 Removed0.2s
    ✔ Container go-redisv9-redis-cluster-server-1 Removed0.2s
    ✔ Container go-redisv9-service-1 Removed0.9s
    ✔ Container go-redisv9-redis-single-server-1 Removed0.2s

  • exit 1

@mrproliu
Copy link
Contributor

So, why did you upload the plugin test log? The plugin test code is there, your need to deep look at it why it returns 500.

@mrproliu
Copy link
Contributor

Yeah ideally the person writing the PR should verify everything in local. What I am seeking here is to be defensive in the way we incur in CI costs.

About running tests in local. Would it be a good idea to have a pre-commit hook? This would trigger tests before commit which is handy and automated.

Do all commits made by the user in their own branch automatically trigger CI? Will this result in a significant consumption of GHA resources and frequent receipt of CI emails from GitHub Actions for the user?

@wu-sheng
Copy link
Member

Do all commits made by the user in their own branch automatically trigger CI?

For now, it wouldn't. But we can't see the result of CI, so does the contributor.

Will this result in a significant consumption of GHA resources and frequent receipt of CI emails from GitHub Actions for the user?

It costs the slots in the whole ASF org, which is why INFRA disabled the auto-running.


This is not the reason I am asking. The issue is, we have to approve the CI to run, in order to see whether the tests passed. But every time, it fails. I can't see the point of doing this.
These automatical tests are reproducible at the contributor's local env, so, CI is just for reviewers to confirm. If the users want to verify on CI and cost its now resources of CI available times, they could close the PR and run on their own PR. Then it is not upstream's concern.

@jcchavezs
Copy link

Do all commits made by the user in their own branch automatically trigger CI? Will this result in a significant consumption of GHA resources and frequent receipt of CI emails from GitHub Actions for the user?

Nope. A pre-commit hooks runs locally, run all targets you decide in local before the commit can be made in local. See https://pre-commit.com/

@wu-sheng
Copy link
Member

Do all commits made by the user in their own branch automatically trigger CI? Will this result in a significant consumption of GHA resources and frequent receipt of CI emails from GitHub Actions for the user?

Nope. A pre-commit hooks runs locally, run all targets you decide in local before the commit can be made in local. See https://pre-commit.com/

pre-hook is local, but with the increment of the plugins(look at Java agent plugin list), every commit will become a pain.
I don't want that burden for everyone. If we look at the history of all language agents contributors, most of them are doing well by following testing locally first, rather than a forcibly pre-commit hook setup.

@JamesSunXX
Copy link
Author

   - segmentId: cdc63b6a382911eeb5b20242ac120005.21.39034998715200004
    spans:
    - operationName: redis/pipeline
      parentSpanId: -1
      spanId: 0
      spanLayer: Cache
      startTime: 1691746271520
      endTime: 1691746271521
      componentId: 5014
      isError: false
      spanType: Exit
      peer: 172.18.0.2:7001
      skipAnalysis: false
      tags:
      - {key: cache.type, value: redis}
      - {key: cache.cmd, value: 'pipeline:set/set'}
  - segmentId: cdc63b6a382911eeb5b20242ac120005.21.39034998715210006
    spans:
    - operationName: redis/pipeline
      parentSpanId: -1
      spanId: 0
      spanLayer: Cache
      startTime: 1691746271521
      endTime: 1691746271521
      componentId: 5014
      isError: false
      spanType: Exit
      peer: 172.18.0.2:7001
      skipAnalysis: false
      tags:
      - {key: cache.type, value: redis}
      - {key: cache.cmd, value: 'pipeline:get/get'}
  - segmentId: cdc63b6a382911eeb5b20242ac120005.71.39034998715150002
    spans:
    - operationName: redis/set
      parentSpanId: 0
      spanId: 1
      spanLayer: Cache
      startTime: 1691746271516
      endTime: 1691746271517
      componentId: 5014
      isError: false
      spanType: Exit
      peer: redis-server:6379
      skipAnalysis: false
      tags:
      - {key: cache.type, value: redis}
      - {key: cache.op, value: write}
      - {key: cache.cmd, value: set}
      - {key: cache.key, value: key_TestSetAndGet}
      - {key: cache.args, value: 'set key_TestSetAndGet value_TestSetAndGet ex 10: '}
    - operationName: redis/get
      parentSpanId: 0
      spanId: 2
      spanLayer: Cache
      startTime: 1691746271517
      endTime: 1691746271517
      componentId: 5014
      isError: false
      spanType: Exit
      peer: redis-server:6379
      skipAnalysis: false
      tags:
      - {key: cache.type, value: redis}
      - {key: cache.op, value: read}
      - {key: cache.cmd, value: get}
      - {key: cache.key, value: key_TestSetAndGet}
      - {key: cache.args, value: 'get key_TestSetAndGet: '}
    - operationName: redis/pipeline
      parentSpanId: 0
      spanId: 3
      spanLayer: Cache
      startTime: 1691746271518
      endTime: 1691746271518
      componentId: 5014
      isError: false
      spanType: Exit
      peer: redis-server:6379
      skipAnalysis: false
      tags:
      - {key: cache.type, value: redis}
      - {key: cache.cmd, value: 'pipeline:set/set'}
    - operationName: redis/pipeline
      parentSpanId: 0
      spanId: 4
      spanLayer: Cache
      startTime: 1691746271518
      endTime: 1691746271518
      componentId: 5014
      isError: false
      spanType: Exit
      peer: redis-server:6379
      skipAnalysis: false
      tags:
      - {key: cache.type, value: redis}
      - {key: cache.cmd, value: 'pipeline:get/get'}
    - operationName: redis/set
      parentSpanId: 0
      spanId: 5
      spanLayer: Cache
      startTime: 1691746271519
      endTime: 1691746271519
      componentId: 5014
      isError: false
      spanType: Exit
      peer: 172.18.0.2:7001
      skipAnalysis: false
      tags:
      - {key: cache.type, value: redis}
      - {key: cache.op, value: write}
      - {key: cache.cmd, value: set}
      - {key: cache.key, value: key_TestSetAndGet}
      - {key: cache.args, value: 'set key_TestSetAndGet value_TestSetAndGet ex 10: '}
    - operationName: redis/get
      parentSpanId: 0
      spanId: 6
      spanLayer: Cache
      startTime: 1691746271519
      endTime: 1691746271519
      componentId: 5014
      isError: false
      spanType: Exit
      peer: 172.18.0.2:7001
      skipAnalysis: false
      tags:
      - {key: cache.type, value: redis}
      - {key: cache.op, value: read}
      - {key: cache.cmd, value: get}
      - {key: cache.key, value: key_TestSetAndGet}
      - {key: cache.args, value: 'get key_TestSetAndGet: '}
    - operationName: GET:/execute
      parentSpanId: -1
      spanId: 0
      spanLayer: Http
      startTime: 1691746271515
      endTime: 1691746271521
      componentId: 5004
      isError: false
      spanType: Entry
      peer: ''
      skipAnalysis: false
      tags:
      - {key: http.method, value: GET}
      - {key: url, value: 'service:8080/execute'}
      - {key: status_code, value: '200'}

The information above consists of actual collected data, and the code logic below is from testing. Why does the pipeline operation on the Redis cluster appear in two different segmentIds? Shouldn't this log data be within the same segmentId?

func executeHandler(w http.ResponseWriter, r *http.Request) {
	testCases := []struct {
		name   string
		client v9.UniversalClient
		fn     testFunc
	}{
		{"set_and_get_single", rdb, TestSetAndGet},
		{"pipeline_set_and_get_single", rdb, TestPipelineSetAndGet},
		{"set_and_get_cluster", clusterDB, TestSetAndGet},
		{"pipeline_set_and_get_cluster", clusterDB, TestPipelineSetAndGet},
	}

	for _, test := range testCases {
		log.Printf("excute test case %s", test.name)
		if err := test.fn(r.Context(), test.client); err != nil {
			log.Fatalf("test case %s failed: %v", test.name, err)
		}
	}
	_, _ = w.Write([]byte("execute redis op success"))
}

@mrproliu
Copy link
Contributor

This depends on whether your interception point is in the same goroutine (or goroutine created by the current HTTP handler) as the current consumer's access address. If the interception point is in a different goroutine, it will be impossible to determine their correlation.

@JamesSunXX
Copy link
Author

In the cluster redis, the hook in the pipeline command will be triggered in another goroutine. Is there any way to identify the same segmentId?

@mrproliu
Copy link
Contributor

mrproliu commented Aug 15, 2023

Please follow this documentation section to operate tracing context.

@wu-sheng wu-sheng removed this from the 0.3.0 milestone Aug 23, 2023
@wu-sheng
Copy link
Member

There is no update for one week.

@wu-sheng wu-sheng closed this Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants