-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Per-log labels #5313
Comments
We can't add a new parameter to the the You can implement conditional label providers, they can be based on Basically, your custom label provider is the one that needs to know when to add a label. If for any reason this approach doesn't work for you do provide more details about your use case and why you can't use the existing label providing mechanism. |
Hi @amanda-tarafa, adding a condition to my label provider was the first thing I tried, but I wasn't able to because Here is a quick summary of what I am trying to do:
|
No, it's not inmediately possible to check on the entry you are creating the labels for. We could do that possibly. But, to be honest, I'm not entirely convinced that labeling a log entry is the best way to tackle your use case. What I think I would do is create a trace span at the beginning of the request and label that span with all the info I want. The span will contain all the log entries created within so you know all those lables apply to all those log entries, i.e. to the request in it's entirety. You can see how to do that here. This is very subjective, and there's no right or wrong, just preferences and context, but adding labels like you are describing to just one entry based on it being the "first", seems off to me. What does that say about the tls_version associated to the rest of the log entries? My point is that when looking at log entries you have to know that a decision was made to add the tls_version only to the first one of each request, and that is not intuitive in my view. If I were to add those labels, I would add them to all the log entries affected or to none. Spans on the other hand, are the ones that mark the start/end of an operation, and adding labels to them that describe that operation makes a lot of sense. Again, this is just my view and you may have any number of constraints or a context that I don't know about, so take this with a pinch of salt. If labeling spans works for you, great, else, let me know and I can take a look at defining label providers that know about the entry being logged. But just to set expectations, I probably wouldn't be able to get to this in a couple of weeks. |
Hi @amanda-tarafa, 2 things:
|
Yes - so it's impossible to update it? I thought that since it's "in progress" you could at least add an annotation to it. |
Not through the Diagnostics library, we don't modify spans that we don't create and we almost certainly don't want to do so. Also, think that in this particular case, you would be setting application specific information on a Load Balancer span, which might be a little unexpected. In any case, if you really want to annotate and external span, you could do it using the Google.Cloud.Trace.v1 library directly, you could inspect the header, get the trace ID, and use the library to fetch the load balancer span and patch it. |
You're right. I just tested, and it worked. |
Oh, this is unfortunate. Turns out those labels in the span don't show up in the Cloud Console Logs Viewer. Only Trace list. |
Traces can be filtered as well based on the span labels, see below, with the added benefit, in my view, that you can see everything, traces and logs, in one screen. If you still want to be able to add labels to specific log entries, I can look into adding this feature, but, to set expectations, we won't be able to look/work on this for a couple of weeks. |
@amanda-tarafa Thanks for that. I think that will work for now, but I'd still like this for logs, so I can do all filtering in one place. I will await your update in a few weeks.🙂 |
Moves GoogleLoggerScope to Diagnostics.Common. In preparation for allowing LogEntry augmentation and making it easier to use Google logging from non ASP.NET Core apps. Towards googleapis#5313, googleapis#5360, googleapis#5929 and googleapis#6367
Moves GoogleLoggerScope to Diagnostics.Common. In preparation for allowing LogEntry augmentation and making it easier to use Google logging from non ASP.NET Core apps. Towards googleapis#5313, googleapis#5360, googleapis#5929 and googleapis#6367
Moves GoogleLoggerScope to Diagnostics.Common. In preparation for allowing LogEntry augmentation and making it easier to use Google logging from non ASP.NET Core apps. Towards googleapis#5313, googleapis#5360, googleapis#5929 and googleapis#6367
Moves GoogleLoggerScope to Diagnostics.Common. In preparation for allowing LogEntry augmentation and making it easier to use Google logging from non ASP.NET Core apps. Towards googleapis#5313, googleapis#5360, googleapis#5929 and googleapis#6367
Moves GoogleLoggerScope to Diagnostics.Common. In preparation for allowing LogEntry augmentation and making it easier to use Google logging from non ASP.NET Core apps. Towards googleapis#5313, googleapis#5360, googleapis#5929 and googleapis#6367
Moves GoogleLoggerScope to Diagnostics.Common. In preparation for allowing LogEntry augmentation and making it easier to use Google logging from non ASP.NET Core apps. Towards googleapis#5313, googleapis#5360, googleapis#5929 and googleapis#6367
Changes in Google.Cloud.Diagnostics.AspNetCore version 4.3.0-beta01: - [Commit 60e8cd8](googleapis@60e8cd8): - feat: Copies GoogleLogger to Common. This allows easier use of GoogleLogger in non ASP.NET Core applications. - Towards [issue 6367](googleapis#6367) - Replicate LoggerOptions in Common, and have AspNetCore\*.LoggerOptions be just a wrapper of Common.LoggerOptions. - Copies ILogEntryLabelProvider to Common and marks the one in AspNetCore* Obsolete. - Makes AspNetCore*.IExternalTraceProvider obsolete. It can now be replaced by Common.ITraceContext. - [Commit 32cb606](googleapis@32cb606): - feat: Allows per log entry labels. - Closes [issue 5313](googleapis#5313) - Closes [issue 5929](googleapis#5929) - [Commit c8e9a48](googleapis@c8e9a48): - refactor: Makes GoogleLoggerScope extendable. Moves GoogleLoggerScope to Diagnostics.Common. In preparation for allowing LogEntry augmentation and making it easier to use Google logging from non ASP.NET Core apps. Towards [issue 5313](googleapis#5313), [issue 5360](googleapis#5360), [issue 5929](googleapis#5929) and [issue 6367](googleapis#6367) - [Commit 7f5f89e](googleapis@7f5f89e): - docs: Change Stackdriver to Google Cloud, and fix some typos, including in test code. - [Commit c4c9cd5](googleapis@c4c9cd5): - feat: Makes it easier to use tracing from non ASP.NET Core applications Closes [issue 5897](googleapis#5897) Towards [issue 6367](googleapis#6367) - [Commit b35b9ea](googleapis@b35b9ea): - feat: Decouples Diagnostics tracing from Google's trace header. Towards [issue 5360](googleapis#5360) and [issue 5897](googleapis#5897) - [Commit 0c00d2c](googleapis@0c00d2c): - refactor: Remove unnecesary service provider extension method. There's an equivalent method offered by Microsoft.Extensions.DependencyInjection so we don't need our own. - [Commit bb0c7b2](googleapis@bb0c7b2): - refactor: Remove unnecesary interface IManagedTracerFactory. It's an internal interface that we don't use anywhere. We can always add it back in if we need it at some point. - [Commit 8ef3983](googleapis@8ef3983): - fix: X-Cloud-Trace-Context trace mask values should be 0-1. See https://cloud.google.com/trace/docs/setup#force-trace Note: changing a generic type parameter constraint in `LabelProviderExtensions` is notionally a breaking change, but due to how it will be used, we don't expect it to actually break any customers. Changes in Google.Cloud.Diagnostics.AspNetCore3 version 4.3.0-beta01: - [Commit 60e8cd8](googleapis@60e8cd8): - feat: Copies GoogleLogger to Common. - This allows easier use of GoogleLogger in non ASP.NET Core applications. - Towards [issue 6367](googleapis#6367) - Replicate LoggerOptions in Common. - And have AspNetCore*.LoggerOptions be just a wrapper of Common.LoggerOptions. - Copies ILogEntryLabelProvider to Common. - And marks the one in AspNetCore* Obsolete. - Makes AspNetCore*.IExternalTraceProvider obsolete. - It can now be replaced by Common.ITraceContext. - [Commit 32cb606](googleapis@32cb606): - feat: Allows per log entry labels. - Closes [issue 5313](googleapis#5313) - Closes [issue 5929](googleapis#5929) - [Commit c8e9a48](googleapis@c8e9a48): - refactor: Makes GoogleLoggerScope extendable. - Moves GoogleLoggerScope to Diagnostics.Common. - In preparation for allowing LogEntry augmentation and making it easier to use Google logging from non ASP.NET Core apps. - Towards [issue 5313](googleapis#5313), [issue 5360](googleapis#5360), [issue 5929](googleapis#5929) and [issue 6367](googleapis#6367) - [Commit 7f5f89e](googleapis@7f5f89e): - docs: Change Stackdriver to Google Cloud - And fix some typos, including in test code. - [Commit c4c9cd5](googleapis@c4c9cd5): - feat: Makes it easier to use tracing from non ASP.NET Core applications - Closes [issue 5897](googleapis#5897) - Towards [issue 6367](googleapis#6367) - [Commit b35b9ea](googleapis@b35b9ea): - feat: Decouples Diagnostics tracing from Google's trace header - Towards [issue 5360](googleapis#5360) and [issue 5897](googleapis#5897) - [Commit bb0c7b2](googleapis@bb0c7b2): - refactor: Remove unnecesary interface IManagedTracerFactory. - It's an internal interface that we don't use anywhere. We can always add it back in if we need it at some point. - [Commit 8ef3983](googleapis@8ef3983): - fix: X-Cloud-Trace-Context trace mask values should be 0-1. - See https://cloud.google.com/trace/docs/setup#force-trace Packages in this release: - Release Google.Cloud.Diagnostics.AspNetCore version 4.3.0-beta01 - Release Google.Cloud.Diagnostics.AspNetCore3 version 4.3.0-beta01 - Release Google.Cloud.Diagnostics.Common version 4.3.0-beta01
Changes in Google.Cloud.Diagnostics.AspNetCore version 4.3.0-beta01: - [Commit 60e8cd8](googleapis@60e8cd8): - feat: Copies GoogleLogger to Common. This allows easier use of GoogleLogger in non ASP.NET Core applications. - Towards [issue 6367](googleapis#6367) - Replicate LoggerOptions in Common, and have AspNetCore\*.LoggerOptions be just a wrapper of Common.LoggerOptions. - Copies ILogEntryLabelProvider to Common and marks the one in AspNetCore* Obsolete. - Makes AspNetCore*.IExternalTraceProvider obsolete. It can now be replaced by Common.ITraceContext. - [Commit 32cb606](googleapis@32cb606): - feat: Allows per log entry labels. - Closes [issue 5313](googleapis#5313) - Closes [issue 5929](googleapis#5929) - [Commit c8e9a48](googleapis@c8e9a48): - refactor: Makes GoogleLoggerScope extendable. Moves GoogleLoggerScope to Diagnostics.Common. In preparation for allowing LogEntry augmentation and making it easier to use Google logging from non ASP.NET Core apps. Towards [issue 5313](googleapis#5313), [issue 5360](googleapis#5360), [issue 5929](googleapis#5929) and [issue 6367](googleapis#6367) - [Commit 7f5f89e](googleapis@7f5f89e): - docs: Change Stackdriver to Google Cloud, and fix some typos, including in test code. - [Commit c4c9cd5](googleapis@c4c9cd5): - feat: Makes it easier to use tracing from non ASP.NET Core applications Closes [issue 5897](googleapis#5897) Towards [issue 6367](googleapis#6367) - [Commit b35b9ea](googleapis@b35b9ea): - feat: Decouples Diagnostics tracing from Google's trace header. Towards [issue 5360](googleapis#5360) and [issue 5897](googleapis#5897) - [Commit 0c00d2c](googleapis@0c00d2c): - refactor: Remove unnecesary service provider extension method. There's an equivalent method offered by Microsoft.Extensions.DependencyInjection so we don't need our own. - [Commit bb0c7b2](googleapis@bb0c7b2): - refactor: Remove unnecesary interface IManagedTracerFactory. It's an internal interface that we don't use anywhere. We can always add it back in if we need it at some point. - [Commit 8ef3983](googleapis@8ef3983): - fix: X-Cloud-Trace-Context trace mask values should be 0-1. See https://cloud.google.com/trace/docs/setup#force-trace Note: changing a generic type parameter constraint in `LabelProviderExtensions` is notionally a breaking change, but due to how it will be used, we don't expect it to actually break any customers. Changes in Google.Cloud.Diagnostics.AspNetCore3 version 4.3.0-beta01: - [Commit 60e8cd8](googleapis@60e8cd8): - feat: Copies GoogleLogger to Common. This allows easier use of GoogleLogger in non ASP.NET Core applications. - Towards [issue 6367](googleapis#6367) - Replicate LoggerOptions in Common, and have AspNetCore\*.LoggerOptions be just a wrapper of Common.LoggerOptions. - Copies ILogEntryLabelProvider to Common and marks the one in AspNetCore* Obsolete. - Makes AspNetCore*.IExternalTraceProvider obsolete. It can now be replaced by Common.ITraceContext. - [Commit 32cb606](googleapis@32cb606): - feat: Allows per log entry labels. - Closes [issue 5313](googleapis#5313) - Closes [issue 5929](googleapis#5929) - [Commit c8e9a48](googleapis@c8e9a48): - refactor: Makes GoogleLoggerScope extendable. Moves GoogleLoggerScope to Diagnostics.Common. In preparation for allowing LogEntry augmentation and making it easier to use Google logging from non ASP.NET Core apps. Towards [issue 5313](googleapis#5313), [issue 5360](googleapis#5360), [issue 5929](googleapis#5929) and [issue 6367](googleapis#6367) - [Commit 7f5f89e](googleapis@7f5f89e): - docs: Change Stackdriver to Google Cloud, and fix some typos, including in test code. - [Commit c4c9cd5](googleapis@c4c9cd5): - feat: Makes it easier to use tracing from non ASP.NET Core applications Closes [issue 5897](googleapis#5897) Towards [issue 6367](googleapis#6367) - [Commit b35b9ea](googleapis@b35b9ea): - feat: Decouples Diagnostics tracing from Google's trace header. Towards [issue 5360](googleapis#5360) and [issue 5897](googleapis#5897) - [Commit 0c00d2c](googleapis@0c00d2c): - refactor: Remove unnecesary service provider extension method. There's an equivalent method offered by Microsoft.Extensions.DependencyInjection so we don't need our own. - [Commit bb0c7b2](googleapis@bb0c7b2): - refactor: Remove unnecesary interface IManagedTracerFactory. It's an internal interface that we don't use anywhere. We can always add it back in if we need it at some point. - [Commit 8ef3983](googleapis@8ef3983): - fix: X-Cloud-Trace-Context trace mask values should be 0-1. See https://cloud.google.com/trace/docs/setup#force-trace Note: changing a generic type parameter constraint in `LabelProviderExtensions` is notionally a breaking change, but due to how it will be used, we don't expect it to actually break any customers. Packages in this release: - Release Google.Cloud.Diagnostics.AspNetCore version 4.3.0-beta01 - Release Google.Cloud.Diagnostics.AspNetCore3 version 4.3.0-beta01 - Release Google.Cloud.Diagnostics.Common version 4.3.0-beta01
Changes in Google.Cloud.Diagnostics.AspNetCore version 4.3.0-beta01: - [Commit 60e8cd8](60e8cd8): - feat: Copies GoogleLogger to Common. This allows easier use of GoogleLogger in non ASP.NET Core applications. - Towards [issue 6367](#6367) - Replicate LoggerOptions in Common, and have AspNetCore\*.LoggerOptions be just a wrapper of Common.LoggerOptions. - Copies ILogEntryLabelProvider to Common and marks the one in AspNetCore* Obsolete. - Makes AspNetCore*.IExternalTraceProvider obsolete. It can now be replaced by Common.ITraceContext. - [Commit 32cb606](32cb606): - feat: Allows per log entry labels. - Closes [issue 5313](#5313) - Closes [issue 5929](#5929) - [Commit c8e9a48](c8e9a48): - refactor: Makes GoogleLoggerScope extendable. Moves GoogleLoggerScope to Diagnostics.Common. In preparation for allowing LogEntry augmentation and making it easier to use Google logging from non ASP.NET Core apps. Towards [issue 5313](#5313), [issue 5360](#5360), [issue 5929](#5929) and [issue 6367](#6367) - [Commit 7f5f89e](7f5f89e): - docs: Change Stackdriver to Google Cloud, and fix some typos, including in test code. - [Commit c4c9cd5](c4c9cd5): - feat: Makes it easier to use tracing from non ASP.NET Core applications Closes [issue 5897](#5897) Towards [issue 6367](#6367) - [Commit b35b9ea](b35b9ea): - feat: Decouples Diagnostics tracing from Google's trace header. Towards [issue 5360](#5360) and [issue 5897](#5897) - [Commit 0c00d2c](0c00d2c): - refactor: Remove unnecesary service provider extension method. There's an equivalent method offered by Microsoft.Extensions.DependencyInjection so we don't need our own. - [Commit bb0c7b2](bb0c7b2): - refactor: Remove unnecesary interface IManagedTracerFactory. It's an internal interface that we don't use anywhere. We can always add it back in if we need it at some point. - [Commit 8ef3983](8ef3983): - fix: X-Cloud-Trace-Context trace mask values should be 0-1. See https://cloud.google.com/trace/docs/setup#force-trace Note: changing a generic type parameter constraint in `LabelProviderExtensions` is notionally a breaking change, but due to how it will be used, we don't expect it to actually break any customers. Changes in Google.Cloud.Diagnostics.AspNetCore3 version 4.3.0-beta01: - [Commit 60e8cd8](60e8cd8): - feat: Copies GoogleLogger to Common. This allows easier use of GoogleLogger in non ASP.NET Core applications. - Towards [issue 6367](#6367) - Replicate LoggerOptions in Common, and have AspNetCore\*.LoggerOptions be just a wrapper of Common.LoggerOptions. - Copies ILogEntryLabelProvider to Common and marks the one in AspNetCore* Obsolete. - Makes AspNetCore*.IExternalTraceProvider obsolete. It can now be replaced by Common.ITraceContext. - [Commit 32cb606](32cb606): - feat: Allows per log entry labels. - Closes [issue 5313](#5313) - Closes [issue 5929](#5929) - [Commit c8e9a48](c8e9a48): - refactor: Makes GoogleLoggerScope extendable. Moves GoogleLoggerScope to Diagnostics.Common. In preparation for allowing LogEntry augmentation and making it easier to use Google logging from non ASP.NET Core apps. Towards [issue 5313](#5313), [issue 5360](#5360), [issue 5929](#5929) and [issue 6367](#6367) - [Commit 7f5f89e](7f5f89e): - docs: Change Stackdriver to Google Cloud, and fix some typos, including in test code. - [Commit c4c9cd5](c4c9cd5): - feat: Makes it easier to use tracing from non ASP.NET Core applications Closes [issue 5897](#5897) Towards [issue 6367](#6367) - [Commit b35b9ea](b35b9ea): - feat: Decouples Diagnostics tracing from Google's trace header. Towards [issue 5360](#5360) and [issue 5897](#5897) - [Commit 0c00d2c](0c00d2c): - refactor: Remove unnecesary service provider extension method. There's an equivalent method offered by Microsoft.Extensions.DependencyInjection so we don't need our own. - [Commit bb0c7b2](bb0c7b2): - refactor: Remove unnecesary interface IManagedTracerFactory. It's an internal interface that we don't use anywhere. We can always add it back in if we need it at some point. - [Commit 8ef3983](8ef3983): - fix: X-Cloud-Trace-Context trace mask values should be 0-1. See https://cloud.google.com/trace/docs/setup#force-trace Note: changing a generic type parameter constraint in `LabelProviderExtensions` is notionally a breaking change, but due to how it will be used, we don't expect it to actually break any customers. Packages in this release: - Release Google.Cloud.Diagnostics.AspNetCore version 4.3.0-beta01 - Release Google.Cloud.Diagnostics.AspNetCore3 version 4.3.0-beta01 - Release Google.Cloud.Diagnostics.Common version 4.3.0-beta01
I want to create some custom labels and add them just 1 log entry. After looking through the code in this project, I found a way:
It works, but it adds the labels to every log. I don't want that - I just want the labels added to 1 specific log.
I think the best approach would be to let users specify labels in the
Log
/LogInformation
/LogWarning
etc calls. That base code is here. You can let the user specify labels through a new param, and then tack those on to what comes back fromCreateLabels()
further down.The text was updated successfully, but these errors were encountered: