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

TraceID - TypeError: Cannot read property 'FromString' of undefined #546

Open
paulskipprhudson opened this issue Nov 25, 2022 · 3 comments

Comments

@paulskipprhudson
Copy link

paulskipprhudson commented Nov 25, 2022

I'm trying to generate consistent Trace ID's across lambda invocations (in and event streaming platform).

However, I'm getting and error when calling static FromString method.

import * as AWSXray from 'aws-xray-sdk-core';

const foo = 'foo'
const bar = 'bar'

AWSXray.TraceID.FromString(`${foo}${bar}`).toString()

/**
 * trace-id-test.ts:6
 * AWSXray.TraceID.FromString(`${foo}${bar}`).toString()
 *                 ^
 * TypeError: Cannot read property 'FromString' of undefined
 */

and

import { TraceID } from 'aws-xray-sdk-core';

const foo = 'foo'
const bar = 'bar'

TraceID.FromString(`${foo}${bar}`).toString()

/**
 * trace-id-test.ts:16
 * TraceID.FromString(`${foo}${bar}`).toString()
 *         ^
 * TypeError: Cannot read property 'FromString' of undefined
 */

As best I can tell, I'm following the implementation in the tests: https://github.com/aws/aws-xray-sdk-node/blob/master/packages/core/test-d/index.test-d.ts

Many thanks for any pointers and help!

node -v v14.19.3
aws-xray-sdk-core ^3.4.0

@carolabadeer
Copy link
Contributor

carolabadeer commented Dec 5, 2022

Looks like this is an import issue. From what I can tell at first glance there is a typo in the second code snippet that may be causing this: the ID part of TraceID should've been capitalized.

By directly importing the TraceID class, using AWSXray.TraceID is no longer necessary. Maybe try this?

import { TraceID } from 'aws-xray-sdk-core';

TraceID.FromString(`${timestring}${iemi}`).toString()

@paulskipprhudson
Copy link
Author

Sorry, that was terrible reporting from me with a copy paste error in the import.

I've corrected the initial report.

@nick-kang
Copy link

We just hit this issue. We tried importing from aws-xray-sdk and aws-xray-sdk-core and neither worked. Ended up just copying the FromString implementation.

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

No branches or pull requests

3 participants