Connecting to SkyWalking with an Extension
This section uses SkyWalking as an example to describe how to integrate a function with monitoring, observability, security, and supervision tools via extension APIs.
Compiling an extension locally with a compiled language will generate a binary file. To use a non-compiled language, package and upload the required dependencies for the function, and ensure that the language is compatible with the function's runtime.
Embed the SkyWalking agent in the extension code to monitor function requests through the extension.
Sample code: skywalking-go.zip
func startSkywalkingAgent() { r, err := reporter.NewGRPCReporter("10.174.242.117:11800", reporter.WithCDS(100)) if err != nil { log.Fatalf("new reporter error %v \n", err) return } defer r.Close() tracer, err := go2sky.NewTracer("testservice", go2sky.WithReporter(r)) if err != nil { log.Fatalf("create tracer error %v \n", err) return } go2sky.SetGlobalTracer(tracer) sm, err := httpPlugin.NewServerMiddleware(go2sky.GetGlobalTracer()) if err != nil { log.Fatalf("create server middleware error %v \n", err) return } http.HandleFunc(invokeURL, sm(RequestHandler{}).ServeHTTP) http.ListenAndServe(currentExtensionAddr, nil) }
Replace 10.174.242.117:11800 with your SkyWalking collector IP address and testservice with your service name.
Compile the code locally to generate a binary file. Then package the binary file and the .sh script file prefixed with extension, and upload them as a dependency. The file structure of the extension dependency package is as follows:
extension -
extensionDemo.sh
Extension # Generated binary file
Service page after successful connection
Endpoint page
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.