question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

data dog dd-trace library: corrupts message data

See original GitHub issue

Hello, I am attempting to utilize the nats transport system however I’m getting some very weird behavior. In the example outlined below, I have provided 3 logs. The first being the expected message format, the second the malformed message format, and the third are logs spit out by what looks to be the nats library. All networking is done locally on the same machine. The message seems to collide with some internal metadata, what could be the cause of this sort of behavior?

example implementation

const encoder = msg => Buffer.from(JSON.stringify(msg))
const decoder = msg => JSON.parse(Buffer.from(msg).toString())

const inbox = createInbox()

// sub handler to inbox
const inboxSub = nats.subscribe(inbox, { timeout: 1000 });
(async () => {
    for await (const m of inboxSub) {

          console.log(
            inbox,
            "inboxSub.data",
            String.fromCharCode.apply(null, m.data)
          );
          
          // decode message content
          const msg = decoder(m.data);

          /* do business logic to process message */
          
          // when we got all replies unsub
          if(done) inboxSub.unsubscribe()
    }
})()

// send "request"
nats.publish("calls", encoder({ method: "call_api" }), { reply: inbox })

Logs

// expected message structure
{"state":"stream","args":[{"_id":"267eb986-61f9-4491-8434-d59507e8e368","id":"267eb986-61f9-4491-8434-d59507e8e368","balance":"0","balanceBefore":"0","canDeposit":true,"canWithdraw":true,"created":1619991725052,"decimals":6,"userid":"267eb986-61f9-4491-8434-d59507e8e368","updated":1619991725053},"chips_staking"]}            
                                     
// received mailformed message
{"state":"stream","args":[{"_id":"bf8ef327-aad0-4c6d-b26f-66a118ab994c","id":"bf8ef327-aad0-4c6d-b26f-66a118ab994c","balance":"0","balanceBefore":"0","canDeposit":true,"canWithdraw":true,"created":1619991726196,"decimals":6,"userid":MSG _INBOX.GV7DNK21FL1UUAGZSTN6F6 4 198                           

// logs emitted from nats lib?                                                                             
service_name    | {"state":"stream","args":[{"_id":"profit                                                                                                                                                                                   
service_name    | reader closed Error: parse error [0]: "bf8ef327-aad0-4c6d-b26f-66a118ab994c","updated":1619991726196},"chips_staking"]}            
service_name    | MSG _INBOX.GV7DNK21FL1UUAGZSTN6F6 4 314                                                                                                                                                                                    

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rochdevcommented, May 28, 2021

@tacyarg Disabling the net plugin would also work, without needing to completely remove dd-trace. This can be done with the DD_TRACE_NET_ENABLED=false environment variable. We’re also going to look into this issue to make sure there is no corruption when dd-trace is used.

0reactions
aricartcommented, May 28, 2021

@tacyarg did you try upgrading the plugin?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sending Traces to Datadog
Traces are sent from your application instrumented with a Datadog Tracing Library to the Datadog Agent, and from the Datadog Agent to the...
Read more >
Getting Started with Tracing - Datadog Docs
Datadog Application Performance Monitoring (APM or tracing) is used to collect traces from your backend application code. This beginners' guide shows you how...
Read more >
APM Troubleshooting - Datadog Docs
During startup, Datadog tracing libraries emit logs that reflect the configurations applied in a JSON object, as well as any errors encountered, ...
Read more >
What is Distributed Tracing? How it Works & Use Cases
You can use Datadog's auto-instrumentation libraries to collect performance data or integrate Datadog with open source instrumentation and tracing tools.
Read more >
APM - Datadog Docs
Add the Datadog Tracing Library for your environment and language, whether you are ... using automatic instrumentation, dd-trace-api, or OpenTelemetry.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found