opampextension currently does the following:
enter image description here
"I have a question: Since the instanceid of opampextension uniquely identifies the OTEL agent, and service.instance.id also represents an OTEL agent, why doesn't opampextension directly read the value of service.instance.id, but instead sets a separate configuration item for it?"
If the values of opampextension's instanceid and service.instance.id are inconsistent, the connection between opampextension and self-monitoring metrics needs to be identified by (service.instance.id, instanceid).
Keeping them consistent would simplify the connection between the two.
Per the OpAMP specification the instance id from the agent must be a ULID whereas the collector's instance id is a UUID. The code you linked shows that an instance ID can be provided by the configuration, otherwise it is read from the collector's
service.instance.idproperty (which is a UUID). A server receiving the ULID can disaggregate the ULID into a timestamp and a UUID (sample code). If you have more questions, please raise an issue in the collector-contrib repository or the opamp-go repository. You can also ask any questions in the #otel-agentmanwg channel in the CNCF slack. Thank you!