-
Notifications
You must be signed in to change notification settings - Fork 312
Fix tracer OpenLineage instrumentation #9487
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
Open
pawel-big-lebowski
wants to merge
1
commit into
master
Choose a base branch
from
pawel.leszczynski/fix-openlineae-instrumentation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+31
−3
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import datadog.trace.api.BaseHash; | ||
import datadog.trace.api.Config; | ||
import datadog.trace.api.DDTags; | ||
import datadog.trace.api.DDTraceId; | ||
|
@@ -180,7 +181,9 @@ public void setupOpenLineage(DDTraceId traceId) { | |
"_dd.trace_id:" | ||
+ traceId.toString() | ||
+ ";_dd.ol_intake.emit_spans:false;_dd.ol_service:" | ||
+ sparkServiceName | ||
+ getServiceForOpenLineage(sparkConf, isRunningOnDatabricks) | ||
+ ";_dd.ol_intake.base_hash:" | ||
+ BaseHash.getBaseHashStr() | ||
+ ";_dd.ol_app_id:" | ||
+ appId); | ||
return; | ||
|
@@ -669,6 +672,9 @@ public void onTaskEnd(SparkListenerTaskEnd taskEnd) { | |
} | ||
} | ||
|
||
// OpenLineage call should be prior to method return statements | ||
notifyOl(x -> openLineageSparkListener.onTaskEnd(x), taskEnd); | ||
|
||
// Only sending failing tasks | ||
if (!(taskEnd.reason() instanceof TaskFailedReason)) { | ||
return; | ||
|
@@ -687,8 +693,6 @@ public void onTaskEnd(SparkListenerTaskEnd taskEnd) { | |
|
||
Properties props = stageProperties.get(stageSpanKey); | ||
sendTaskSpan(stageSpan, taskEnd, props); | ||
|
||
notifyOl(x -> openLineageSparkListener.onTaskEnd(x), taskEnd); | ||
} | ||
|
||
public static boolean classIsLoadable(String className) { | ||
|
@@ -1292,6 +1296,30 @@ private static String getSparkServiceName(SparkConf conf, boolean isRunningOnDat | |
return sparkAppName; | ||
} | ||
|
||
private static String getServiceForOpenLineage(SparkConf conf, boolean isRunningOnDatabricks) { | ||
// Service for OpenLineage in Databricks is not supported yet | ||
if (isRunningOnDatabricks) { | ||
return null; | ||
} | ||
|
||
// Keep service set by user, except if it is only "spark" or "hadoop" that can be set by USM | ||
String serviceName = Config.get().getServiceName(); | ||
if (Config.get().isServiceNameSetByUser() | ||
&& !"spark".equals(serviceName) | ||
&& !"hadoop".equals(serviceName)) { | ||
log.debug("Service '{}' explicitly set by user, not using the application name", serviceName); | ||
return serviceName; | ||
} | ||
|
||
String sparkAppName = conf.get("spark.app.name", null); | ||
if (sparkAppName != null) { | ||
log.info( | ||
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. Should this one be |
||
"Using Spark application name '{}' as the Datadog service for OpenLineage", sparkAppName); | ||
} | ||
|
||
return sparkAppName; | ||
} | ||
|
||
private static void reportKafkaOffsets( | ||
final String appName, final AgentSpan span, final SourceProgress progress) { | ||
if (!traceConfig().isDataStreamsEnabled() | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
thanks for adding that, but actually given that you support also container tags, it would be better to skip the base hash and add directly the process tags .
These are currently enabled for jvm 21 and will be enabled by default on next version