|
5 | 5 |
|
6 | 6 | import com.google.auto.service.AutoService; |
7 | 7 | import datadog.trace.agent.tooling.InstrumenterModule; |
| 8 | +import datadog.trace.api.Config; |
8 | 9 | import net.bytebuddy.asm.Advice; |
9 | 10 | import org.apache.spark.SparkContext; |
| 11 | +import org.apache.spark.util.Utils; |
10 | 12 |
|
11 | 13 | @AutoService(InstrumenterModule.class) |
12 | 14 | public class Spark213Instrumentation extends AbstractSparkInstrumentation { |
@@ -42,29 +44,29 @@ public void methodAdvice(MethodTransformer transformer) { |
42 | 44 | public static class InjectListener { |
43 | 45 | @Advice.OnMethodEnter(suppress = Throwable.class) |
44 | 46 | public static void enter(@Advice.This SparkContext sparkContext) { |
45 | | - // checking whether OpenLineage integration is available and that it supports tags |
46 | | - // Disabling this mechanism for this PR. Will be enabled with provided with Config option. |
47 | | - // if (Utils.classIsLoadable("io.openlineage.spark.agent.OpenLineageSparkListener") |
48 | | - // && Utils.classIsLoadable( |
49 | | - // "io.openlineage.spark.agent.facets.builder.TagsRunFacetBuilder")) { |
50 | | - // if (!sparkContext.conf().contains("spark.extraListeners")) { |
51 | | - // sparkContext |
52 | | - // .conf() |
53 | | - // .set("spark.extraListeners", |
54 | | - // "io.openlineage.spark.agent.OpenLineageSparkListener"); |
55 | | - // } else { |
56 | | - // String extraListeners = sparkContext.conf().get("spark.extraListeners"); |
57 | | - // if |
58 | | - // (!extraListeners.contains("io.openlineage.spark.agent.OpenLineageSparkListener")) { |
59 | | - // sparkContext |
60 | | - // .conf() |
61 | | - // .set( |
62 | | - // "spark.extraListeners", |
63 | | - // extraListeners + |
64 | | - // ",io.openlineage.spark.agent.OpenLineageSparkListener"); |
65 | | - // } |
66 | | - // } |
67 | | - // } |
| 47 | + // Checking whether OpenLineage integration is available and that it supports tags |
| 48 | + // Disabling this mechanism for this PR. Will be enabled with provided with Config |
| 49 | + // option. |
| 50 | + |
| 51 | + if (Config.get().isDataJobsOpenLineageEnabled() |
| 52 | + && Utils.classIsLoadable("io.openlineage.spark.agent.OpenLineageSparkListener") |
| 53 | + && Utils.classIsLoadable( |
| 54 | + "io.openlineage.spark.agent.facets.builder.TagsRunFacetBuilder")) { |
| 55 | + if (!sparkContext.conf().contains("spark.extraListeners")) { |
| 56 | + sparkContext |
| 57 | + .conf() |
| 58 | + .set("spark.extraListeners", "io.openlineage.spark.agent.OpenLineageSparkListener"); |
| 59 | + } else { |
| 60 | + String extraListeners = sparkContext.conf().get("spark.extraListeners"); |
| 61 | + if (!extraListeners.contains("io.openlineage.spark.agent.OpenLineageSparkListener")) { |
| 62 | + sparkContext |
| 63 | + .conf() |
| 64 | + .set( |
| 65 | + "spark.extraListeners", |
| 66 | + extraListeners + ",io.openlineage.spark.agent.OpenLineageSparkListener"); |
| 67 | + } |
| 68 | + } |
| 69 | + } |
68 | 70 |
|
69 | 71 | // We want to add the Datadog listener as the first listener |
70 | 72 | AbstractDatadogSparkListener.listener = |
|
0 commit comments