Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Optional Dictionary to add custom tags when creating a SentryEvent #149

Closed
wants to merge 1 commit into from
Closed

Conversation

mr-sige
Copy link

@mr-sige mr-sige commented Aug 31, 2016

This change is Reviewable

@asbjornu
Copy link
Contributor

asbjornu commented Sep 1, 2016

The SentryEvent object was created to avoid constructor overload hell, so I don't understand why we need this?

@mr-sige
Copy link
Author

mr-sige commented Sep 2, 2016

Right now you can add tags using sentryEvent.Tags.Add( one by one.
I was thinking it would be nice if I could pass a Dictionary to the constructor with all the tags I'd like to add. :)

@samukce
Copy link
Contributor

samukce commented Sep 2, 2016

When we add a parameter in constructor it is more hard do maintenance and new parameters in sentryEvent easily could maintain the same pattern (constructor hell.)

Maybe is more interesting create a method like SentryEvent.MergeTags(Dictionary<string, string> tags), this way you could build automated tests for ensuring for instance tags already the same key from the dictionary exist in Tags property.

@asbjornu
Copy link
Contributor

asbjornu commented Sep 5, 2016

I'm not a fan of having several methods pertaining a property on the class itself; I think it's neater to group the methods within the property instead. That would require an extension method or a new interface for the Tags property. Extension methods are more backwards compatible, so I would prefer to see a solution using them rather than an interface or other alternatives. If that means the Tags property needs to have its setter made internal, that's fine.

@samukce
Copy link
Contributor

samukce commented Sep 5, 2016

Good idea. Using Extension is the better solution.

On Mon, Sep 5, 2016 at 9:40 AM, Asbjørn Ulsberg notifications@github.com
wrote:

I'm not a fan of having several methods pertaining a property on the class
itself; I think it's neater to group the methods within the property
instead. That would require an extension method or a new interface for the
Tags property. Extension methods are more backwards compatible, so I
would prefer to see a solution using them rather than an interface or other
alternatives. If that means the Tags property needs to have its setter
made internal, that's fine.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#149 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABUhkCUsNbkkTwjL9QGgcEu-WN77WwFRks5qnA3AgaJpZM4JyAVG
.

Regards,

*Samuel Pereira *
Senior Systems Analyst
c. +55 85 9 8883.1368
skype samuel.p.araujo
l. br.linkedin.com/in/samuelpereiraaraujo
g. github.com/samukce

@mr-sige
Copy link
Author

mr-sige commented Sep 5, 2016

Hey Asbjørn!

Can you be a bit more specific, what do you mean by "extension method for
tags property", how would it work, where would it be?

Thanks

-sige

On Mon, Sep 5, 2016 at 4:04 PM Samuel P. notifications@github.com wrote:

Good idea. Using Extension is the better solution.

On Mon, Sep 5, 2016 at 9:40 AM, Asbjørn Ulsberg notifications@github.com
wrote:

I'm not a fan of having several methods pertaining a property on the
class
itself; I think it's neater to group the methods within the property
instead. That would require an extension method or a new interface for
the
Tags property. Extension methods are more backwards compatible, so I
would prefer to see a solution using them rather than an interface or
other
alternatives. If that means the Tags property needs to have its setter
made internal, that's fine.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<
#149 (comment)
,
or mute the thread
<
https://github.com/notifications/unsubscribe-auth/ABUhkCUsNbkkTwjL9QGgcEu-WN77WwFRks5qnA3AgaJpZM4JyAVG

.

Regards,

*Samuel Pereira *
Senior Systems Analyst
c. +55 85 9 8883.1368
skype samuel.p.araujo
l. br.linkedin.com/in/samuelpereiraaraujo
g. github.com/samukce


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#149 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFoMbCGP4nZ9iPxl5h5yFm5UnU83C-ugks5qnA7ggaJpZM4JyAVG
.

@asbjornu
Copy link
Contributor

asbjornu commented Sep 5, 2016

@sigebacsi Since Tags currently is a IDictionary<string, string>, you can create an extension method like so:

public static void Add(this IDictionary<string, string> instance, IDictionary<string, string> dictionary)
{
    foreach (var kvp in dictionary)
    {
        instance.Add(kvp);
    }
}

This method can reside in the SharpRaven library, but seeing how simple it is, I'd say you can just add it to your own code. No need to wait for a new release of SharpRaven to simplify your own code. 😄

@mr-sige
Copy link
Author

mr-sige commented Sep 11, 2016

Okay.
If you don't see it as a useful addition to SharpRaven, the I'll just add it to my code.

@genne
Copy link
Contributor

genne commented Sep 13, 2016

Any specific reason for the setter of SentryEvents.Tags being internal and not public? It it was public you could write the following code:

new SentryEvent(...)
{
    Tags = myTags
}

@asbjornu
Copy link
Contributor

@genne Good question. It's helpful for SharpRaven itself to know that it can't be null, and I imagined that exposing an IDictionary<string, string> would give everyone what they needed, but it's of course possible to make the property writable. It already has null protection in place, so I wouldn't oppose a PR doing just that.

genne added a commit to genne/raven-csharp that referenced this pull request Sep 14, 2016
To make it easier to include tags directly when constructing a new
`SentryEvent`.

Related to PR getsentry#149.
@asbjornu
Copy link
Contributor

@sigebacsi Now that #157 is merged, does it give you what you need? If so, can this PR be closed?

samukce added a commit to samukce/raven-csharp that referenced this pull request Sep 19, 2016
samukce added a commit to samukce/raven-csharp that referenced this pull request Sep 19, 2016
@mr-sige mr-sige closed this Sep 19, 2016
asbjornu added a commit that referenced this pull request Feb 6, 2017
* develop: (90 commits)
  Fixing typo.
  Added initial doc about breadcrumbs.
  Demangle Anonymous Function Names
  Improve exception frame tests
  Demangle Function Name from Async Calls
  Solution reordering
  Updating configurations
  Fixing Build Configurations
  Targetframework dependency fix
  Refactoring # directives position
  Complementing the PR #149. Some tests case to ensure public assign from SentryEvent.Tags
  Web Test configurations
  Multiple code refactoring
  Fixing reference Newtonsoft targetFramework in .net 4.5 build
  Removing unnecessary variables. Removing inconsistent build configurations
  Changing NSubstitute targetFramework dependency on .net 4.5
  Adding missing using
  Using .net 3.5 way whenever it is possible
  Solution configurations
  Removing unnecessary usings
  ...
asbjornu added a commit that referenced this pull request Feb 6, 2017
* develop: (90 commits)
  Fixing typo.
  Added initial doc about breadcrumbs.
  Demangle Anonymous Function Names
  Improve exception frame tests
  Demangle Function Name from Async Calls
  Solution reordering
  Updating configurations
  Fixing Build Configurations
  Targetframework dependency fix
  Refactoring # directives position
  Complementing the PR #149. Some tests case to ensure public assign from SentryEvent.Tags
  Web Test configurations
  Multiple code refactoring
  Fixing reference Newtonsoft targetFramework in .net 4.5 build
  Removing unnecessary variables. Removing inconsistent build configurations
  Changing NSubstitute targetFramework dependency on .net 4.5
  Adding missing using
  Using .net 3.5 way whenever it is possible
  Solution configurations
  Removing unnecessary usings
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants