mrproliu commented on code in PR #186: URL: https://github.com/apache/skywalking-go/pull/186#discussion_r1633370629
########## CHANGES.md: ########## @@ -12,9 +12,7 @@ Release Notes. * Support [Segmentio-Kafka](https://github.com/segmentio/kafka-go) MQ. * Support http headers collection for Gin * Support higher versions of grpc. - -#### Chore Review Comment: Why remove this Chore selection? ########## plugins/go-elasticsearchv8/intercepter.go: ########## @@ -0,0 +1,72 @@ +// 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 goelasticsearchv8 + +import ( + "fmt" + "net/http" + "strings" + + "github.com/apache/skywalking-go/plugins/core/operator" + "github.com/apache/skywalking-go/plugins/core/tracing" + + "github.com/elastic/elastic-transport-go/v8/elastictransport" + "github.com/elastic/go-elasticsearch/v8" +) + +type ESV8Interceptor struct { +} + +func (es *ESV8Interceptor) BeforeInvoke(invocation operator.Invocation) error { + client := invocation.CallerInstance().(*elasticsearch.BaseClient) + var addresses []string + for _, u := range client.Transport.(*elastictransport.Client).URLs() { + addresses = append(addresses, u.String()) + } + url := strings.Join(addresses, ",") + req := invocation.Args()[0].(*http.Request) + span, err := tracing.CreateExitSpan("Elasticsearch/"+req.Method, url, func(headerKey, headerValue string) error { + req.Header.Add(headerKey, headerValue) Review Comment: I think we haven't ability to monitoring the elastic-search or open-search, so the header it's not necessary. ########## plugins/go-elasticsearchv8/intercepter.go: ########## @@ -0,0 +1,72 @@ +// 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 goelasticsearchv8 + +import ( + "fmt" + "net/http" + "strings" + + "github.com/apache/skywalking-go/plugins/core/operator" + "github.com/apache/skywalking-go/plugins/core/tracing" + + "github.com/elastic/elastic-transport-go/v8/elastictransport" + "github.com/elastic/go-elasticsearch/v8" +) + +type ESV8Interceptor struct { +} + +func (es *ESV8Interceptor) BeforeInvoke(invocation operator.Invocation) error { + client := invocation.CallerInstance().(*elasticsearch.BaseClient) Review Comment: Is possible we can move the address parsing to the constructor the client? ########## test/plugins/scenarios/go-elasticsearchv8/config/excepted.yml: ########## @@ -0,0 +1,99 @@ +# 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: go-elasticsearchv8 + segmentSize: ge 1 + segments: + - segmentId: not null + spans: + - operationName: Elasticsearch/PUT + parentSpanId: 0 + spanId: 1 + spanLayer: Database + startTime: nq 0 + endTime: nq 0 + componentId: 47 + isError: false + spanType: Exit + peer: http://elasticsearch:9200 + skipAnalysis: false + tags: + - { key: db.type, value: Elasticsearch } + - { key: db.statement, value: not null } Review Comment: Could you help adding a demo statement in there? -- 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]
