title: Custom protobuf options of message of type Any in Go
body: <p>I have a GRPC service defined like:</p>
  <pre><code>message SendEventRequest {
    string producer = 1;
    google.protobuf.Any event = 2;
  }
  
  message SendEventResponse {
    string event_name = 1;
    string status = 2;
  }
  
  service EventService {
    rpc Send(SendEventRequest) returns (SendEventResponse);
  }
  </code></pre>
  <p>I also have defined a custom message option:</p>
  <pre><code>extend google.protobuf.MessageOptions {
    // event_name is the unique name of the event sent by the clients
    string event_name = 50000;
  }
  </code></pre>
  <p>What I want to achieve is have clients create custom proto messages that set the <code>event_name</code> option to a &quot;constant&quot;. For instance:</p>
  <pre><code>message SomeCustomEvent {
    option (mypackage.event_name) = &quot;some_custom_event&quot;;
  
    string data = 1;
    ...
  }
  </code></pre>
  <p>That way the service can keep track of what events are being sent. When I do something like this I'm able to get the value of the option from a specific <code>proto.Message</code>:</p>
  <pre class="lang-golang prettyprint-override"><code>_, md := descriptor.MessageDescriptorProto(SomeCustomEvent)
  mOpts := md.GetOptions()
  eventName := proto.GetExtension(mOpts, mypackage.E_EventName)
  </code></pre>
  <p>However, when the message is of type <code>github.com/golang/protobuf/ptypes/any.Any</code> the options are nil. How can I retrieve the <code>event_name</code> from the message? I've come across the <code>protoregistry.MessageTypeResolver</code>, which looks like it might help, but I would need to figure out a way to dynamically update the proto definitions of the events when clients integrate.</p>