Giter Club home page Giter Club logo

Comments (10)

boukeversteegh avatar boukeversteegh commented on May 20, 2024 1

It seems that this feature is now implemented:

getsentry/sentry-javascript#623 (comment)

Can we reopen this perhaps?

from sentry-dotnet.

bruno-garcia avatar bruno-garcia commented on May 20, 2024 1

I see, thanks for your reply. Looking at it, I have two questions:

  • How do I use this overload? SentrySdk.AddBreadCrumb is the documented approach, but this overload is not available on the SentrySdk static class.

Those extensions are available when adding directly to the event or to the scope. The latter is what SentrySdk.AddBreadcrumb does. You can see all extension methods through:

SentrySdk.ConfigureScope(s => s.AddBreadcrumb(...)
  • In the source code, it seems that it adds a KeyValuePair to the Dictionary<string,string>, so we're not really setting the top-level data object.

Not sure I follow. What do you mean by the top level data object? The Dictionary<string, string> named data is the field in the breadcrumb object where we can define arbitrary data.
We document this here: https://develop.sentry.dev/sdk/event-payloads/breadcrumbs/

image

The fields at the level of the breadcrumb (ie.: its properties) are typed and you can't add data that's not specified in the documentation above.

Thinking about it more, I suppose that as long as the Sentry UI displays the string values as is, including whitespace and linebreaks, then it doesn't really matter whether or not it understands JSON, since we can include a pretty-printed json string in the breadcrumbs.

I will experiment with this approach.

Sounds good! I hope this works out.

from sentry-dotnet.

bruno-garcia avatar bruno-garcia commented on May 20, 2024

Currently Sentry doesn't really support a serialized object in its data bag.
Serializing an object shows up like this:

image

I think this could be a feature request opened on Sentry and if implemented, change the SDKs which is a coordinated thing now as align the API.

from sentry-dotnet.

bruno-garcia avatar bruno-garcia commented on May 20, 2024

@lunim I'll close this as per my comment above.
If Sentry itself is changed to support breadcrumbs value as objects we can reopen this and implement support in this SDK.

from sentry-dotnet.

bruno-garcia avatar bruno-garcia commented on May 20, 2024

It's a bit of an issue to take object because often people put data that can't be serialized by default and we have issues.

Forcing this to be ISerializable will introduce friction, since one would need to implement the interface and get serialization done. To be quite honest at this point I would prefer the caller serializes it.

from sentry-dotnet.

boukeversteegh avatar boukeversteegh commented on May 20, 2024

from sentry-dotnet.

bruno-garcia avatar bruno-garcia commented on May 20, 2024

It currently accepts string as a value so it should already work if you're serializing before setting it.

There are different extension method, for example accepting a value tuple:

(string, string)? dataPair = null,

from sentry-dotnet.

boukeversteegh avatar boukeversteegh commented on May 20, 2024

I see, thanks for your reply. Looking at it, I have two questions:

  • How do I use this overload? SentrySdk.AddBreadCrumb is the documented approach, but this overload is not available on the SentrySdk static class.
  • In the source code, it seems that it adds a KeyValuePair to the Dictionary<string,string>, so we're not really setting the top-level data object.

Thinking about it more, I suppose that as long as the Sentry UI displays the string values as is, including whitespace and linebreaks, then it doesn't really matter whether or not it understands JSON, since we can include a pretty-printed json string in the breadcrumbs.

I will experiment with this approach.

from sentry-dotnet.

SimonCropp avatar SimonCropp commented on May 20, 2024

@boukeversteegh @lunim looks like @bruno-garcia answered this one.

from sentry-dotnet.

boukeversteegh avatar boukeversteegh commented on May 20, 2024

Sorry to keep this open.

My current workaround is to pass a dictionary like this;

Dictionary<string, string> data = new();
data.Add(key, JsonFormatter.Format(message)); // formats a Protobuf message to JSON
SentrySdk.AddBreadcrumb(description, category, null, data);

It's just shown as a string, and the json structure is not handled in any way, but it's workable for small messages. Haven't tested yet with formatted/multiline strings.

Closing this is OK I suppose. Thanks!

from sentry-dotnet.

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.