-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
airbyte-metrics/server: add tags to root span from OAuth handler #20468
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,8 +70,10 @@ public OAuthHandler(final ConfigRepository configRepository, | |
|
||
public OAuthConsentRead getSourceOAuthConsent(final SourceOauthConsentRequest sourceOauthConsentRequest) | ||
throws JsonValidationException, ConfigNotFoundException, IOException { | ||
ApmTraceUtils.addTagsToTrace(Map.of(WORKSPACE_ID_KEY, sourceOauthConsentRequest.getWorkspaceId(), SOURCE_DEFINITION_ID_KEY, | ||
sourceOauthConsentRequest.getSourceDefinitionId())); | ||
final Map<String, Object> traceTags = Map.of(WORKSPACE_ID_KEY, sourceOauthConsentRequest.getWorkspaceId(), SOURCE_DEFINITION_ID_KEY, | ||
sourceOauthConsentRequest.getSourceDefinitionId()); | ||
ApmTraceUtils.addTagsToTrace(traceTags); | ||
ApmTraceUtils.addTagsToRootSpan(traceTags); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [non-blocking nit] when I've done instrumentation like this in the past, the strategy was to append as much information to the trace / root-span at the top level before getting into any individual controller. This looks like a global rootSpanHelper which intercepts /every/ request (e.g. "request middleware") and:
Then, in the controller itself, you only have to add new information (the source_id in this case). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this idea of helper/request middleware. This abstraction could also help us switch tracking backend (sentry/datadog) with a single interface. @evantahler could it fit a bigger project we'd have in Q1? |
||
final StandardSourceDefinition sourceDefinition = | ||
configRepository.getStandardSourceDefinition(sourceOauthConsentRequest.getSourceDefinitionId()); | ||
final OAuthFlowImplementation oAuthFlowImplementation = oAuthImplementationFactory.create(sourceDefinition); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question] If the framework is wrapping all requests in a span, how would we not have a span? Perhaps if Data dog is disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evantahler Good catch. This method should check if
activeSpan
is notnull
. It will benull
when the DataDog Java agent is not present. cc: @alafanechereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. Isn't
if activeSpan instanceof MutableSpan
already checking anot null
by itself?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evantahler
MutableSpan
is a datadog interface. AndSpan
andGlobalTracer.get().activeSpan()
are fromopentelemetry
. So when datadog is disabled we might not received Span object implementing the MutableSpan interface, hence the importance of this check. Am I right @jdpgrailsdev ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alafanechere Correct on both accounts. The
instanceof
check does protect us fromnull
, as it will resolve tofalse
.MutableSpan
is a DataDog only class, so if a customer uses a different APM product that supports OpenTracing, that check protects us from calling methods that don't exist on the object.