Need help in Plugin Development #13112
vivek-c-singh
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wrote the plugin for couchbase datadase for qb statement and query interception just like elastic search plugin it is registering by point method i print the log but in intercepter after and before method not executed while running sample application.
I tried all the steps to print the log for agent it is not printing after auto-instrumentation without my plugin as well i set all the env variables and config file tried please help me in printing log and debug the agent
Also i am getting intermittent issue "
go: finding module for package github.com/bmizerany/assert
go: finding module for package github.com/apache/skywalking-go/plugin/trace
go: found github.com/bmizerany/assert in github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
go: finding module for package github.com/apache/skywalking-go/plugin/trace
go: github.com/apache/skywalking-go/tools/go-agent/instrument/plugins imports
github.com/apache/skywalking-go/plugin/trace: module github.com/apache/skywalking-go@latest found (v0.5.0), but does not contain package github.com/apache/skywalking-go/plugin/trace"
I tird the steps to use gork sync , replace directory but still this issue is coming
Here is my Instrumentation.go
// 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 couchbase
import (
"embed"
//"fmt"
"log"
)
var fs embed.FS
//skywalking:nocopy
type Instrument struct {
}
func NewInstrument() *Instrument {
return &Instrument{}
}
func (i *Instrument) Name() string {
return "couchbase"
}
func (i *Instrument) BasePackage() string {
return "github.com/couchbase/gocb/v2"
}
func (i *Instrument) VersionChecker(version string) bool {
// Return true for all versions of the Couchbase Go SDK
return true
}
func (i *Instrument) Points() []*instrument.Point {
log.Println("[DEBUG] Couchbase plugin Points() method is being executed")
return []*instrument.Point{
{
PackagePath: "github.com/couchbase/gocb/v2", // Correct package path for the Cluster struct
At: instrument.NewMethodEnhance("Cluster", "Query", // Use NewMethodEnhance for instance methods
instrument.WithArgsCount(2), // Query takes 2 arguments: query string and options
instrument.WithArgType(0, "string"), // First argument is the query string
instrument.WithArgType(1, "*QueryOptions"), // Second argument is a pointer to QueryOptions
instrument.WithResultCount(2), // Returns 2 results: QueryResult and error
instrument.WithResultType(0, "*QueryResult"), // First result is QueryResult
instrument.WithResultType(1, "error")), // Second result is error
Interceptor: "QueryInterceptor",
},
}
}
func (i *Instrument) FS() *embed.FS {
return &fs
}
Intercepter.go
package couchbase
import (
"fmt"
"log"
)
type QueryInterceptor struct{}
func (q *QueryInterceptor) BeforeInvoke(invocation operator.Invocation) error {
log.Println("[DEBUG] Couchbase QueryInterceptor BeforeInvoke: Interceptor is running")
}
func (q *QueryInterceptor) AfterInvoke(invocation operator.Invocation, result ...interface{}) error {
log.Println("[DEBUG] Couchbase QueryInterceptor AfterInvoke: Interceptor is running")
}
Beta Was this translation helpful? Give feedback.
All reactions