microsoft / ApplicationInsights-JS

Microsoft Application Insights SDK for JavaScript
MIT License
650 stars 240 forks source link

[Feature] Add the ability to disable truncation #2383

Open MgenGlder opened 3 months ago

MgenGlder commented 3 months ago

Is your feature request related to a problem? Please describe. Adding the an option to the track method that disables property truncation.

Describe the solution you'd like I currently use ApplicationInsights-Web to send telemetry to a non-Azure endpoint. I do this because the SDK is robust, has fault tolerance, and implements useful retry logic out of the box. My service understands and adheres to the contracts created by the Application Insights SDK. Unfortunately, the SDK defaults to limiting the length of property fields to 8192 characters. This limit is based on the Application Insights Azure service's specifications, but isn't relevant if you use a self-hosted option.

I'd love to see an option that can be passed down to conditionally disable the character length limit that exists here.

Describe alternatives you've considered I've considered migrating away from using the ApplicationInsights-web SDK, though I enjoy the benefits the library confers for telemetry management.

I've also considered shrinking telemetry length, though there are some messages that are long by nature and cannot be shrunk.

MSNev commented 3 months ago

We can't remove the "truncation" limits as if we do the backend will reject the entire event as that is why we have these limits in place.

If you find "some" field where it seems that the SDK imposed limit does not match the server limit we can address that as a bug, but generally the limits were gathered from the server several years ago.

MgenGlder commented 3 months ago

We can't remove the "truncation" limits as if we do the backend will reject the entire event as that is why we have these limits in place.

If you find "some" field where it seems that the SDK imposed limit does not match the server limit we can address that as a bug, but generally the limits were gathered from the server several years ago.

@MSNev Thanks for replying so quickly!

What about the possibility of adding a configuration to disable truncation client-side? We have our own server that mimics the behavior of the App Insights server, but doesn't have character limits as we need longer field values. It could be added to the .Track(..., truncate: Boolean) function such that, if omitted, it defaults to true. What do you think?

MSNev commented 3 months ago

That might be a little ticky as all of the actual sanitization (truncation) occurs in these functions which don't take any additional config properties (to potentially have a disable flag)...

Which would mean that every call of these would either need to have an alias (so we could replace with a no-op that just returns the value), so it's probably not a trivial change and we would need to be a little careful to ensure we didn't increase the bundle size too much or introduce bugs of people that don't have the same requirements.

I'll tag this as an enhancement, but I don't expect that we will get to this any time soon. So feel free to investigate and see if you could propose a possible option to solve your issue (ie. a PR).

MgenGlder commented 1 month ago

@MSNev In league with your feedback on my PR- do you have any availability to walk through the code a bit? I'd love to get the lay of the land in terms of how things work holistically, as well as future plans I can work around.

MSNev commented 1 month ago

What timezone are you in? I'm in PST/PDT, I tend to have a lot of early morning meetings my time everyday... Based on your github profile it looks like your about -3hrs from me, is your listed github email the best way to directly contact you?

MgenGlder commented 1 month ago

What timezone are you in? I'm in PST/PDT, I tend to have a lot of early morning meetings my time everyday... Based on your github profile it looks like your about -3hrs from me, is your listed github email the best way to directly contact you?

@MSNev Yep! That's correct, I'm in EDT, so ~3 hours ahead of you. I can be reached at mgenglder@github.com. I was searching for you in Teams but I wasn't able to find your full handle, maybe we can interface that way?