Question: OK, I spent quiet some time figuring out how to configure stuff to have DataDog trace ID in logs but couldn't get it working. To be clear what I'm looking for is to see trace IDs in logs message, the same way that adding `spring-cloud-starter-sleuth` to the classpath, automatically configure Slf4j/Logback to show trace IDs in log messages.

Where I've started: 

1. We've got a simple web spring boot application running as a Docker container deployed as an AWS Elastic BeansTalk, whose logs go to CloudWatch and we read them there.
2. We have DataDog as a Java agent (thus no dependencies in pom.xml)
3. We have SLF4J/Logback in our dependencies list.
4. There's no other related depndencies (like `dd-trace-ot` or any `opertracing` libs)

What I did so far: 

1. I found on SO that adding `opentracing-spring-cloud-starter` will add log integration automatically. But I couldn't get it working.
2. On DD website, it says configuring the pattern is enough to see the IDs, but in our case it didn't work. (is it because we don't have our logs a JSON?). Also, adding `dd-trace-ot` didn't help.

Notes: 

1. We can't switch to JSON logs.
2. We can't switch to any other library (e.g. Slueth).
3. We can't go away from CloudWatch.

Can someone tell me how exactly I need to configure the application to see trace IDs in log messages? Is there any documentation or samples I can look at?

Answer: 
As @Buckeye14Guy and @Sid pointed out the main problems in your code, you might also need to clean out some of the logic:

```
from pyspark.sql.functions import udf

def contains(x,y): 
  try:
    sx, sy = set(x), set(y) 
    if len(sy) == 0: 
        return 'list is empty'
    elif sx == sy: 
        return "ok"    
    elif sy.issubset(sx): 
        return "medium"  
    # below none of sy is in sx
    elif sx - sy == sx: 
        return "none found in raw"  # including empty x
    else: 
        return "some missing in raw"
  # in exception, for example `x` or `y` is None (not a list)
  except:
    return "not an iterable or other errors"

udf_contains = udf(contains, 'string')

df.withColumn('new_column', udf_contains('id', 'name')).show(truncate=False)
+---------------+---------------------+-----------------+
|id             |name                 |new_column       |
+---------------+---------------------+-----------------+
|[98475, 748574]|[98475, 748574]      |ok               |
|[75473, 98456] |[98456]              |medium           |
|[23456, 28596] |[84758, 56849, 86954]|none found in raw|
+---------------+---------------------+-----------------+

```
```py
else set(y) != set(x):
           ^
SyntaxError: invalid syntax

```

This is because an `else` statement doesn't require a condition. It contains code to be executed only if none of the previous conditions are met. Use instead:

```py
elif set(y) != set(x):
    #code

```

**OR**

```py
else :
    #code

```