Skip to content
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

inconsistency printing to json from ConsoleSpanExporter #1832

Closed
codeboten opened this issue May 10, 2021 · 0 comments · Fixed by #1833
Closed

inconsistency printing to json from ConsoleSpanExporter #1832

codeboten opened this issue May 10, 2021 · 0 comments · Fixed by #1833
Assignees
Labels
bug Something isn't working

Comments

@codeboten
Copy link
Contributor

Running the following code:

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
    ConsoleSpanExporter,
    SimpleSpanProcessor,
)

trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(
    SimpleSpanProcessor(ConsoleSpanExporter())
)
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("foo"):
    with tracer.start_as_current_span("bar"):
        print("Hello world!")

outputs the following span information, note the parent ID formatting is inconsistent:

Hello world!
{
    "name": "bar",
    "context": {
        "trace_id": "0xaba880c3256d04f47bcdecf9bf3ba84e",
        "span_id": "0x3014b62ab356f774",
        "trace_state": "[]"
    },
    "kind": "SpanKind.INTERNAL",
    "parent_id": "53321c6000aabdfe",
    "start_time": "2021-05-10T15:21:55.215847Z",
    "end_time": "2021-05-10T15:21:55.215898Z",
    "status": {
        "status_code": "UNSET"
    },
    "attributes": {},
    "events": [],
    "links": [],
    "resource": {
        "telemetry.sdk.language": "python",
        "telemetry.sdk.name": "opentelemetry",
        "telemetry.sdk.version": "1.2.0.dev0",
        "service.name": "unknown_service"
    }
}
{
    "name": "foo",
    "context": {
        "trace_id": "0xaba880c3256d04f47bcdecf9bf3ba84e",
        "span_id": "0x53321c6000aabdfe",
        "trace_state": "[]"
    },
    "kind": "SpanKind.INTERNAL",
    "parent_id": null,
    "start_time": "2021-05-10T15:21:55.215765Z",
    "end_time": "2021-05-10T15:21:55.216855Z",
    "status": {
        "status_code": "UNSET"
    },
    "attributes": {},
    "events": [],
    "links": [],
    "resource": {
        "telemetry.sdk.language": "python",
        "telemetry.sdk.name": "opentelemetry",
        "telemetry.sdk.version": "1.2.0.dev0",
        "service.name": "unknown_service"
    }
}
@codeboten codeboten added the bug Something isn't working label May 10, 2021
@codeboten codeboten self-assigned this May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant