Prerequisites
Version requirements
GoLand 2021.2 or later.
mosn-intellij for GoLand (mosn mecha) 1.0.4 or later.
NoteFor legacy projects created with a version of the mecha plugin for GoLand earlier than 1.0.4, you must manually upgrade the project after you install the new version of mosn-intellij.
Seamless project upgrade
For projects created with mosn-intellij versions earlier than 1.0.4, you can use the one-click refresh feature to upgrade to the latest scaffolding feature set. This action performs the following operations:
Updates the makefile.
You can pull the compilation and startup scripts for MOSN.
Creates plugin version information.
Creates the `application.properties` project properties file.
Automatically upgrades Go mod to version 1.18.
To upgrade, perform the following steps:
Right-click any folder in the project.
In the menu, select Mosn Go Plugin > Refresh.
After you run the command, the old project scaffold is automatically updated. The following figure shows an example.
Step 1: Create a Zipkin plugin
You can create a Zipkin plugin in one of the following two ways:
Before you start, ensure that Go module integration is enabled in GoLand. To do this, navigate to Settings > Go > Go Modules and select Enable Go Modules integration.
Create a Zipkin plugin by creating a new project
The following steps use the Trace plugin type as an example:
On the GoLand Projects home page, click New Project.

Select Mosn Plugin. Specify the plugin name and project location. Set Plugin Type to Trace and set Trace Type to zipkin.

Click Create.
Add a Zipkin plugin to an existing project
The following steps use go-plugin-quickstart as an example:
Right-click any node in the project, and then select New > Mosn Plugin.

Specify the plugin name. Set Plugin Type to Trace and set Trace Type to zipkin.

Click OK.
The completed project is as follows:

Typically, the automatically generated observability code can run without modification.
If needed, you can modify the code in the `plugins/traces` module of the project root directory. For example, to add a reporting tag, you can append the key-value pair to `ParseVariable` in `span.go`.
user@user-m1 traces % tree . └── zipkin └── main ├── config.go ├── driver.go ├── reporter_factory.go ├── span.go └── tracer.go 2 directories, 5 filesThe `etc/ant/env_conf` file contains the required environment configurations. When you start the service locally, the service automatically connects to the address specified by the `SKY_WALKING_ADDRESS` variable in this file.
By default, the Pod IP is automatically used when the local container starts. The `SKY_WALKING_ADDRESS` value does not need to be changed.
To associate the observability plugin with a deployment in a test or production environment, configure the observability address by setting the `ZIPKIN_ADDRESS` environment variable in the injection rule.
The format is: `ZIPKIN_ADDRESS=http://ip:9411/api/v2/spans`.

When the
MOSN_GENERATOR_SAPN_ENABLEDenvironment variable is set totrue, MOSN generates a trace ID at the first node.
Step 2: Compile the plugin
After you create the observability plugin in the GoLand IDE, MOSN mecha automatically generates the observability code. It also creates a local Docker Compose file for the observability container in the `etc/docker-compose` root folder. This file is used to start the Zipkin components and simplify local development.
You can compile plugins in GoLand using the UI or keyboard shortcuts. Note that plugin development is not currently supported on Windows systems. To compile a single plugin with a keyboard shortcut, use
on macOS or Alt+Ctrl+Win+B on Linux. You can also right-click a folder within the `configs` or `plugins` node and select the corresponding option from the menu.

After compilation, the binary plugin is located in the `build/codecs/bundle/support` directory:
user@user-m1 support % tree
.
└── traces
└── zipkin
├── config.json
├── metadata.json
├── trace-zipkin-a5e036f9.so
└── trace-zipkin.md5
2 directories, 4 files
Step 3: Run the plugin
Start the functional modules in the following order:
Start the Zipkin container service.
The
etcdirectory contains the Docker plugin container image:user@user-4 docker-compose % tree . └── traces └── zipkin └── docker-compose.yaml 2 directories, 1 fileIn the `traces/zipkin` folder, run the following command to start the Zipkin server:
docker compose up -dStart the Sidecar.
Start the xRPC server and client.
For instructions on how to start the Sidecar and xRPC services, see the xRPC lessons in the protocol extension course. After you make a call, you can view the observable data.
The new version of mosn-intellij automatically triggers service publishing and subscription.
The Zipkin console may require you to refresh it multiple times to display trace information.
For trace linking to work, the original protocol must propagate the Zipkin trace information. Otherwise, the trace link will be broken.
By default, the xRPC client request does not carry trace information. To enable trace propagation, add the Zipkin trace information to the header in the `configs/codecs/xrpc/request_template.txt` file. This allows MOSN to parse the trace information.


