<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:37:58 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[GODRIVER-2172] Include context in Command Events</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-2172</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;It would be useful to include the context.Context in the&#160;CommandStartedEvent&#160;and CommandFinishedEvent structs so extra application contextual information can be included in metrics. Things such as the calling function or the source of the query would be great to include in our metrics but right now there&apos;s no way to connect these events to their original function calls. If the context was passed along then a value could be added to the context and then retrieved later from the event.&lt;/p&gt;

&lt;p&gt;I would be willing to contribute these changes if this is an acceptable feature. I would add a `Ctx context.context` field to `CommandStartedEvent` and `CommandFinishedEvent`.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1889035">GODRIVER-2172</key>
            <summary>Include context in Command Events</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13202">Works as Designed</resolution>
                                        <assignee username="benji.rewis@mongodb.com">Benji Rewis</assignee>
                                    <reporter username="james@getadmiral.com">James Hartig</reporter>
                        <labels>
                    </labels>
                <created>Mon, 4 Oct 2021 14:52:54 +0000</created>
                <updated>Fri, 27 Oct 2023 13:16:23 +0000</updated>
                            <resolved>Mon, 11 Oct 2021 17:35:45 +0000</resolved>
                                                                    <component>Monitoring</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="4116355" author="benji.rewis" created="Mon, 11 Oct 2021 17:35:45 +0000"  >&lt;p&gt;Sounds good! Feel free to reopen this ticket if anything changes.&lt;/p&gt;</comment>
                            <comment id="4116272" author="james@getadmiral.com" created="Mon, 11 Oct 2021 17:05:34 +0000"  >&lt;p&gt;We were already using those but I wasn&apos;t aware that the context was the same as the one passed to the command. It makes sense thinking about it now but I assumed the monitors were some sort of asynchronous callback that happened out-of-band. It does seem like that will work so I think this can be closed. I appreciate the help!&lt;/p&gt;</comment>
                            <comment id="4116179" author="benji.rewis" created="Mon, 11 Oct 2021 16:23:43 +0000"  >&lt;p&gt;Got it, that makes sense! I&apos;m curious if you could just use the &lt;tt&gt;Started&lt;/tt&gt;, &lt;tt&gt;Succeeded&lt;/tt&gt; and &lt;tt&gt;Failed&lt;/tt&gt; &lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/blob/master/event/monitoring.go#L61-L63&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;callbacks&lt;/a&gt; defined on a &lt;tt&gt;CommandMonitor&lt;/tt&gt; to access the context of the published event. Is there a reason you need the context stored on the actual command struct?&lt;/p&gt;</comment>
                            <comment id="4113778" author="james@getadmiral.com" created="Fri, 8 Oct 2021 19:03:51 +0000"  >&lt;p&gt;Hey Benji Rewis,&lt;/p&gt;

&lt;p&gt;It depends on the application, it could be as simple as a line number or function name that originated the query or it could be a userID. With our other drivers we have a map that we store in the context and then when we publish metrics as a part of that query we include that map as labels on the metric. I like that the Mongo driver publishes events but the events happening out-of-band lose the ability to get this information without being able to store it somehow. I only suggested the context because it&apos;s already being plumbed through all of the code but if there was another way to store key-value pairs and have them passed along, that would be acceptable too.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;</comment>
                            <comment id="4113746" author="benji.rewis" created="Fri, 8 Oct 2021 18:53:13 +0000"  >&lt;p&gt;Hello again, &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=james%40getadmiral.com&quot; class=&quot;user-hover&quot; rel=&quot;james@getadmiral.com&quot;&gt;james@getadmiral.com&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;The structure of both &lt;tt&gt;CommandStartedEvent&lt;/tt&gt; and &lt;tt&gt;CommandFinishedEvent&lt;/tt&gt; are defined by our cross-drivers &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/command-monitoring/command-monitoring.rst#api&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;specification on command monitoring&lt;/a&gt;. So, normally, adding a field to either struct would probably require a cross-driver&#8217;s change.&lt;/p&gt;

&lt;p&gt;contexts, however, are unique to Go, and so a cross-drivers change does not make sense. While it doesn&#8217;t seem too tough to add the underlying context to published events, I&#8217;d love to hear a little more about your use-case.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Things such as the calling function or the source of the query&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Are you referring to the function from your own application that is calling the Go driver API? I.e. are you trying to track which section of your own code is producing a particular event in the driver?&lt;/p&gt;

&lt;p&gt;And, what information would you be adding to the context? A unique &quot;function caller&quot; token?&lt;/p&gt;</comment>
                            <comment id="4101229" author="benji.rewis" created="Tue, 5 Oct 2021 00:33:46 +0000"  >&lt;p&gt;Hello &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=james%40getadmiral.com&quot; class=&quot;user-hover&quot; rel=&quot;james@getadmiral.com&quot;&gt;james@getadmiral.com&lt;/a&gt;&#160;and thanks for your improvement suggestion! We&apos;re taking a look now.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10257" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Documentation Changes</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="11861"><![CDATA[Not Needed]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hznvy7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>