Skip to content

Add okhttp2.x plugin#49

Merged
wu-sheng merged 15 commits intoapache:mainfrom
xu1009:add-okhttp2.x-plugin
Oct 25, 2021
Merged

Add okhttp2.x plugin#49
wu-sheng merged 15 commits intoapache:mainfrom
xu1009:add-okhttp2.x-plugin

Conversation

@xu1009
Copy link
Contributor

@xu1009 xu1009 commented Oct 12, 2021

Add an agent plugin to support

  • If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #<7889>.
  • Update the CHANGES log.

@wu-sheng
Copy link
Member

Please fix conflicts.

@wu-sheng wu-sheng added enhancement New feature or request plugin labels Oct 12, 2021
@xu1009
Copy link
Contributor Author

xu1009 commented Oct 12, 2021

ok fix conflict

@xu1009
Copy link
Contributor Author

xu1009 commented Oct 12, 2021

it looks hbase scenarios test failed, i do not change other file

@wu-sheng wu-sheng added this to the 8.8.0 milestone Oct 12, 2021
@wu-sheng
Copy link
Member

Please resolve conflicts.

@xu1009
Copy link
Contributor Author

xu1009 commented Oct 12, 2021

ok, fix it

@wu-sheng
Copy link
Member

Your #45 gets merged, you have to resolve the conflicts again.

@xu1009
Copy link
Contributor Author

xu1009 commented Oct 12, 2021

ok, fix conflicts

# limitations under the License.
segmentItems:
- serviceName: okhttp2-scenario
segmentSize: ge 5
Copy link
Member

Choose a reason for hiding this comment

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

Why ge 5?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

at least one health check

Copy link
Member

Choose a reason for hiding this comment

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

We don't have to do this. Usually ge 0 is clear enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Comment on lines +20 to +43
- segmentId: not null
spans:
- operationName: Async/okhttp2-scenario/case/receiveContext-0
parentSpanId: 0
spanId: 1
startTime: nq 0
endTime: nq 0
componentId: 0
isError: false
spanType: Local
skipAnalysis: 'false'
- operationName: GET:/case/okhttp2-scenario
parentSpanId: -1
spanId: 0
spanLayer: Http
startTime: nq 0
endTime: nq 0
componentId: 14
isError: false
spanType: Entry
tags:
- {key: url, value: 'http://localhost:8080/okhttp2-scenario/case/okhttp2-scenario'}
- {key: http.method, value: GET}
skipAnalysis: 'false'
Copy link
Member

Choose a reason for hiding this comment

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

What is this segment? It seems no exit and no ref?

Copy link
Member

Choose a reason for hiding this comment

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

I assume this is the main entry and the next should be async call, right?

Copy link
Member

Choose a reason for hiding this comment

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

I can see /okhttp2-scenario/case/receiveContext-0 exit span, but where is /okhttp2-scenario/case/receiveContext-1 exit span?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes the segment next is async call, it follows the passed okhttp version

/okhttp2-scenario/case/receiveContext-1 exit span seems lost, i recheck it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i find the problem, the request is in async call back respose method, but the last span is exit span, this causes this span will be discarded

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it looks the passed okhttp version has the same problem, besides, the time of action in response method will be calculated in last span, it is not correct

Copy link
Member

Choose a reason for hiding this comment

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

This span will be ignore only if both spans are in the same thread. But callback usually should generate a local span. Also, callback should invoke after the first HTTP span finished, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, both span is in same thread, the implementation is strange, i will optimize it

Copy link
Member

Choose a reason for hiding this comment

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

That means the first exit span doesn't finish in time.

Comment on lines 54 to 55
Request request = new Request.Builder().url("http://127.0.0.1:8080/okhttp2-scenario/case/receiveContext-0")
.header("sw8", "123456").build();
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain a little about this? sw8 header is not in this format.
When you are doing request, the header should be injected automatically. Is this somthing special?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it can confirm the plugin overwrite the skywalking sw8 head

Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to test this scenario? Who will use this header key besides ourselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, i will remove it

Copy link
Contributor Author

@xu1009 xu1009 Oct 14, 2021

Choose a reason for hiding this comment

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

image

i fix it by add local span in response, so it can catch the action in reposne method and the first http call time is correct like above

