mrproliu commented on code in PR #203:
URL: https://github.com/apache/skywalking-go/pull/203#discussion_r1766003033


##########
CHANGES.md:
##########
@@ -8,8 +8,10 @@ Release Notes.
 
 * support attaching events to span in the toolkit.
 * support record log in the toolkit.
+* support goframev2

Review Comment:
   ```suggestion
   ```
   
   You have already added it to `plugins` selection, don't need to add it again



##########
test/plugins/scenarios/goframe/main.go:
##########
@@ -0,0 +1,51 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package main
+
+//go:nolint
+import (
+       "context"
+       _ "github.com/apache/skywalking-go"

Review Comment:
   I think it would trigger the `link` checker, please fix the lint. 



##########
test/plugins/scenarios/goframe/main.go:
##########
@@ -0,0 +1,51 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package main
+
+//go:nolint
+import (
+       "context"
+       _ "github.com/apache/skywalking-go"
+       "github.com/gogf/gf/v2/frame/g"
+       "github.com/gogf/gf/v2/net/ghttp"
+       "github.com/gogf/gf/v2/os/gcmd"
+       "github.com/gogf/gf/v2/os/gctx"
+       "net/http"
+)
+
+func main() {
+       command := gcmd.Command{
+               Name:  "goframe",
+               Usage: "goframe",
+               Brief: "start http server",
+               Func: func(ctx context.Context, parser *gcmd.Parser) (err 
error) {
+                       s := g.Server()
+                       s.SetPort(8080)
+                       s.BindHandler("/provider", func(r *ghttp.Request) {

Review Comment:
   Can you enrich this case? For example, the plugin test first accesses 
`/consumer`, then `/consumer` accesses its own `/provider` service. I hope to 
verify whether the trace context can be passed through during process 
communication. You can refer to other HTTP use cases.



##########
plugins/goframe/net/ghttp/intercepter.go:
##########
@@ -0,0 +1,68 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package ghttp
+
+import (
+       "fmt"
+       "github.com/apache/skywalking-go/plugins/core/operator"
+       "github.com/apache/skywalking-go/plugins/core/tracing"
+       "net/http"
+)
+
+// GoFrameServerInterceptor is used to intercept and trace HTTP requests.
+type GoFrameServerInterceptor struct{}
+
+// BeforeInvoke intercepts the HTTP request before invoking the handler.
+func (h *GoFrameServerInterceptor) BeforeInvoke(invocation 
operator.Invocation) error {
+       request := invocation.Args()[1].(*http.Request)
+       s, err := tracing.CreateEntrySpan(fmt.Sprintf("%s:%s", request.Method, 
request.URL.Path), func(headerKey string) (string, error) {
+               return request.Header.Get(headerKey), nil
+       }, tracing.WithLayer(tracing.SpanLayerHTTP),
+               tracing.WithTag(tracing.TagHTTPMethod, request.Method),
+               tracing.WithTag(tracing.TagURL, request.Host+request.URL.Path),
+               tracing.WithComponent(5004))

Review Comment:
   ```suggestion
                tracing.WithComponent(5022))
   ```
   
   Please update the component ID with the newer ID. 



##########
plugins/goframe/instrument.go:
##########
@@ -0,0 +1,46 @@
+package goframe
+
+import (
+       "embed"
+       "github.com/apache/skywalking-go/plugins/core/instrument"

Review Comment:
   Looks like all `lint` checker still failure, please fix it. 



##########
go.work:
##########
@@ -68,4 +69,5 @@ use (
        ./tools/go-agent
 
        ./toolkit
+       test/plugins/scenarios/goframe

Review Comment:
   Can you place it in the same position as the other plugins for testing?



##########
test/plugins/scenarios/goframe/plugin.yml:
##########
@@ -0,0 +1,28 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+entry-service: http://${HTTP_HOST}:${HTTP_PORT}/provider
+health-checker: http://${HTTP_HOST}:${HTTP_PORT}/health
+start-script: ./bin/startup.sh
+framework: github.com/gogf/gf
+export-port: 8080
+support-version:
+  - go: 1.18

Review Comment:
   the goframe have multiple versions, please update it to 
`https://github.com/gogf/gf/releases`. 
   In the test case, you still need to update these two files:
   1. 
[plugins.md](https://github.com/apache/skywalking-go/blob/main/docs/en/agent/support-plugins.md):
 please update the support plugins documentation.
   2. [plugin 
test](https://github.com/apache/skywalking-go/blob/main/.github/workflows/plugin-tests.yaml#L77-L104):
 please add this plugin test, otherwise the plugin test would not be triggered. 



##########
test/plugins/scenarios/goframe/config/excepted.yml:
##########
@@ -0,0 +1,68 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+segmentItems:
+  - serviceName: http
+    segmentSize: ge 3
+    segments:
+      - segmentId: not null
+        spans:
+          - operationName: GET:/provider
+            parentSpanId: -1
+            spanId: 0
+            spanLayer: Http
+            startTime: nq 0
+            endTime: nq 0
+            componentId: 5004

Review Comment:
   Please update the component ID, I think it should be `5022`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to