Skip to content

pass tracer to datadog wrapper#1

Open
midu-git wants to merge 1 commit into
mainfrom
midu-git/pass_tracer_to_datadog_wrapper
Open

pass tracer to datadog wrapper#1
midu-git wants to merge 1 commit into
mainfrom
midu-git/pass_tracer_to_datadog_wrapper

Conversation

@midu-git
Copy link
Copy Markdown

@midu-git midu-git commented May 9, 2023

What does this PR do?

The tracer is passed explicitly to datadog wrapper. This reduces the dynamic resolution of dd-trace to a single place, and resolves the following issue:

Assume that you use the libraries dd-trace and datadog-lambda-js as npm modules without the layer. Moreover, assume you use a bundler like esbuild. In this situation, when initializing the trace as follows

import { tracer } from "dd-trace"
tracer.init(...)

export handler = datadog(handler_to_be_wrapped, ...)

and bundling this code with esbuild say

esbuild.build({
    entryPoints: [above_file],
    bundle: true,
    treeShaking: true,
    minify: true,
    sourcemap: true,
    entryNames: "[name]/index",
    outdir: "dist",
    platform: "node",
    target: ["node18"],
    logLevel: "info",
    plugins: [require("dd-trace/esbuild")],
})

the trace initialized will not be the same as the one this library loads, resulting in using a noop tracer for calls within this library. Up to my knowledge, there is no possibility to resolve this issue otherwise.

For the layer case, this change will not have an impact. However, the datadog wrapper has now a mandatory additional attribute. Thus, this change is potentially a breaking change.

To minimize the impact, loading and initializing the tracer has been split into two different functions, the latter one being exported to the user. Thus the user is able to initialize the tracer exactly the same way this library would do it.

Motivation

Testing Guidelines

Additional Notes

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)

@midu-git midu-git force-pushed the main branch 4 times, most recently from c581f52 to 0548d77 Compare May 16, 2023 14:51
@midu-git midu-git force-pushed the midu-git/pass_tracer_to_datadog_wrapper branch from 536ff2f to be651a7 Compare November 22, 2023 15:10
loading tracer, in particular in bundler scenarios.
@midu-git midu-git force-pushed the midu-git/pass_tracer_to_datadog_wrapper branch from be651a7 to 576fc85 Compare November 22, 2023 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant