You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "Alipebt (via GitHub)" <gi...@apache.org> on 2023/09/23 06:35:34 UTC
[GitHub] [skywalking-go] Alipebt opened a new pull request, #104: Provide APIs to user and support correlationContext
Alipebt opened a new pull request, #104:
URL: https://github.com/apache/skywalking-go/pull/104
# Add
- Provide APIs to users
- support get/set correlation context value
realted to apache/skywalking#11333
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-go] Alipebt commented on pull request #104: Provide APIs to user and support correlationContext
Posted by "Alipebt (via GitHub)" <gi...@apache.org>.
Alipebt commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1732531617
I will solve these problems later
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-go] mrproliu commented on a diff in pull request #104: Provide APIs to user and support correlationContext
Posted by "mrproliu (via GitHub)" <gi...@apache.org>.
mrproliu commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1335150162
##########
go.sum:
##########
@@ -3,6 +3,8 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
+github.com/apache/skywalking-go/plugins/core v0.0.0-20230918115826-b3e0cf3c66e3 h1:eKd+lMBXKPxrDQ/OJ/JZ26YsaSSBgFt8vJHANfsn1LA=
Review Comment:
Please delete this package in the sum file.
##########
plugins/core/tracer.go:
##########
@@ -65,6 +65,10 @@ func (t *Tracer) Init(entity *reporter.Entity, rep reporter.Reporter, samp Sampl
t.Reporter.Boot(entity, t.cdsWatchers)
t.initFlag = 1
t.initMetricsCollect(meterCollectSecond)
+ t.correlation = &CorrelationConfig{
Review Comment:
Can we make it configurable?
##########
plugins/trace-activation/capture_intercepter.go:
##########
@@ -0,0 +1,35 @@
+// 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 traceactivation
+
+import (
+ "github.com/apache/skywalking-go/plugins/core/operator"
+ "github.com/apache/skywalking-go/plugins/core/tracing"
+)
+
+type CaptureContextInterceptor struct {
+}
+
+func (h *CaptureContextInterceptor) BeforeInvoke(invocation operator.Invocation) error {
+ return nil
+}
+
+func (h *CaptureContextInterceptor) AfterInvoke(invocation operator.Invocation, result ...interface{}) error {
+ invocation.DefineReturnValues(tracing.CaptureContext())
Review Comment:
Please define the result in the beforeMethod.
##########
plugins/core/tracing.go:
##########
@@ -293,3 +331,11 @@ func saveSpanToActiveIfNotError(ctx *TracingContext, span interface{}, err error
ctx.SaveActiveSpan(span.(TracingSpan))
SetGLS(ctx)
}
+
+func getTracer() *Tracer {
Review Comment:
If this method doesn't need, please remove it.
##########
plugins/core/tracing.go:
##########
@@ -175,6 +175,44 @@ func (t *Tracer) CleanContext() {
SetGLS(nil)
}
+func (t *Tracer) GetCorrelationContextValue(key string) string {
+ tracer := getTracer()
Review Comment:
You have already get the tracer reference, why you need to get tracer again?
##########
plugins/core/tracing.go:
##########
@@ -175,6 +175,44 @@ func (t *Tracer) CleanContext() {
SetGLS(nil)
}
+func (t *Tracer) GetCorrelationContextValue(key string) string {
+ tracer := getTracer()
+ if tracer == nil {
+ return ""
+ }
+ span := tracer.ActiveSpan()
+ if span == nil {
+ return ""
+ }
+ reportedSpan, ok := span.(*RootSegmentSpan)
+ if !ok {
+ return ""
+ }
+ return reportedSpan.Context().GetCorrelationContextValue(key)
+}
+
+func (t *Tracer) SetCorrelationContextValue(key, value string) {
+ tracer := getTracer()
Review Comment:
Same here.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "mrproliu (via GitHub)" <gi...@apache.org>.
mrproliu commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1360670832
##########
tools/go-agent/instrument/plugins/instrument.go:
##########
@@ -107,8 +107,7 @@ func (i *Instrument) CouldHandle(opts *api.CompileOptions) bool {
// check the version of the framework could handler
version, err := i.tryToFindThePluginVersion(opts, ins)
if err != nil {
- logrus.Warnf("ignore the plugin %s, because: %s", ins.Name(), err)
- continue
+ logrus.Warnf("the plugin %s %s", ins.Name(), err)
Review Comment:
looks like it's still not updated?
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-go] Alipebt commented on pull request #104: Provide APIs to user and support correlationContext
Posted by "Alipebt (via GitHub)" <gi...@apache.org>.
Alipebt commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1732238922
Sure, I'll do that.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-go] wu-sheng commented on pull request #104: Provide APIs to user and support correlationContext
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1732231984
Could you update the branch up to the main branch to avoid `update branch` button shows up?
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "Alipebt (via GitHub)" <gi...@apache.org>.
Alipebt commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1360679078
##########
plugins/core/tracer.go:
##########
@@ -65,6 +65,10 @@ func (t *Tracer) Init(entity *reporter.Entity, rep reporter.Reporter, samp Sampl
t.Reporter.Boot(entity, t.cdsWatchers)
t.initFlag = 1
t.initMetricsCollect(meterCollectSecond)
+ t.correlation = &CorrelationConfig{
Review Comment:
sorry,I misunderstood it as supplementing comments on GitHub.I will resolve it.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "mrproliu (via GitHub)" <gi...@apache.org>.
mrproliu commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1359843863
##########
test/plugins/scenarios/trace-activation/main.go:
##########
@@ -0,0 +1,44 @@
+// 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
+
+import (
+ _ "github.com/apache/skywalking-go"
+ "net/http"
+)
+
+func consumerHandler(w http.ResponseWriter, r *http.Request) {
+ testTag()
+ testLog()
+ testGetSegmentID()
+ testGetSpanID()
+ testGetTraceID()
+ testSetOperationName()
+ testContext()
+ testContextCarrierAndCorrelation()
+}
+
+func main() {
+ http.HandleFunc("/consumer", consumerHandler)
Review Comment:
Could you help to add a `/provider` handler, and test whether the correlation works or not in the different segments?
##########
toolkit/trace/go.mod:
##########
@@ -0,0 +1,3 @@
+module github.com/apache/skywalking-go/toolkit/trace
Review Comment:
I think we only need to let the `github.com/apache/skywalking-go/toolkit` as a new module, `trace` is only a part of the `toolkit`. After this, you can add the `metrics` or `logs` if you have interests.
##########
plugins/core/operator/tracing.go:
##########
@@ -29,4 +29,8 @@ type TracingOperator interface {
CaptureContext() interface{}
ContinueContext(interface{})
CleanContext()
+
+ GetCorrelationContextValue(key string) string
+ SetCorrelationContextValue(key, val string)
+ SetCorrelationConfig(maxKeyCount, maxValueSize int)
Review Comment:
Config could not be set, it only read from the config file.
##########
test/plugins/scenarios/trace-activation/test_service.go:
##########
@@ -0,0 +1,92 @@
+// 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
+
+import (
+ "github.com/apache/skywalking-go/toolkit/trace"
Review Comment:
looks like this file is not format, and the CI is not detected?
##########
plugins/core/tracer.go:
##########
@@ -65,6 +65,10 @@ func (t *Tracer) Init(entity *reporter.Entity, rep reporter.Reporter, samp Sampl
t.Reporter.Boot(entity, t.cdsWatchers)
t.initFlag = 1
t.initMetricsCollect(meterCollectSecond)
+ t.correlation = &CorrelationConfig{
Review Comment:
looks like it has not been fixed?
##########
toolkit/trace/api.go:
##########
@@ -0,0 +1,81 @@
+// 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 trace
+
+func CreateEntrySpan(operationName string, extractor ExtractorRef) (s SpanRef, err error) {
+ return nil, err
+}
+
+// nolint
+func CreateExitSpan(operationName string, peer string, injector InjectorRef) (s SpanRef, err error) {
+ return nil, err
+}
+
+func CreateLocalSpan(operationName string) (s SpanRef, err error) {
+ return nil, err
+}
+
+func StopSpan() {
+}
+
+func CaptureContext() ContextSnapshotRef {
+ return nil
+}
+
+func ContinueContext(ctx ContextSnapshotRef) {
+}
+
+func SetOperationName(string) {
+}
+
+func GetTraceID() string {
+ return ""
+}
+
+func GetSegmentID() string {
+ return ""
+}
+
+func GetSpanID() int32 {
+ return -1
+}
+
+// nolint
+func SetTag(key string, value string) {
+}
+
+func SetLog(...string) {
Review Comment:
```suggestion
func AddLog(...string) {
```
##########
tools/go-agent/instrument/plugins/instrument.go:
##########
@@ -107,8 +107,7 @@ func (i *Instrument) CouldHandle(opts *api.CompileOptions) bool {
// check the version of the framework could handler
version, err := i.tryToFindThePluginVersion(opts, ins)
if err != nil {
- logrus.Warnf("ignore the plugin %s, because: %s", ins.Name(), err)
- continue
+ logrus.Warnf("the plugin %s %s", ins.Name(), err)
Review Comment:
Please give more comments and descriptions in there to explain why we can ignore it.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "mrproliu (via GitHub)" <gi...@apache.org>.
mrproliu commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1361735376
##########
tools/go-agent/instrument/plugins/instrument.go:
##########
@@ -107,8 +107,9 @@ func (i *Instrument) CouldHandle(opts *api.CompileOptions) bool {
// check the version of the framework could handler
version, err := i.tryToFindThePluginVersion(opts, ins)
if err != nil {
- logrus.Warnf("ignore the plugin %s, because: %s", ins.Name(), err)
- continue
+ // Local package (e.g. toolkit) does not have version.
Review Comment:
```suggestion
// Local package (e.g. replaced toolkit) does not have version.
```
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "Ecostack (via GitHub)" <gi...@apache.org>.
Ecostack commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1360360058
##########
docs/en/advanced-features/manual-apis/toolkit-trace.md:
##########
@@ -0,0 +1,124 @@
+# Tracing APIs
+
+## Add trace Toolkit
+
+toolkit/trace provides the APIs to enhance the trace context, such as createLocalSpan, createExitSpan, createEntrySpan, log, tag, prepareForAsync and asyncFinish.
+Add the toolkit dependency to your project.
+
+```go
+import "github.com/apache/skywalking-go/toolkit/trace"
+```
+
+## Use Native Tracing
+
+### Context Carrier
+
+The context carrier is used to pass the context between the difference application.
+
+When creating an Entry Span, you need to obtain the context carrier from the request. When creating an Exit Span, you need to write the context carrier into the target RPC request.
+
+```go
+type ExtractorRef func(headerKey string) (string, error)
+
+type InjectorRef func(headerKey, headerValue string) error
+```
+
+### Create Span
+
+Use `trace.CreateEntrySpan()` API to create entry span, and then use `SpanRef` to contain the reference of created span in agent kernel.
+
+- The first parameter is operation name of span
+- the second parameter is `InjectorRef`.
+
+```go
+spanRef, err := trace.CreateEntrySpan("operationName", InjectorRef)
+```
+
+Use `trace.CreateLocalSpan()` API to create local span
+
+- the only parameter is the operation name of span.
+
+```go
+spanRef, err := trace.CreateLocalSpan("operationName")
+```
+
+Use `trace.CreateExitSpan()` API to create exit span.
+
+- the first parameter is the operation name of span
+- the second parameter is the remote peer which means the peer address of exit operation.
+- the third parameter is the `ExtractorRef`
+
+```go
+spanRef, err := trace.CreateExitSpan("operationName", "peer", ExtractorRef)
+```
+
+Use `trace.StopSpan()` API to stop current span
+
+```go
+trace.StopSpan()
+```
+
+### Add Span’s Tag and Log
+
+Use `trace.SetLog` to record log in span.
+
+Use `trace.SetTag` to add tag to span, the parameters of tag are two String which are key and value respectively.
+
+```go
+trace.SetLog(...string)
+
+trace.SetTag("key","value")
+```
+
+### Async Prepare/Finish
+
+Use `trace.PrepareAsync()` to make current span still alive until `trace.AsyncFinish()` called.
Review Comment:
Maybe trace.PrepareAsync and trace.AsyncFinish could be aligned in the word order. I am not sure how the other functions are named but how about renaming trace.AsyncFinish to trace.FinishAsync?
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "Alipebt (via GitHub)" <gi...@apache.org>.
Alipebt commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1360681219
##########
tools/go-agent/instrument/plugins/instrument.go:
##########
@@ -107,8 +107,7 @@ func (i *Instrument) CouldHandle(opts *api.CompileOptions) bool {
// check the version of the framework could handler
version, err := i.tryToFindThePluginVersion(opts, ins)
if err != nil {
- logrus.Warnf("ignore the plugin %s, because: %s", ins.Name(), err)
- continue
+ logrus.Warnf("the plugin %s %s", ins.Name(), err)
Review Comment:
sorry,I misunderstood it as supplementing comments on GitHub.I will resolve it.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1757037821
@Alipebt Any update? This is stale for two weeks.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1751672141
@NecoLiang This is a new feature PR. If you have any question, post on here.
https://github.com/apache/skywalking/discussions
Or join slack to discuss.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1774760747
> BTW, @Ecostack For the `github.com/apache/skywalking-go/toolkit` version is not correct problem.
>
> I have added a new tag for this. Now, you can use `go get github.com/apache/skywalking-go/toolkit` to get the package.
@mrproliu Should we update the release doc about this? This seems to be an easy-to-forget thing.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "Ecostack (via GitHub)" <gi...@apache.org>.
Ecostack commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1360751576
##########
docs/en/advanced-features/manual-apis/toolkit-trace.md:
##########
@@ -0,0 +1,124 @@
+# Tracing APIs
+
+## Add trace Toolkit
+
+toolkit/trace provides the APIs to enhance the trace context, such as createLocalSpan, createExitSpan, createEntrySpan, log, tag, prepareForAsync and asyncFinish.
+Add the toolkit dependency to your project.
+
+```go
+import "github.com/apache/skywalking-go/toolkit/trace"
+```
+
+## Use Native Tracing
+
+### Context Carrier
+
+The context carrier is used to pass the context between the difference application.
+
+When creating an Entry Span, you need to obtain the context carrier from the request. When creating an Exit Span, you need to write the context carrier into the target RPC request.
+
+```go
+type ExtractorRef func(headerKey string) (string, error)
+
+type InjectorRef func(headerKey, headerValue string) error
+```
+
+### Create Span
+
+Use `trace.CreateEntrySpan()` API to create entry span, and then use `SpanRef` to contain the reference of created span in agent kernel.
+
+- The first parameter is operation name of span
+- the second parameter is `InjectorRef`.
+
+```go
+spanRef, err := trace.CreateEntrySpan("operationName", InjectorRef)
+```
+
+Use `trace.CreateLocalSpan()` API to create local span
+
+- the only parameter is the operation name of span.
+
+```go
+spanRef, err := trace.CreateLocalSpan("operationName")
+```
+
+Use `trace.CreateExitSpan()` API to create exit span.
+
+- the first parameter is the operation name of span
+- the second parameter is the remote peer which means the peer address of exit operation.
+- the third parameter is the `ExtractorRef`
+
+```go
+spanRef, err := trace.CreateExitSpan("operationName", "peer", ExtractorRef)
+```
+
+Use `trace.StopSpan()` API to stop current span
+
+```go
+trace.StopSpan()
+```
+
+### Add Span’s Tag and Log
+
+Use `trace.SetLog` to record log in span.
+
+Use `trace.SetTag` to add tag to span, the parameters of tag are two String which are key and value respectively.
+
+```go
+trace.SetLog(...string)
+
+trace.SetTag("key","value")
+```
+
+### Async Prepare/Finish
+
+Use `trace.PrepareAsync()` to make current span still alive until `trace.AsyncFinish()` called.
Review Comment:
Good argument, keeping is consistent is the better way.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "NecoLiang (via GitHub)" <gi...@apache.org>.
NecoLiang commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1751669862
I according to the official documentation to the introduction of the "github.com/apache/skywalking-go", after the project go build out of the question, prompt is as follows:
/ github.com/aliyun/alibaba-cloud-sdk-go@v1.61.1704/sdk/errors/server_error.go:21:2: zip: not a valid zip file;
/ github.com/spf13/viper@v1.16.0/internal/encoding/toml/codec.go:4:2: zip: not a valid zip file;
/ github.com/prometheus/client_golang@v1.12.2/prometheus/process_collector_other.go:20:2: zip: not a valid zip file
How can I solve this problem
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "Ecostack (via GitHub)" <gi...@apache.org>.
Ecostack commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1770349895
Not sure if this is the right place to mention this, but it looks like the documentation generation was unsuccessful:
https://skywalking.apache.org/docs/skywalking-go/next/en/advanced-features/manual-apis/toolkit-trace.md
<img width="1539" alt="Screenshot 2023-10-19 at 16 46 46" src="https://github.com/apache/skywalking-go/assets/8505607/4be2ef1b-8a5f-4fe2-ad89-c7f051cfc4c0">
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "Ecostack (via GitHub)" <gi...@apache.org>.
Ecostack commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1774645846
Been testing the new version and found some things. First of all, this feature looks amazing and I am happy about what it can provide! Please let me know if this is the right place to post or not.
### Toolkit/Trace API
The package github.com/apache/skywalking-go v0.3.0 does not expose the toolkit/trace API, it is a separate package.
Would it not be better if that is both coming from the skywalking-go package?
```
require (
github.com/apache/skywalking-go v0.3.0
github.com/apache/skywalking-go/toolkit v0.0.0-20231019114202-ff7ad0ddecba
)
```
### No trace.SetLog
According to the documentation, there should be a log method on the trace. It seems like it does not exist though. Either way, logging inside of a span is correctly reported.
Maybe it is best to remove the trace.SetLog from the documentation?
### Injector & Extractor Ref
There are two methods, `CreateEntrySpan(operationName string, extractor ExtractorRef)` and `CreateExitSpan(operationName string, peer string, injector InjectorRef)` which require either an **injector or extractor ref**.
How would I obtain these or use these methods? Maybe provide an example of how these can be used.
### Component unknown
Manual span entries have component value set to `unknown`. Can this be set manually or would it be possible to set this value somehow automatic, maybe the file name or such?
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1365155692
##########
docs/menu.yml:
##########
@@ -42,6 +42,10 @@ catalog:
path: /en/agent/plugin-configurations
- name: Transport Layer Security (TLS)
path: /en/advanced-features/grpc-tls
+ - name: Manual APIs
+ catalog:
+ - name: Tracing APIs
+ path: /en/advanced-features/manual-apis/toolkit-trace.md
Review Comment:
You should not add `.md` as suffix. All markdowns are transferred into HTML, so no md suffix.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "NecoLiang (via GitHub)" <gi...@apache.org>.
NecoLiang commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1751679716
> @NecoLiang This is a new feature PR. If you have any question, post on here.
>
> https://github.com/apache/skywalking/discussions
>
> Or join slack to discuss.
Thanks for your reply
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "Ecostack (via GitHub)" <gi...@apache.org>.
Ecostack commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1360360058
##########
docs/en/advanced-features/manual-apis/toolkit-trace.md:
##########
@@ -0,0 +1,124 @@
+# Tracing APIs
+
+## Add trace Toolkit
+
+toolkit/trace provides the APIs to enhance the trace context, such as createLocalSpan, createExitSpan, createEntrySpan, log, tag, prepareForAsync and asyncFinish.
+Add the toolkit dependency to your project.
+
+```go
+import "github.com/apache/skywalking-go/toolkit/trace"
+```
+
+## Use Native Tracing
+
+### Context Carrier
+
+The context carrier is used to pass the context between the difference application.
+
+When creating an Entry Span, you need to obtain the context carrier from the request. When creating an Exit Span, you need to write the context carrier into the target RPC request.
+
+```go
+type ExtractorRef func(headerKey string) (string, error)
+
+type InjectorRef func(headerKey, headerValue string) error
+```
+
+### Create Span
+
+Use `trace.CreateEntrySpan()` API to create entry span, and then use `SpanRef` to contain the reference of created span in agent kernel.
+
+- The first parameter is operation name of span
+- the second parameter is `InjectorRef`.
+
+```go
+spanRef, err := trace.CreateEntrySpan("operationName", InjectorRef)
+```
+
+Use `trace.CreateLocalSpan()` API to create local span
+
+- the only parameter is the operation name of span.
+
+```go
+spanRef, err := trace.CreateLocalSpan("operationName")
+```
+
+Use `trace.CreateExitSpan()` API to create exit span.
+
+- the first parameter is the operation name of span
+- the second parameter is the remote peer which means the peer address of exit operation.
+- the third parameter is the `ExtractorRef`
+
+```go
+spanRef, err := trace.CreateExitSpan("operationName", "peer", ExtractorRef)
+```
+
+Use `trace.StopSpan()` API to stop current span
+
+```go
+trace.StopSpan()
+```
+
+### Add Span’s Tag and Log
+
+Use `trace.SetLog` to record log in span.
+
+Use `trace.SetTag` to add tag to span, the parameters of tag are two String which are key and value respectively.
+
+```go
+trace.SetLog(...string)
+
+trace.SetTag("key","value")
+```
+
+### Async Prepare/Finish
+
+Use `trace.PrepareAsync()` to make current span still alive until `trace.AsyncFinish()` called.
Review Comment:
Maybe `trace.PrepareAsync` and `trace.AsyncFinish` could be aligned in the word order. I am not sure how the other functions are named but how about renaming `trace.AsyncFinish` to `trace.FinishAsync`?
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-go] wu-sheng commented on pull request #104: Provide APIs to user and support correlationContext
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1732232988
And please provide a new document to introduce this new set of APIs.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1360364246
##########
docs/en/advanced-features/manual-apis/toolkit-trace.md:
##########
@@ -0,0 +1,124 @@
+# Tracing APIs
+
+## Add trace Toolkit
+
+toolkit/trace provides the APIs to enhance the trace context, such as createLocalSpan, createExitSpan, createEntrySpan, log, tag, prepareForAsync and asyncFinish.
+Add the toolkit dependency to your project.
+
+```go
+import "github.com/apache/skywalking-go/toolkit/trace"
+```
+
+## Use Native Tracing
+
+### Context Carrier
+
+The context carrier is used to pass the context between the difference application.
+
+When creating an Entry Span, you need to obtain the context carrier from the request. When creating an Exit Span, you need to write the context carrier into the target RPC request.
+
+```go
+type ExtractorRef func(headerKey string) (string, error)
+
+type InjectorRef func(headerKey, headerValue string) error
+```
+
+### Create Span
+
+Use `trace.CreateEntrySpan()` API to create entry span, and then use `SpanRef` to contain the reference of created span in agent kernel.
+
+- The first parameter is operation name of span
+- the second parameter is `InjectorRef`.
+
+```go
+spanRef, err := trace.CreateEntrySpan("operationName", InjectorRef)
+```
+
+Use `trace.CreateLocalSpan()` API to create local span
+
+- the only parameter is the operation name of span.
+
+```go
+spanRef, err := trace.CreateLocalSpan("operationName")
+```
+
+Use `trace.CreateExitSpan()` API to create exit span.
+
+- the first parameter is the operation name of span
+- the second parameter is the remote peer which means the peer address of exit operation.
+- the third parameter is the `ExtractorRef`
+
+```go
+spanRef, err := trace.CreateExitSpan("operationName", "peer", ExtractorRef)
+```
+
+Use `trace.StopSpan()` API to stop current span
+
+```go
+trace.StopSpan()
+```
+
+### Add Span’s Tag and Log
+
+Use `trace.SetLog` to record log in span.
+
+Use `trace.SetTag` to add tag to span, the parameters of tag are two String which are key and value respectively.
+
+```go
+trace.SetLog(...string)
+
+trace.SetTag("key","value")
+```
+
+### Async Prepare/Finish
+
+Use `trace.PrepareAsync()` to make current span still alive until `trace.AsyncFinish()` called.
Review Comment:
I think this is a reference from the first Java agent. https://skywalking.apache.org/docs/skywalking-java/v9.0.0/en/setup/service-agent/java-agent/java-plugin-development-guide/#async-span-apis
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "Alipebt (via GitHub)" <gi...@apache.org>.
Alipebt commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1360679078
##########
plugins/core/tracer.go:
##########
@@ -65,6 +65,10 @@ func (t *Tracer) Init(entity *reporter.Entity, rep reporter.Reporter, samp Sampl
t.Reporter.Boot(entity, t.cdsWatchers)
t.initFlag = 1
t.initMetricsCollect(meterCollectSecond)
+ t.correlation = &CorrelationConfig{
Review Comment:
sorry,I misunderstood it as supplementing comments on GitHub.I will resolve it.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "Alipebt (via GitHub)" <gi...@apache.org>.
Alipebt commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1765979774
Oh! I accidentally deleted the CI tests about trace in my previous submission. I will resubmit it now.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1774661794
@Ecostack Could you copy your report at here? https://github.com/apache/skywalking/discussions
It is better for others to find discussion context.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "mrproliu (via GitHub)" <gi...@apache.org>.
mrproliu commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1774746232
BTW, @Ecostack For the `github.com/apache/skywalking-go/toolkit` version is not correct problem.
I have added a new tag for this. Now, you can use `go get github.com/apache/skywalking-go/toolkit` to get the package.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "mrproliu (via GitHub)" <gi...@apache.org>.
mrproliu merged PR #104:
URL: https://github.com/apache/skywalking-go/pull/104
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1770359820
Here it is, https://skywalking.apache.org/docs/skywalking-go/next/en/advanced-features/manual-apis/toolkit-trace/
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1360375046
##########
docs/en/advanced-features/manual-apis/toolkit-trace.md:
##########
@@ -0,0 +1,124 @@
+# Tracing APIs
+
+## Add trace Toolkit
+
+toolkit/trace provides the APIs to enhance the trace context, such as createLocalSpan, createExitSpan, createEntrySpan, log, tag, prepareForAsync and asyncFinish.
+Add the toolkit dependency to your project.
+
+```go
+import "github.com/apache/skywalking-go/toolkit/trace"
+```
+
+## Use Native Tracing
+
+### Context Carrier
+
+The context carrier is used to pass the context between the difference application.
+
+When creating an Entry Span, you need to obtain the context carrier from the request. When creating an Exit Span, you need to write the context carrier into the target RPC request.
+
+```go
+type ExtractorRef func(headerKey string) (string, error)
+
+type InjectorRef func(headerKey, headerValue string) error
+```
+
+### Create Span
+
+Use `trace.CreateEntrySpan()` API to create entry span, and then use `SpanRef` to contain the reference of created span in agent kernel.
+
+- The first parameter is operation name of span
+- the second parameter is `InjectorRef`.
+
+```go
+spanRef, err := trace.CreateEntrySpan("operationName", InjectorRef)
+```
+
+Use `trace.CreateLocalSpan()` API to create local span
+
+- the only parameter is the operation name of span.
+
+```go
+spanRef, err := trace.CreateLocalSpan("operationName")
+```
+
+Use `trace.CreateExitSpan()` API to create exit span.
+
+- the first parameter is the operation name of span
+- the second parameter is the remote peer which means the peer address of exit operation.
+- the third parameter is the `ExtractorRef`
+
+```go
+spanRef, err := trace.CreateExitSpan("operationName", "peer", ExtractorRef)
+```
+
+Use `trace.StopSpan()` API to stop current span
+
+```go
+trace.StopSpan()
+```
+
+### Add Span’s Tag and Log
+
+Use `trace.SetLog` to record log in span.
+
+Use `trace.SetTag` to add tag to span, the parameters of tag are two String which are key and value respectively.
+
+```go
+trace.SetLog(...string)
+
+trace.SetTag("key","value")
+```
+
+### Async Prepare/Finish
+
+Use `trace.PrepareAsync()` to make current span still alive until `trace.AsyncFinish()` called.
Review Comment:
- `Prepare Async` is more about `prepare for running in the async mode.
- `Async Finish` represents the asynchronous finishing of the given span.
These were why they are named in a different order.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "mrproliu (via GitHub)" <gi...@apache.org>.
mrproliu commented on code in PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#discussion_r1365178798
##########
docs/menu.yml:
##########
@@ -42,6 +42,10 @@ catalog:
path: /en/agent/plugin-configurations
- name: Transport Layer Security (TLS)
path: /en/advanced-features/grpc-tls
+ - name: Manual APIs
+ catalog:
+ - name: Tracing APIs
+ path: /en/advanced-features/manual-apis/toolkit-trace.md
Review Comment:
@Alipebt Please create a new PR to fix it.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Provide APIs to user and support correlationContext [skywalking-go]
Posted by "Alipebt (via GitHub)" <gi...@apache.org>.
Alipebt commented on PR #104:
URL: https://github.com/apache/skywalking-go/pull/104#issuecomment-1757359161
> @Alipebt Any update? This is stale for two weeks.
Yes, just got over the holidays and I will provide an update shortly.
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org