open-telemetry / opentelemetry-python-contrib

OpenTelemetry instrumentation for Python modules
https://opentelemetry.io
Apache License 2.0
739 stars 613 forks source link

java call python tracing broken #1122

Closed tonycody closed 2 years ago

tonycody commented 2 years ago
image

java call python

python pip list

image

python automic instrument

opentelemetry-instrument \
      --exporter_jaeger_endpoint http://172.37.66.191:14268/api/traces?format=jaeger.thrift \
      --service_name "python-test" \
      --traces_exporter jaeger_thrift,console \
      python ipaas_start.py

java debug

image

java trace

image

python debug

{
    "name": "/execute",
    "context": {
        "trace_id": "0x86a051a6f50d2a5a4deb3d3fd82b9496",
        "span_id": "0x0c94c833eec2a358",
        "trace_state": "[]"
    },
    "kind": "SpanKind.SERVER",
    "parent_id": null,
    "start_time": "2022-06-08T09:57:43.379825Z",
    "end_time": "2022-06-08T09:57:43.381147Z",
    "status": {
        "status_code": "UNSET"
    },
    "attributes": {
        "http.method": "POST",
        "http.server_name": "0.0.0.0",
        "http.scheme": "http",
        "net.host.port": 8080,
        "http.host": "ipaas-a34d5480-2468-429b-8e6a-03663169489f.dev3.svc.cluster.local",
        "http.target": "/execute",
        "net.peer.ip": "10.100.57.170",
        "http.user_agent": "Apache-HttpClient/4.5.13 (Java/1.8.0_212)",
        "net.peer.port": 47458,
        "http.flavor": "1.1",
        "http.route": "/execute",
        "http.status_code": 200
    },
    "events": [],
    "links": [],
    "resource": {
        "telemetry.sdk.language": "python",
        "telemetry.sdk.name": "opentelemetry",
        "telemetry.sdk.version": "1.11.1",
        "service.name": "python-test",
        "telemetry.auto.version": "0.30b1"
    }
}

The trace ID is different

tonycody commented 2 years ago

Currently, the source of the request in Python is retrieved, but parent_id is empty, and traceId is inconsistent with source

"attributes": {
        "http.method": "POST",
        "http.server_name": "0.0.0.0",
        "http.scheme": "http",
        "net.host.port": 8080,
        "http.host": "ipaas-a34d5480-2468-429b-8e6a-03663169489f.dev3.svc.cluster.local",
        "http.target": "/execute",
        "net.peer.ip": "10.100.57.170",
        "http.user_agent": "Apache-HttpClient/4.5.13 (Java/1.8.0_212)",
        "net.peer.port": 47458,
        "http.flavor": "1.1",
        "http.route": "/execute",
        "http.status_code": 200
    }
aabmass commented 2 years ago

This sounds like a propagation issue. What propagator are you using in java and what server framework are you using in Python? Is it flask?

lytao123 commented 2 years ago

I also met! The java used is opentelemetry javaagent - version: 1.12.1, springboot2.4.9. python: opentelemetry-api==1.11.1 opentelemetry-sdk==1.11.1 opentelemetry-instrumentation==0.30b1 opentelemetry-instrumentation-tornado==0.30b1 opentelemetry-instrumentation-requests==0.30b1 tornado==6.1 requests==2.25.1

tonycody commented 2 years ago

I also met! The java used is opentelemetry javaagent - version: 1.12.1, springboot2.4.9. python: opentelemetry-api==1.11.1 opentelemetry-sdk==1.11.1 opentelemetry-instrumentation==0.30b1 opentelemetry-instrumentation-tornado==0.30b1 opentelemetry-instrumentation-requests==0.30b1 tornado==6.1 requests==2.25.1

Checking the Package Version and Flask is used or not.If you use Flask, try not using it for the time being

lytao123 commented 2 years ago

I use Tornado v6.1, not use Flask

lytao123 commented 2 years ago

My problem is solved.

add TornadoInstrumentor().instrument()

lytao123 commented 2 years ago

Currently, the source of the request in Python is retrieved, but parent_id is empty, and traceId is inconsistent with source

"attributes": {
        "http.method": "POST",
        "http.server_name": "0.0.0.0",
        "http.scheme": "http",
        "net.host.port": 8080,
        "http.host": "ipaas-a34d5480-2468-429b-8e6a-03663169489f.dev3.svc.cluster.local",
        "http.target": "/execute",
        "net.peer.ip": "10.100.57.170",
        "http.user_agent": "Apache-HttpClient/4.5.13 (Java/1.8.0_212)",
        "net.peer.port": 47458,
        "http.flavor": "1.1",
        "http.route": "/execute",
        "http.status_code": 200
    }

@tonycody code add:

TornadoInstrumentor().instrument()
srikanthccv commented 2 years ago

@tonycody can you answer what the configured propagators are for both python and java?

srikanthccv commented 2 years ago

@tonycody is this still an issue? Can you share more details requested? Otherwise please close the issue.

tonycody commented 2 years ago

python instrumentation is strongly related to different python package versions. When tracing cannot be obtained, you can try to change the package of a lower version.