open-telemetry/opamp-spec

Unable to set multiple Capabilities in a single message when using Java/Kotlin protobuf

nephyst opened this issue · 4 comments

AgentCapabilities capabilities = 4;

ServerCapabilities capabilities = 7;

The intent of these fields is to pack multiple flags into a single field. According to the protobuf docs, Enum fields only allow a single value. When compiled to Java or Kotlin the generated objects do not allow for setting multiple capability flags to a single enum.

This can be fixed by changing the field to be an int32 with manual bit packing, or by repeating the enum fields.

This is the setCapabilities method in the java ServerToAgent object builder:

      public Builder setCapabilities(opamp.proto.Opamp.ServerCapabilities value) {
        if (value == null) {
          throw new NullPointerException();
        }
        
        capabilities_ = value.getNumber();
        onChanged();
        return this;
      }

I think we need to change the bit fields to uint64. The enum declarations can stay to show what the bit values are.

@nephyst thanks for reporting the problem. Does this fix the problem in Java/Kotlin: #125 ?

Yes, thank you!