Giter Site home page Giter Site logo

Provide option to disable monkey-patching of global methods and allow flexibility in configuring http clients. about aws-rum-web HOT 7 OPEN

aws-observability avatar aws-observability commented on August 10, 2024
Provide option to disable monkey-patching of global methods and allow flexibility in configuring http clients.

from aws-rum-web.

Comments (7)

maniator avatar maniator commented on August 10, 2024

I've contributed some, so I do believe they are accepting

That sounds like it could be a great idea too 🙂

from aws-rum-web.

maniator avatar maniator commented on August 10, 2024

i have an open PR for uodatijg tyoes of monkey patch, and another for plugins (so that new things can be added by others in a much easier way)

from aws-rum-web.

qhanam avatar qhanam commented on August 10, 2024

Hi @gillisandrew thanks for the detailed issue! Yes, we are open to contributions.

1. Allow an option to disable monkey-patching of fetch and instead expose the instrumented client on the AwsRum instance.
2. Allow a fetch API compatible function to be passed as the default http client in the CWR configuration object. Currently this could technically be achieved by monkey-patching fetch before initializing CWR web client, but that is far from ideal.

It is possible to disable the FetchPlugin and XhrPlugin by excluding http from the telemetries config. For example:

const config: AwsRumConfig = {
  ...
  telemetries: ['errors', 'performance']
};

It is also possible to add a custom plugin using the config. For example:

import { AwsRum, AwsRumConfig, FetchPlugin } from 'aws-rum-web';

const config = {
    logicalServiceName: 'sample.rum.aws.amazon.com',
    urlsToInclude: [/response\.json/],
    recordAllRequests: true,
    addXRayTraceIdHeader: true
};

const config: AwsRumConfig = {
  ...
  eventPluginsToLoad: [new FetchPlugin(config)],
  telemetries: ['errors', 'performance']
};

Would this solve the use case?

Notes:

  • Events generated by the plugin must conform to the HTTP event schema or the X-Ray trace event schema. You can generate type definitions for these schemas by running npm run build:schemas.
  • The class VirtualPageLoadTimer also monkey patches fetch and XMLHttpRequest to time route changes. I don't think this impacts you, but just in case.

3. Allow instrumentation of a fetch client in the local scope. This should allow application developers to instrument each service for their own requirements.

Could a custom plugin support this use case as well?

4. Provide a mechanism for extending the annotations and metadata in an X-Ray segment.

Yes! This is in our backlog. Specifically, @limhjgrace is looking into it if you'd like to co-ordinate.

from aws-rum-web.

gillisandrew avatar gillisandrew commented on August 10, 2024

@qhanam Thanks for the response! An xray plugin would actually really help address some of the immediate challenges. If it isn't something that is being released in the next couple of weeks I'll likely work on it as an external package just to unblock the current project.

I'd be sure to reference the issue and open a pull request once there is a working solution.

It is possible to disable the FetchPlugin and XhrPlugin by excluding http from the telemetries config

Yeah, I'm aware but we do hope to use the data collected by the FetchPlugin, we just need some flexibility in how things are handled on the client.

from aws-rum-web.

qhanam avatar qhanam commented on August 10, 2024

Gotcha. Sounds awesome, thanks @gillisandrew !

from aws-rum-web.

limhjgrace avatar limhjgrace commented on August 10, 2024

Hey @gillisandrew! The custom X-Ray annotations feature is definitely in our backlog and I'll most likely be able to get to it mid-June. However, this doesn't include extending the metadata. Could I know more about your use case? Do you have an idea of what the additional data would look like?

from aws-rum-web.

gillisandrew avatar gillisandrew commented on August 10, 2024

@limhjgrace Hey thanks for working on this. I just lumped annotations together with metadata because they both add data to the traces. Annotations would be sufficient to address the current issue we're having.

from aws-rum-web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.