Copy link
Member

Choose a reason for hiding this comment

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

Local span should be added.

Copy link
Member

Choose a reason for hiding this comment

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

A question is, from the graph, the duration of first span is incorrect. It should finish before the local span starts, otherwise, the rpc duration is over measured.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, but self time cost is the duration of first span,

Copy link
Member

Choose a reason for hiding this comment

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

That is correct. But when you look at metrics of lines in the topology, which represents calling outbound to upstream, the number of client side is generated by exit span.
So, we also need to fix that duration too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok i will fix it and the passed okhttp version too

@wu-sheng
Copy link
Member

@xu1009 Could you finish this pull request?

@xu1009
Copy link
Contributor Author

xu1009 commented Oct 19, 2021

@xu1009 Could you finish this pull request?

@wu-sheng sorry about it, i am very busy recently, i will try my best to finish it this week

@wu-sheng
Copy link
Member

New release should start recently, if you want to include this in, you need to finish this PR ASAP.

@xu1009
Copy link
Contributor Author

xu1009 commented Oct 25, 2021

image

i fix it like above, you think ok

execute is local span,include execute http req and response callback fail callback

@wu-sheng
Copy link
Member

This trace seems good now. Is there other version(s) to fix?

@xu1009
Copy link
Contributor Author

xu1009 commented Oct 25, 2021

no, i think it is the best, it can show the time cost precisely

@wu-sheng
Copy link
Member

no, i think it is the best, it can show the time cost precisely

I just mean this, there are several versions to fix, right?
#49

@xu1009
Copy link
Contributor Author

xu1009 commented Oct 25, 2021

yes, i ci it in this way

@wu-sheng
Copy link
Member

Please fix CI.

@xu1009
Copy link
Contributor Author

xu1009 commented Oct 25, 2021

ok, okhttp4.x use kt, it looks internal method name is diff in running time

@xu1009
Copy link
Contributor Author

xu1009 commented Oct 25, 2021

the failed ci task is not my change

@wu-sheng
Copy link
Member

the failed ci task is not my change

I rerun those. But it seems you missed some UTs?

@xu1009
Copy link
Contributor Author

xu1009 commented Oct 25, 2021

yes, i find the problem, fix it

@wu-sheng
Copy link
Member

Strange, that plugin can't pass even I have tried many times.

@xu1009
Copy link
Contributor Author

xu1009 commented Oct 25, 2021

i do not change that plugin==

@xu1009
Copy link
Contributor Author

xu1009 commented Oct 25, 2021

i will try the master branch

@xu1009
Copy link
Contributor Author

xu1009 commented Oct 25, 2021

the master branch failed too

@wu-sheng
Copy link
Member

i do not change that plugin==

I know you didn't change that.

@wu-sheng wu-sheng merged commit 9101f69 into apache:main Oct 25, 2021
wu-sheng added a commit that referenced this pull request Oct 31, 2021
* main: (28 commits)
  fix release doc (#61)
  Support Jedis' Transaction and fix duplicated enhancement (#57)
  Initialize 8.9.0 iteration (#59)
  Polish release shell and doc. (#58)
  fix rocketmq message header properties garbled characters issue (#54)
  Fix netty-socketio plugin test failure (#56)
  Add okhttp2.x plugin (#49)
  add e2e test for kafka transporter (#42)
  Fix version badge (#53)
  Add JDK17 supported declaration. (#52)
  Fix instrumentation v2 API doesn't work for constructor instrumentation. (#51)
  Add kylin jdbc plugin (#45)
  Fix version compatibility for JSON-RPC4J Plugin (#50)
  Feature add clickhouse jdbc plugin (#41)
  Update menu.yml (#48)
  Fix format. (#47)
  Add new menu for the document (#46)
  Doc: Update setup agent in kubernetes from 'containers' to 'initContainers'. (#44)
  The httpasyncclient-4.x-plugin does not take effect every time. (#40)
  Add an agent plugin to support Jackson (#39)
  ...

# Conflicts:
#	.github/workflows/plugins-test.3.yaml
#	CHANGES.md
#	docs/en/setup/service-agent/java-agent/README.md
#	docs/menu.yml
GuoHaoZai pushed a commit to GuoHaoZai/skywalking-java that referenced this pull request Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants