deno icon indicating copy to clipboard operation
deno copied to clipboard

Deno's default OTEL exporter doesn't strip ansi colors, and has a missing parent span

Open samuelcolvin opened this issue 6 months ago • 2 comments

Version: deno 2.3.3 (stable, release, aarch64-apple-darwin)

As shown here in pydantic logfire:

Image

Two issues:

  1. ansi colors are included in the span name
  2. These Listening on http://0.0.0.0:8000/ (http://localhost:8000/) spans and the [0m[38;5;12mWatcher[0m [0m[38;5;245mRestarting! File change detected: ... all have a (different) parent_span_id that is not transmitted, hence the "The parent span of this record is missing." message.

Attributes from such a span:

{
  "start_timestamp": "2025-05-23T08:35:22.087455Z",
  "trace_id": "0196fc48596780beee7f45759e2a7302",
  "span_id": "f81d188a59300e5d",
  "parent_span_id": "a8da8c7d368d1ddf",
  "span_name": "\u001b[0m\u001b[38;5;12mWatcher\u001b[0m Process started.",
  "level": 9,
  "service_name": "unknown_service",
  "otel_scope_name": "deno::util::file_watcher",
  "tags": [],
  "created_at": 1747989325010.019,
  "end_timestamp": "2025-05-23T08:35:22.087455Z",
  "kind": "log",
  "message": "\u001b[0m\u001b[38;5;12mWatcher\u001b[0m Process started.",
  "is_exception": false,
  "exception_type": null,
  "otel_scope_version": null,
  "service_version": null,
  "http_response_status_code": null,
  "gen_ai_operation_name": null,
  "gen_ai_request_model": null,
  "gen_ai_response_model": null,
  "gen_ai_system": null,
  "gen_ai_usage_input_tokens": 0,
  "gen_ai_usage_output_tokens": 0,
  "matched_filter": true,
  "is_extra_span": false,
  "day": "2025-05-23",
  "duration": null,
  "otel_status_code": "OK",
  "otel_status_message": null,
  "otel_links": null,
  "otel_events": null,
  "url_path": null,
  "url_query": null,
  "url_full": null,
  "http_route": null,
  "http_method": null,
  "attributes": {},
  "attributes_json_schema": null,
  "otel_scope_attributes": {},
  "service_namespace": "",
  "service_instance_id": null,
  "process_pid": null,
  "otel_resource_attributes": {
    "process.runtime.name": "deno",
    "process.runtime.version": "2.3.3",
    "service.name": "unknown_service",
    "telemetry.sdk.language": "deno-rust",
    "telemetry.sdk.name": "deno-opentelemetry",
    "telemetry.sdk.version": "2.3.3-0.27.1"
  },
  "telemetry_sdk_name": "deno-opentelemetry",
  "telemetry_sdk_language": "deno-rust",
  "telemetry_sdk_version": "2.3.3-0.27.1",
  "deployment_environment": null
}

samuelcolvin avatar May 23 '25 08:05 samuelcolvin

Can you please provide a reproduction?

bartlomieju avatar May 23 '25 10:05 bartlomieju

Hey @bartlomieju! 👋

Here's an example repository you can check out:
https://github.com/ddanielcruzz/deno-otel-with-logfire

To get it running, you'll need to sign up for Logfire to create a write token, as described in the repository’s README.md.


If you’d rather just explore the data without setting up the repo, you can join my Logfire project directly.
Note: You’ll still need to create a Logfire account in the US data region using the invite link below:

  1. Sign up and join the project using this invite link:
    https://logfire-us.pydantic.dev/l/join-deno/tHvuM0eaj6
  2. Once you're in, you can view the live project data here:
    https://logfire-us.pydantic.dev/ddanielcruzz/deno?last=30d

Let me know if you run into anything or have any questions!

ddanielcruzz avatar May 27 '25 06:05 ddanielcruzz