"Invalid Character" when using Scope names with state #895
Replies: 7 comments
-
So you must have your custom extension method that does something with those two arguments and pass it to the You can add your custom code to apply Through: An example here: sentry-dotnet/samples/Sentry.Samples.Console.Customized/Program.cs Lines 272 to 287 in e17703a |
Beta Was this translation helpful? Give feedback.
-
@bruno-garcia Ilogger itself does not but the LoggerExtensions do: |
Beta Was this translation helpful? Give feedback.
-
Oh that's new I believe? I wasn't aware of that extension method anyway. It basically: Sounds like we'd need to special case for that, and extract the key from the message format (like The code would go here: We could test that with a unit test, calling the same extension method you did. In fact, your use case could be the test case. Is this something you'd be willing to contribute with a PR? |
Beta Was this translation helpful? Give feedback.
-
That actually already works. With the example above I get "HttpMethod" as Key and "123" as value but the message itself is passed without any kind of replacement and any kind of key which marks it as invalid in the frontend. I guess the tags work cause FormattedLogValues is based on a IReadOnlyList<KeyValuePair<string, object>> I can take a look if I can get a PR ready 😄 |
Beta Was this translation helpful? Give feedback.
-
@bruno-garcia I've been digging a bit more. The reason this fails is that FormattedLogValues adds the original message as another item to the keyvaluepairlist with key "{OriginalFormat}". So the problem is not the "{" in the message but the "{" in the Key that is added. My test case is : "scope {variable}", "test" I can see multiple ways to handle this but I'm not sure what might be the best:
In my opinion "OriginalFormat: scope {variable}" doesn't hold any information so maybe a combination of 2 and 3 is fine? Would that be acceptable? I'm not sure about the name "Scope" maybe "ActiveScope", "ScopeMessage" or something completly different would be better? EDIT: Oh and I sadly can't check if it's FormattedLogValues as that type is internal since .NET Core 3 it seems 😞 |
Beta Was this translation helpful? Give feedback.
-
We have a special case for it too here: In this case ideally we'd add the formatted version only. I've used |
Beta Was this translation helpful? Give feedback.
-
I am experiencing this exact problem too. We have recently updated our asp .net core version to 3.1 and sentry to 2.1.8 |
Beta Was this translation helpful? Give feedback.
-
Please mark the type framework used:
Please mark the type of the runtime used:
Please mark the NuGet packages used:
When using the AspNetCore ILogger like this:
This creates a scope called "HTTP 123 1234" and additional tags "HttpMethod: 123" and "Uri: 1234".
Sentry successfully gets the tags but the scope results in an error in the sentry frontend like this:
The tags json will contain:
I think Sentry should be able to use "HTTP 123 1234" as value and probably have "scope" as a tag key (Are arrays supported as tag keys?)
Beta Was this translation helpful? Give feedback.
All reactions